# What does "emissive" in Asymptote do?

When drawing a 3D object in Asymptote, one can define the color with constructions like `rgb(.4,.4,1)` or `rgb(1,0,1)+opacity(.5)`, which have fairly obvious meanings. One can also wrap these color commands in `emissive(..)`, as in `emissive(rgb(1,0,1)+opacity(.3))`.

What does the `emissive` wrapper do? I can see the results, but I don't quite understand what is going on. Are there other wrappers like `emissive`?

In the manual, the only place where the word `emissive` appears is in the word `emissivepen`, on page 132. A secondary question is: what does `emissivepen` do? In that same section, `diffusepen`, `ambientpen` and `specularpen` are also defined, though I don't understand their use.

In Asymptote, a `pen` object includes certain properties (most notably, color) that are used to draw lines and fill areas. A `material` object (defined in `three_light.asy`) is used to color surfaces and includes, roughly, three different pens. To understand these, keep in mind that an Asymptote 3d picture comes equipped with "lighting", which includes one or more light sources (specifying direction and strength) and an ambient light (strength only, no direction; it's "from everywhere.").

• `diffusepen`: The way the object interacts with light sources. Portions of the surface aimed directly at the light source show up exactly this color; the color gradually fades to black as the surface approaches a 90 degree angle to the light source.
• `specularpen`: The extent to which the object behaves like a mirror. This pen only affects portions of the surface aimed directly at the light source (or close to it).
• `emissivepen`: Object coloring that is completely independent of the lighting. A surface colored with `emissivepen=red` and no other pens will show up completely red no matter what direction it is aimed.

If more than one pen is set, then the colors are added together to produce the final result.

There are three reasonably convenient ways to produce a `material` object (typically for the `surfacepen` parameter of a `draw` command):

• The full constructor:

``````  material(pen diffusepen=black,
pen emissivepen=black,
pen specularpen=mediumgray,
real opacity=opacity(diffusepen),
real shininess=defaultshininess,
real metallic=defaultmetallic,
real fresnel0=defaultfresnel0)
``````

Note that all the parameters are optional.

• A `pen` object can be cast to a `material` object. If you pass in the pen `p`, it gets cast to `material(diffusepen=p)`. Thus, the `diffusepen` will be `p`, the `specularpen` will be `mediumgray`, and the other two pens will not contribute.
• The `emissive` wrapper: if `p` is a pen, then `emissive(p)` produces a `material` with `emissivepen=p` (and `opacity` taken from `opacity(p)`), but no other pens contribute. This is convenient if you want, say, a yellow polygon that will not fade to black when the lighting changes.
• Asymptote version 2.62 give me an error on `draw(unitsphere,surfacepen=material(white+opacity(0.8),ambientpen=white), meshpen=gray(0.4));` as `no matching function 'material(pen, pen ambientpen)'` does something changed? Feb 11, 2021 at 21:37
• It appears that the `ambientpen` was removed in github.com/vectorgraphics/asymptote/commit/…, likely because the same effect can be achieved with `emissivepen`. I will modify the answer accordingly. Feb 12, 2021 at 0:15
• I'm not really sure that they are the same. I cannot reproduce the same result of this Feb 12, 2021 at 0:30
• Did you try `emissivepen=0.1*white`? They are not the same, emissive is about ten times stronger than ambient by default, but they can be used to achieve the same effect. Feb 12, 2021 at 13:33
• I think this difference should be in the answer, too. Since there are lots of examples/questions around here and outside that use the `ambientpen` but they cannot be compiled, and even some from your tutorial, too. Maybe your tutorial needs an update/note about this too. I've tried but not close to the original ( even the labels are small compared to the original image). I'll contact the author again. Feb 12, 2021 at 13:53

As I understand it, an `emissive` pen "emits" light. A non-emissive pen just reflects light. A 3D object drawn with an `emissive` red pen will be shown in pure red. A 3D object drawn with a non-emissive red pen will be shown in shades of red, depending on lighting and camera positions.