diff options
author | Karl Berry <karl@freefriends.org> | 2020-03-01 23:10:25 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-03-01 23:10:25 +0000 |
commit | 81abf43d2b32106102462c3fd1b6c52c0b74f6b7 (patch) | |
tree | 8ff3cf992c81a46d17219ac528c3cb6fe7467402 /Master/texmf-dist/asymptote/three_light.asy | |
parent | 668f13d96ea148cade89c8813883c8b5a90cb55e (diff) |
asymptote 2.62 support files
git-svn-id: svn://tug.org/texlive/trunk@53988 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/asymptote/three_light.asy')
-rw-r--r-- | Master/texmf-dist/asymptote/three_light.asy | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/Master/texmf-dist/asymptote/three_light.asy b/Master/texmf-dist/asymptote/three_light.asy index 3bd747dd4ec..6e0bc366c78 100644 --- a/Master/texmf-dist/asymptote/three_light.asy +++ b/Master/texmf-dist/asymptote/three_light.asy @@ -1,29 +1,37 @@ struct material { - pen[] p; // diffusepen,ambientpen,emissivepen,specularpen + pen[] p; // diffusepen,emissivepen,specularpen real opacity; real shininess; - void operator init(pen diffusepen=black, pen ambientpen=black, + real metallic; + real fresnel0; // Reflectance rate at a perfect normal angle. + + void operator init(pen diffusepen=black, pen emissivepen=black, pen specularpen=mediumgray, real opacity=opacity(diffusepen), - real shininess=defaultshininess) { - p=new pen[] {diffusepen,ambientpen,emissivepen,specularpen}; + real shininess=defaultshininess, + real metallic=defaultmetallic, + real fresnel0=defaultfresnel0) { + + p=new pen[] {diffusepen,emissivepen,specularpen}; this.opacity=opacity; this.shininess=shininess; + this.metallic=metallic; + this.fresnel0=fresnel0; } void operator init(material m) { p=copy(m.p); opacity=m.opacity; shininess=m.shininess; + metallic=m.metallic; + fresnel0=m.fresnel0; } pen diffuse() {return p[0];} - pen ambient() {return p[1];} - pen emissive() {return p[2];} - pen specular() {return p[3];} + pen emissive() {return p[1];} + pen specular() {return p[2];} void diffuse(pen q) {p[0]=q;} - void ambient(pen q) {p[1]=q;} - void emissive(pen q) {p[2]=q;} - void specular(pen q) {p[3]=q;} + void emissive(pen q) {p[1]=q;} + void specular(pen q) {p[2]=q;} } material operator init() @@ -36,11 +44,12 @@ void write(file file, string s="", material x, suffix suffix=none) write(file,s); write(file,"{"); write(file,"diffuse=",x.diffuse()); - write(file,", ambient=",x.ambient()); write(file,", emissive=",x.emissive()); write(file,", specular=",x.specular()); write(file,", opacity=",x.opacity); write(file,", shininess=",x.shininess); + write(file,", metallic=",x.metallic); + write(file,", F0=",x.fresnel0); write(file,"}",suffix); } @@ -52,7 +61,8 @@ void write(string s="", material x, suffix suffix=endl) bool operator == (material m, material n) { return all(m.p == n.p) && m.opacity == n.opacity && - m.shininess == n.shininess; + m.shininess == n.shininess && m.metallic == n.metallic && + m.fresnel0 == n.fresnel0; } material operator cast(pen p) @@ -72,7 +82,7 @@ pen operator ecast(material m) material emissive(material m) { - return material(black+opacity(m.opacity),black,m.diffuse(),black,m.opacity,1); + return material(black+opacity(m.opacity),m.diffuse(),black,m.opacity,1); } pen color(triple normal, material m, light light, transform3 T=light.T) { @@ -83,23 +93,19 @@ pen color(triple normal, material m, light light, transform3 T=light.T) { if(settings.twosided) normal *= sgn(normal.z); real s=m.shininess*128; real[] Diffuse=rgba(m.diffuse()); - 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=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())); @@ -113,13 +119,13 @@ light operator * (transform3 t, light light) light operator cast(triple v) {return light(v);} -light Viewport=light(ambient=gray(0.1),specularfactor=3,(0.25,-0.25,1)); +light Viewport=light(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), +light Headlamp=light(gray(0.8),specular=gray(0.7), specularfactor=3,dir(42,48)); currentlight=Headlamp; |