summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/asymptote/three_light.asy
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/asymptote/three_light.asy')
-rw-r--r--Master/texmf-dist/asymptote/three_light.asy27
1 files changed, 16 insertions, 11 deletions
diff --git a/Master/texmf-dist/asymptote/three_light.asy b/Master/texmf-dist/asymptote/three_light.asy
index 6cbd9b6f0be..3bd747dd4ec 100644
--- a/Master/texmf-dist/asymptote/three_light.asy
+++ b/Master/texmf-dist/asymptote/three_light.asy
@@ -86,36 +86,41 @@ pen color(triple normal, material m, light light, transform3 T=light.T) {
real[] Ambient=rgba(m.ambient());
real[] Specular=rgba(m.specular());
real[] p=rgba(m.emissive());
+ real[] diffuse={0,0,0,0};
+ real[] ambient={0,0,0,0};
+ real[] specular={0,0,0,0};
for(int i=0; i < position.length; ++i) {
- triple L=light.viewport ? position[i] : T*position[i];
- real Ldotn=max(dot(normal,L),0);
- p += light.ambient[i]*Ambient+Ldotn*light.diffuse[i]*Diffuse;
- // Apply specularfactor to partially compensate non-pixel-based rendering.
- if(Ldotn > 0) // Phong-Blinn model of specular reflection
- p += dot(normal,unit(L+Z))^s*light.specularfactor*
- light.specular[i]*Specular;
+ triple L=position[i];
+ real dotproduct=abs(dot(normal,L));
+ diffuse += dotproduct*light.diffuse[i];
+ ambient += light.ambient[i];
+ dotproduct=abs(dot(normal,unit(L+Z)));
+ // Phong-Blinn model of specular reflection
+ specular += dotproduct^s*light.specular[i];
}
+ p += diffuse*Diffuse;
+ p += ambient*Ambient;
+ // Apply specularfactor to partially compensate non-pixel-based rendering.
+ p += specular*Specular*light.specularfactor;
return rgb(p[0],p[1],p[2])+opacity(opacity(m.diffuse()));
}
light operator * (transform3 t, light light)
{
light light=light(light);
- if(!light.viewport) light.position=shiftless(t)*light.position;
return light;
}
light operator cast(triple v) {return light(v);}
-light Viewport=light(ambient=gray(0.1),specularfactor=3,viewport=true,
- (0.25,-0.25,1));
+light Viewport=light(ambient=gray(0.1),specularfactor=3,(0.25,-0.25,1));
light White=light(new pen[] {rgb(0.38,0.38,0.45),rgb(0.6,0.6,0.67),
rgb(0.5,0.5,0.57)},specularfactor=3,
new triple[] {(-2,-1.5,-0.5),(2,1.1,-2.5),(-0.5,0,2)});
light Headlamp=light(gray(0.8),ambient=gray(0.1),specular=gray(0.7),
- specularfactor=3,viewport=true,dir(42,48));
+ specularfactor=3,dir(42,48));
currentlight=Headlamp;