Dark colors in Asymptote

I came across strange color behavior in Asymptote. It seems that colors are darker as they should be when I draw 3D figure. Please consider the figures embedded below.

Any idea or pointer?

Source code for Figure 1:

``````import graph;
import settings;
outformat="pdf";
size(8cm, 4cm, IgnoreAspect);
real xmin=-3.5,xmax=3.5;
real ymin=0,ymax=5;
real f(real x) {return 0 + exp(-abs(x)^2);}
path Cf=graph(f, xmin,xmax, n=400);
path mypoly=buildcycle(pA--(1.64,0)--(0.5,0)--pB,graph(f,0.5,1.64));
draw(Cf);
xaxis(Label("\$x\$"), xmax=3.6, Arrow(3));
yaxis(Label("\$p\$"), ymax=1.1, Arrow(3));
filldraw(mypoly, red, black);
``````

Source code for Figure 2:

``````import graph3;
import settings;
outformat="pdf";
size(7.5cm,0);
real f(pair x) {return 1 + exp(-abs(x)^2);}
currentprojection=perspective(4,5,2);
limits((-3,-3,-0.2),(3,3,3.2));
xaxis3(Label("\$x\$",1),blue,arrow=Arrow3);
yaxis3(Label("\$y\$",1),blue,arrow=Arrow3);
zaxis3(Label("\$z\$",1),blue,arrow=Arrow3);
path3 p1=(-2.5,-2.5,0)--(2.5,-2.5,0)--(2.5,2.5,0)--(-2.5,2.5,0)--cycle;
path3 p2=scale3(2)*unitcircle3;
draw(p1);
draw(surface(reverse(p1)^^p2,planar=true),red);
draw(surface(f,(-2.5,-2.5),(2.5,2.5),nx=20,Spline),lightgray,meshpen=black+thick(),nolight);
``````
• In the next to last line of your second code block, change `red` to `emissive(red)`. That creates a `material` that is always exactly the color `red`, regardless of the lighting. Commented Jun 26, 2014 at 13:57

It is due to the light source position (in 3D). You can observe the phenomenon by playing with asy and the OpenGl render. Perhaps you can change current light by adding

``````currentlight=light(0,0,2);
``````

and

``````draw(surface(reverse(p1)^^p2,planar=true),red,currentlight);
``````

O.G.

• Welcome to TeX.SX! It is usually best if you post complete compilable minimal documents rather than code snippets. Commented Jun 26, 2014 at 13:26