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, four 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.
  • ambientpen: Object coloring that depends on the strength of the ambient light, but not the angle of the surface. In practice, setting e.g. ambientpen=red is generally equivalent to setting emissivepen=0.1 red.

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 ambientpen=black,
             pen emissivepen=black, pen specularpen=mediumgray,
             real opacity=opacity(diffusepen),
             real shininess=defaultshininess)

    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.

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.