diff --git a/Shader Minifier Library.fsproj b/Shader Minifier Library.fsproj index 14326b91..d63120dd 100644 --- a/Shader Minifier Library.fsproj +++ b/Shader Minifier Library.fsproj @@ -56,8 +56,8 @@ - + diff --git a/shader-minifier-linux.fsproj b/shader-minifier-linux.fsproj index 6d043fd4..56145fed 100644 --- a/shader-minifier-linux.fsproj +++ b/shader-minifier-linux.fsproj @@ -11,8 +11,8 @@ - + diff --git a/src/renamer.fs b/src/renamer.fs index be0b06f5..032fddca 100644 --- a/src/renamer.fs +++ b/src/renamer.fs @@ -264,22 +264,16 @@ module private RenamerImpl = // so that we can reuse them. In other words, this function allows us // to shadow global variables in a function. let shadowVariables (env: Env) block = - let d = HashSet() - let collect mEnv = function - | Var id as e -> - if not (mEnv.vars.ContainsKey(id.Name)) then d.Add id.Name |> ignore - e - | FunCall(Var id, li) as e -> - match env.funRenames.TryFind id.Name with - | Some m -> if not (m.ContainsKey li.Length) then d.Add id.Name |> ignore - | None -> d.Add id.Name |> ignore - e - | e -> e - mapStmt BlockLevel.Unknown (mapEnvExpr collect) block |> ignore - let set = HashSet(Seq.choose env.varRenames.TryFind d) - let varRenames, reusable = env.varRenames |> Map.partition (fun _ id -> id.Length > 2 || set.Contains id) - let reusable = reusable |> Seq.filter (fun x -> not (List.contains x.Value options.noRenamingList)) - let allAvailable = [for i in reusable -> i.Value] @ env.availableNames |> Seq.distinct |> Seq.toList + // Find all the variables known in varRenames that are used in the block. + // They should be preserved in the renaming environment. + let stillUsedSet = + [for ident in Analyzer.varUsesInStmt block -> ident.Name] + |> Seq.choose env.varRenames.TryFind |> set + + let varRenames, reusable = env.varRenames |> Map.partition (fun _ id -> stillUsedSet.Contains id) + let reusable = [for i in reusable -> i.Value] + |> List.filter (fun x -> not (List.contains x options.noRenamingList)) + let allAvailable = reusable @ env.availableNames |> List.distinct env.Update(varRenames, env.funRenames, allAvailable) let rec renStmt env = @@ -292,30 +286,34 @@ module private RenamerImpl = renList env renStmt b |> ignore env | If(cond, th, el) -> - renStmt env th |> ignore - Option.iter (renStmt env >> ignore) el + renStmt (env.onEnterFunction env th) th |> ignore + Option.iter (fun el -> renStmt (env.onEnterFunction env el) el |> ignore) el renExpr env cond env - | ForD(init, cond, inc, body) -> - let newEnv = renDecl false env init + | ForD(init, cond, inc, body) as stmt -> + let newEnv = env.onEnterFunction env stmt + let newEnv = renDecl false newEnv init renStmt newEnv body |> ignore Option.iter (renExpr newEnv) cond Option.iter (renExpr newEnv) inc if options.hlsl then newEnv else env - | ForE(init, cond, inc, body) -> + | ForE(init, cond, inc, body) as stmt -> + let newEnv = env.onEnterFunction env stmt renOpt init renOpt cond renOpt inc - renStmt env body |> ignore + renStmt newEnv body |> ignore env - | While(cond, body) -> - renExpr env cond - renStmt env body |> ignore + | While(cond, body) as stmt -> + let newEnv = env.onEnterFunction env stmt + renExpr newEnv cond + renStmt newEnv body |> ignore env - | DoWhile(cond, body) -> - renExpr env cond - renStmt env body |> ignore + | DoWhile(cond, body) as stmt -> + let newEnv = env.onEnterFunction env stmt + renExpr newEnv cond + renStmt newEnv body |> ignore env | Jump(_, e) -> renOpt e; env | Verbatim _ -> env diff --git a/tests/compression_results.log b/tests/compression_results.log index 3abb69c0..74a8622f 100644 --- a/tests/compression_results.log +++ b/tests/compression_results.log @@ -1,24 +1,24 @@ -clod.frag... 8760 => 1495.202 -mouton/mouton.vert... 16770 => 2417.200 +clod.frag... 8760 => 1486.187 +mouton/mouton.vert... 16740 => 2404.493 audio-flight-v2.frag 4486 => 878.312 -buoy.frag 4013 => 605.720 +buoy.frag 4013 => 606.290 controllable-machinery.frag 7683 => 1225.947 ed-209.frag 7672 => 1338.529 elevated.hlsl 3401 => 602.542 -endeavour.frag 2568 => 529.742 -from-the-seas-to-the-stars.frag 14240 => 2306.531 -frozen-wasteland.frag 4517 => 803.422 +endeavour.frag 2568 => 529.992 +from-the-seas-to-the-stars.frag 14240 => 2285.909 +frozen-wasteland.frag 4517 => 813.441 kinder_painter.frag 2836 => 442.689 -leizex.frag 2252 => 507.685 -lunaquatic.frag 5222 => 1043.813 +leizex.frag 2252 => 506.309 +lunaquatic.frag 5222 => 1043.256 mandelbulb.frag 2325 => 534.901 -ohanami.frag 3246 => 721.169 +ohanami.frag 3246 => 711.753 orchard.frag 5393 => 1002.991 oscars_chair.frag 4648 => 986.069 robin.frag 6204 => 1039.733 -slisesix.frag 4497 => 895.900 -terrarium.frag 3575 => 750.087 -the_real_party_is_in_your_pocket.frag 11986 => 1779.232 +slisesix.frag 4497 => 890.639 +terrarium.frag 3575 => 747.116 +the_real_party_is_in_your_pocket.frag 11986 => 1774.550 valley_ball.glsl 4307 => 881.820 -yx_long_way_from_home.frag 2938 => 599.331 -Total: 133539 => 23388.566 +yx_long_way_from_home.frag 2938 => 600.714 +Total: 133509 => 23334.181 diff --git a/tests/real/chocolux.expected b/tests/real/chocolux.expected index 4eb9edab..5e90eda3 100644 --- a/tests/real/chocolux.expected +++ b/tests/real/chocolux.expected @@ -17,23 +17,23 @@ const char *chocolux_frag = "vec3 i=vec3(c.x,c.y*1.25-.3,0),y=vec3(c.x+cos(v)*.3,c.y,1)/64.;" "vec4 f=vec4(0);" "float x=0.;" - "for(int b=0;b<75;b++)" + "for(int v=0;v<75;v++)" "{" "if(s(i+y*x)<.4)" "{" "x-=5.;" - "for(int m=0;m<5;m++)" + "for(int f=0;f<5;f++)" "{" "if(s(i+y*x)<.4)" "break;" "x+=1.;" "}" - "vec3 m=vec3(.01,0,0),r=vec3(0);" - "r.x=s(i+y*x)-s(vec3(i+y*x+m.xyy));" - "r.y=s(i+y*x)-s(vec3(i+y*x+m.yxy));" - "r.z=s(i+y*x)-s(vec3(i+y*x+m.yyx));" - "r=normalize(r);" - "f+=max(dot(vec3(0,0,-.5),r),0.)+max(dot(vec3(0,-.5,.5),r),0.)*.5;" + "vec3 d=vec3(.01,0,0),v=vec3(0);" + "v.x=s(i+y*x)-s(vec3(i+y*x+d.xyy));" + "v.y=s(i+y*x)-s(vec3(i+y*x+d.yxy));" + "v.z=s(i+y*x)-s(vec3(i+y*x+d.yyx));" + "v=normalize(v);" + "f+=max(dot(vec3(0,0,-.5),v),0.)+max(dot(vec3(0,-.5,.5),v),0.)*.5;" "break;" "}" "x+=5.;" diff --git a/tests/real/clod.expected b/tests/real/clod.expected index 0141317a..363ccf85 100644 --- a/tests/real/clod.expected +++ b/tests/real/clod.expected @@ -1 +1 @@ -uniform vec2 v;uniform float s;uniform sampler2D y,c,n,C;float m(vec3 v){float s=(sin(v.x)+v.y*.25)*.35;v=vec3(cos(s)*v.x-sin(s)*v.y,sin(s)*v.x+cos(s)*v.y,v.z);return dot(cos(v)*cos(v),vec3(1))-1.2;}vec3 m(vec3 v,vec3 s){float y=0.,c,f;for(int r=0;r<75;r++){if(m(v+s*y)<0.){c=y-.125;f=y;for(int u=0;u<10;u++){y=(c+f)*.5;if(m(v+s*y)<0.)f=y;else c=y;}vec3 d=vec3(.1,0,0),i=v+s*y,n=-normalize(vec3(m(i+d),m(i+d.yxy),m(i+d.yyx))+vec3(sin(i*75.))*.01);return vec3(mix((max(-dot(n,vec3(.577)),0.)+.125*max(-dot(n,vec3(-.707,-.707,0)),0.))*(mod(length(i.xy)*20.,2.)<1.?vec3(.71,.85,.25):vec3(.79,.93,.4)),vec3(.93,.94,.85),vec3(pow(y/9.,5.))));}y+=.125;}return vec3(.93,.94,.85);}void main(){vec2 i=-1.+2.*gl_FragCoord.xy/v.xy;gl_FragColor=vec4(m(vec3(sin(s*1.5)*.5,cos(s)*.5,s),normalize(vec3(i.xy,1))),1);} +uniform vec2 v;uniform float s;uniform sampler2D y,c,n,C;float m(vec3 v){float s=(sin(v.x)+v.y*.25)*.35;v=vec3(cos(s)*v.x-sin(s)*v.y,sin(s)*v.x+cos(s)*v.y,v.z);return dot(cos(v)*cos(v),vec3(1))-1.2;}vec3 m(vec3 v,vec3 s){float y=0.,c,f;for(int r=0;r<75;r++){if(m(v+s*y)<0.){c=y-.125;f=y;for(int r=0;r<10;r++){y=(c+f)*.5;if(m(v+s*y)<0.)f=y;else c=y;}vec3 r=vec3(.1,0,0),i=v+s*y,n=-normalize(vec3(m(i+r),m(i+r.yxy),m(i+r.yyx))+vec3(sin(i*75.))*.01);return vec3(mix((max(-dot(n,vec3(.577)),0.)+.125*max(-dot(n,vec3(-.707,-.707,0)),0.))*(mod(length(i.xy)*20.,2.)<1.?vec3(.71,.85,.25):vec3(.79,.93,.4)),vec3(.93,.94,.85),vec3(pow(y/9.,5.))));}y+=.125;}return vec3(.93,.94,.85);}void main(){vec2 i=-1.+2.*gl_FragCoord.xy/v.xy;gl_FragColor=vec4(m(vec3(sin(s*1.5)*.5,cos(s)*.5,s),normalize(vec3(i.xy,1))),1);} diff --git a/tests/real/elevated.hlsl.expected b/tests/real/elevated.hlsl.expected index b3e5b7bb..f364e81f 100644 --- a/tests/real/elevated.hlsl.expected +++ b/tests/real/elevated.hlsl.expected @@ -78,54 +78,54 @@ const char *elevated_hlsl = "float3 r=float3(.55,.65,.75)+.1*D(s+t[3].w*.2,10)+.5*pow(1-x.y,8)+pow(saturate(mul(x,t[3])),16)*float3(.4,.3,.1)+float4(1+.4*w,2,3+.5*w,0)*(1-cos(12.5664*s.y))*saturate(1-abs(s.y)/10-abs(s.x+t[5+w].x*.0012-8)/20)*exp(-t[5+w].x*2e-4);" "if(y.w>.5)" "{" - "float c=length(y.xyz-t[4].xyz),p=t[1].w-y.y;" - "if(p<0)" + "float f=length(y.xyz-t[4].xyz),w=t[1].w-y.y;" + "if(w<0)" "{" - "float3 e=D(y.xz,.001*c,12-log2(c));" - "float n=D(3*y.xz,3),d=D(666*y.xz);" - "r=(.1+.75*t[2].x)*(.8+.2*d);" - "r=lerp(r,lerp(float3(.8,.85,.9),float3(.45,.45,.2)*(.8+.2*d),t[2].x),smoothstep(.5-.8*e.y,1-1.1*e.y,n*.15));" - "r=lerp(r,lerp(float3(.37,.23,.08),float3(.42,.4,.2),t[2].x)*(.5+.5*d),smoothstep(0,1,50*(e.y-1)+(n+t[2].x)/.4));" - "r*=l(y,e,D(y.xz,.001*c,5));" + "float3 x=D(y.xz,.001*f,12-log2(f));" + "float w=D(3*y.xz,3),s=D(666*y.xz);" + "r=(.1+.75*t[2].x)*(.8+.2*s);" + "r=lerp(r,lerp(float3(.8,.85,.9),float3(.45,.45,.2)*(.8+.2*s),t[2].x),smoothstep(.5-.8*x.y,1-1.1*x.y,w*.15));" + "r=lerp(r,lerp(float3(.37,.23,.08),float3(.42,.4,.2),t[2].x)*(.5+.5*s),smoothstep(0,1,50*(x.y-1)+(w+t[2].x)/.4));" + "r*=l(y,x,D(y.xz,.001*f,5));" "}" "else" "{" - "c=(t[1].w-t[4].y)/x.y;" - "y=t[4]+x.xyzz*c;" - "float3 d=normalize(D(float2(512,32)*y.xz+saturate(p*60)*float2(t[3].w,0),.001*c,4)*float3(1,6,1));" - "r=.12*(float3(.4,1,1)-float3(.2,.6,.4)*saturate(p*16));" + "f=(t[1].w-t[4].y)/x.y;" + "y=t[4]+x.xyzz*f;" + "float3 z=normalize(D(float2(512,32)*y.xz+saturate(w*60)*float2(t[3].w,0),.001*f,4)*float3(1,6,1));" + "r=.12*(float3(.4,1,1)-float3(.2,.6,.4)*saturate(w*16));" "r*=.3+.7*t[2].x;" - "r+=pow(1-mul(-x,d),4)*(pow(mul(t[3],reflect(-x,d)),32)*float3(.32,.31,.3)+.1);" - "r=lerp(r,l(y,d,d),smoothstep(1,0,t[2].x+p*60-D(666*y.xz+saturate(p*60)*float2(t[3].w,0)*2,5))*.5);" + "r+=pow(1-mul(-x,z),4)*(pow(mul(t[3],reflect(-x,z)),32)*float3(.32,.31,.3)+.1);" + "r=lerp(r,l(y,z,z),smoothstep(1,0,t[2].x+w*60-D(666*y.xz+saturate(w*60)*float2(t[3].w,0)*2,5))*.5);" "}" - "r=r*(.7+.3*smoothstep(0,1,256*abs(p)))*exp(-.042*c);" - "r+=(1-exp(-.1*c))*(float3(.52,.59,.65)+pow(saturate(mul(x,t[3])),8)*float3(.6,.4,.1));" + "r=r*(.7+.3*smoothstep(0,1,256*abs(w)))*exp(-.042*f);" + "r+=(1-exp(-.1*f))*(float3(.52,.59,.65)+pow(saturate(mul(x,t[3])),8)*float3(.6,.4,.1));" "}" "return float4(r,0);" "}" "float4 s(float2 x:texcoord):color" "{" "float2 s=x+.5/1280;" - "float4 r=tex2D(m,s);" - "float3 w=tex2D(y,s);" - "if(r.w>.5)" + "float4 w=tex2D(m,s);" + "float3 r=tex2D(y,s);" + "if(w.w>.5)" "{" - "r=mul(z,float4(r.xyz,1));" - "r.y*=-1;" - "w=0;" - "for(float p=0;p<16;p++)" - "w.x+=tex2D(y,s+p*(.5+.5*r.xy/r.w-s)/16+float2(2,0)/1280).x,w.y+=tex2D(y,s+p*(.5+.5*r.xy/r.w-s)/16+float2(0,0)/1280).y,w.z+=tex2D(y,s+p*(.5+.5*r.xy/r.w-s)/16+float2(-2,0)/1280).z;" - "w/=16;" + "w=mul(z,float4(w.xyz,1));" + "w.y*=-1;" + "r=0;" + "for(float f=0;f<16;f++)" + "r.x+=tex2D(y,s+f*(.5+.5*w.xy/w.w-s)/16+float2(2,0)/1280).x,r.y+=tex2D(y,s+f*(.5+.5*w.xy/w.w-s)/16+float2(0,0)/1280).y,r.z+=tex2D(y,s+f*(.5+.5*w.xy/w.w-s)/16+float2(-2,0)/1280).z;" + "r/=16;" "}" - "w=(pow(w,.45)*t[2].z+t[2].y)*(.4+9.6*s.x*s.y*(1-s.x)*(1-s.y));" - "w.xz*=.98;" - "float c=tex2D(f,t[3].w*.1);" - "s+=c;" - "w-=.005*c;" - "w.x+=.01*tex2D(f,s+=.1);" - "w.y+=.01*tex2D(f,s+=.1);" - "w.z+=.01*tex2D(f,s+=.1);" - "return float4(w,0);" + "r=(pow(r,.45)*t[2].z+t[2].y)*(.4+9.6*s.x*s.y*(1-s.x)*(1-s.y));" + "r.xz*=.98;" + "float D=tex2D(f,t[3].w*.1);" + "s+=D;" + "r-=.005*D;" + "r.x+=.01*tex2D(f,s+=.1);" + "r.y+=.01*tex2D(f,s+=.1);" + "r.z+=.01*tex2D(f,s+=.1);" + "return float4(r,0);" "}"; #endif // ELEVATED_HLSL_EXPECTED_ diff --git a/tests/real/leizex.expected b/tests/real/leizex.expected index 2e7fc670..3ac54fb1 100644 --- a/tests/real/leizex.expected +++ b/tests/real/leizex.expected @@ -31,12 +31,12 @@ _leizex_frag: db 'ivec3 f=ivec3(floor(v));' db 'vec3 x=fract(v);' db 'vec2 n=vec2(1);' - db 'for(int y=-1;y<=1;y++)' - db 'for(int i=-1;i<=1;i++)' - db 'for(int r=-1;r<=1;r++)' + db 'for(int v=-1;v<=1;v++)' + db 'for(int y=-1;y<=1;y++)' + db 'for(int i=-1;i<=1;i++)' db '{' - db 'int c=f.x+r+57*(f.y+i)+113*(f.z+y);' - db 'vec3 m=vec3(float(r),float(i),float(y))-x+vec3(t(c),t(c+1217),t(c+2513))/2147483647.;' + db 'int c=f.x+i+57*(f.y+y)+113*(f.z+v);' + db 'vec3 m=vec3(float(i),float(y),float(v))-x+vec3(t(c),t(c+1217),t(c+2513))/2147483647.;' db 'float s=dot(m,m);' db 'if(s.001)" - "if(f(x,y,r,p,g))" - "n=.1;" - "z=mix(mix(mix(vec3(1),vec3(.8,.6,.2),sqrt(d.x)*1.25),vec3(.8,.3,.3),sqrt(d.y)*1.25),vec3(.7,.4,.3),sqrt(d.z)*1.25)*((.5+.5*s.y)*vec3(.14,.15,.16)*.8+n*vec3(1,.85,.4)+.5*t*vec3(.08,.1,.14))*vec3(pow(w,.8),pow(w,1.),pow(w,1.1));" + "vec4 x;" + "if(v>.001)" + "if(f(i,y,r,p,x))" + "v=.1;" + "z=mix(mix(mix(vec3(1),vec3(.8,.6,.2),sqrt(d.x)*1.25),vec3(.8,.3,.3),sqrt(d.y)*1.25),vec3(.7,.4,.3),sqrt(d.z)*1.25)*((.5+.5*s.y)*vec3(.14,.15,.16)*.8+v*vec3(1,.85,.4)+.5*t*vec3(.08,.1,.14))*vec3(pow(w,.8),pow(w,1.),pow(w,1.1));" "z=1.5*(z*.15+.85*sqrt(z));" "}" "else" diff --git a/tests/real/mouton/mouton.expected b/tests/real/mouton/mouton.expected index 2f0dc7da..effd0c97 100644 --- a/tests/real/mouton/mouton.expected +++ b/tests/real/mouton/mouton.expected @@ -14,7 +14,7 @@ # define VAR_eyesSurprise "p" # define VAR_fishEyeFactor "u" # define VAR_flowerPos "s" -# define VAR_fragColor "C" +# define VAR_fragColor "U" # define VAR_headRot "a" # define VAR_iTime "t" # define VAR_noseSize "w" @@ -22,7 +22,7 @@ # define VAR_panelWarningPos "x" # define VAR_sheepPos "m" # define VAR_sunDir "r" -# define VAR_tex "Y" +# define VAR_tex "Q" const char *mouton_vert = "#version 150\n" @@ -55,125 +55,125 @@ const char *mouton_vert = "i=vec3(1,.2,.25),f=vec3(1,1,2),l=vec3(0,.5,1),a.y=.25,o=4.,c=vec3(5,.5,0),e=vec3(0,.5,1);" "else if(g<29.5)" "{" - "float C=g-14.5;" + "float v=g-14.5;" "i=vec3(1,.2,.25);" "f=vec3(1,1,2);" "l=vec3(0,.5,1);" "a.y=.25;" - "c=vec3(5.+C*.5,2,C*.5);" + "c=vec3(5.+v*.5,2,v*.5);" "e=vec3(0,2,0);" "}" "else if(g<44.)" "{" - "float C=g-29.;" + "float v=g-29.;" "i=vec3(1,.2,.25);" "f=vec3(1,1,2);" "l=vec3(0,.5,1);" "a.y=.25;" - "float U=C*.35+2.5;" - "r=normalize(vec3(cos(U),sin(U),-.3));" + "float y=v*.35+2.5;" + "r=normalize(vec3(cos(y),sin(y),-.3));" "o=1.5;" - "c=vec3(22,2,C*.6-10.);" - "e=vec3(0,2,C*.6-10.);" + "c=vec3(22,2,v*.6-10.);" + "e=vec3(0,2,v*.6-10.);" "}" "else if(g<52.)" "{" - "float C=g-44.,U=smoothstep(5.,5.5,C);" - "a.y=mix(.25,0.,U);" - "i=vec3(1.-U,.2*(1.-U),1);" + "float v=g-44.,x=smoothstep(5.,5.5,v);" + "a.y=mix(.25,0.,x);" + "i=vec3(1.-x,.2*(1.-x),1);" "f=vec3(1,1,.5);" - "l=vec3(U*.3,.3-U*.3,1);" - "p=smoothstep(7.4,7.6,C)*.2;" + "l=vec3(x*.3,.3-x*.3,1);" + "p=smoothstep(7.4,7.6,v)*.2;" "o=4.;" "c=vec3(0,3,-4);" "e=vec3(0,3,0);" - "if(C>3.)" + "if(v>3.)" "n=max(fract(t*.333),fract(t*.333+.08));" "}" "else if(g<54.8)" "{" - "float C=g-52.;" + "float v=g-52.;" "y=vec3(-5,0,-8);" "m=vec3(9e7);" "l=vec3(.3,0,1);" "p=.2;" - "float U=smoothstep(0.,.5,C);" - "o=mix(4.,3.,U);" + "float x=smoothstep(0.,.5,v);" + "o=mix(4.,3.,x);" "c=vec3(0,3,-4);" - "e=mix(vec3(0,3,0),vec3(-5,5,-9),U);" + "e=mix(vec3(0,3,0),vec3(-5,5,-9),x);" "}" "else if(g<60.)" "{" - "float C=g-55.;" - "d.x=smoothstep(0.,.5,C);" + "float v=g-55.;" + "d.x=smoothstep(0.,.5,v);" "i=vec3(0);" "n=0.;" "l=vec3(.3,0,1);" "c=mix(vec3(0,3,-4),vec3(0,2,-6),d.x);" "e=vec3(0,3,0);" - "o=mix(4.,3.,d.x)+smoothstep(0.,5.,C);" + "o=mix(4.,3.,d.x)+smoothstep(0.,5.,v);" "}" "else if(g<65.)" "{" - "float C=g-60.;" + "float v=g-60.;" "l=vec3(0,0,1);" - "m=vec3(0,0,-C*3.-2.);" + "m=vec3(0,0,-v*3.-2.);" "y=vec3(-5,0,-8);" "i=vec3(1,1,.5);" "f=vec3(3,1.5,8)*1.5;" "c=vec3(16,5,9);" - "e=vec3(3,5,-2.-C);" + "e=vec3(3,5,-2.-v);" "o=3.;" "}" "else if(g<73.)" "{" - "float C=g-65.;" + "float v=g-65.;" "i=vec3(1);" "f=vec3(3,1.5,8);" - "float U=mod(C,8.);" - "l=vec3(smoothstep(.5,1.,U)*smoothstep(2.8,2.5,U)-smoothstep(4.,4.5,U)*smoothstep(5.8,5.5,U)+cos(t)*.2,cos(t*.5)*.1+.1,1);" + "float x=mod(v,8.);" + "l=vec3(smoothstep(.5,1.,x)*smoothstep(2.8,2.5,x)-smoothstep(4.,4.5,x)*smoothstep(5.8,5.5,x)+cos(t)*.2,cos(t*.5)*.1+.1,1);" "u=.3;" "o=2.5;" "c=vec3(2.75,1,-5.25);" "e=vec3(0,2.3,0);" - "float D=mod(C,2.);" - "w+=smoothstep(.5,.6,D)*smoothstep(.7,.6,D)*.3;" - "D=mod(C+.3,3.);" - "w+=smoothstep(.5,.6,D)*smoothstep(.7,.6,D)*.3;" + "float y=mod(v,2.);" + "w+=smoothstep(.5,.6,y)*smoothstep(.7,.6,y)*.3;" + "y=mod(v+.3,3.);" + "w+=smoothstep(.5,.6,y)*smoothstep(.7,.6,y)*.3;" "}" "else if(g<76.)" "{" - "float C=g-73.,U=smoothstep(1.,3.,C);" - "i=vec3(0,1.-U*.5,1);" + "float v=g-73.,y=smoothstep(1.,3.,v);" + "i=vec3(0,1.-y*.5,1);" "f=vec3(3,1.5,6);" - "l=vec3(U*.5,.3-U*.45,1);" + "l=vec3(y*.5,.3-y*.45,1);" "o=4.;" "c=vec3(0,3,-4);" "e=vec3(0,3,0);" - "if(C>3.)" + "if(v>3.)" "n=max(fract(t*.333),fract(t*.333+.08));" "}" "else if(g<81.25)" "{" - "float C=g-76.;" + "float v=g-76.;" "x=vec3(-5,0,-8);" "l=vec3(.5,-.15,1);" "i=vec3(0,.5,1);" "f=vec3(3,1.5,6);" - "float U=smoothstep(0.,1.,C);" - "o=mix(4.,3.,U);" + "float y=smoothstep(0.,1.,v);" + "o=mix(4.,3.,y);" "c=vec3(0,3,-4);" - "e=mix(vec3(0,3,0),vec3(-5,5,-9),U);" + "e=mix(vec3(0,3,0),vec3(-5,5,-9),y);" "}" "else if(g<88.)" "{" - "float C=g-81.25;" + "float v=g-81.25;" "m=vec3(0,0,-11);" "x=vec3(-5,0,-8);" - "l=normalize(mix(vec3(1,-.5,1),vec3(0,.5,1),smoothstep(2.8,3.2,C)));" - "l=mix(l,vec3(1,-.5,1),smoothstep(6.,6.5,C));" - "a.y=smoothstep(3.,3.5,C)*.6;" - "a.x=smoothstep(3.,3.5,C)*smoothstep(7.,5.,C)*.25*sin(C*3.);" + "l=normalize(mix(vec3(1,-.5,1),vec3(0,.5,1),smoothstep(2.8,3.2,v)));" + "l=mix(l,vec3(1,-.5,1),smoothstep(6.,6.5,v));" + "a.y=smoothstep(3.,3.5,v)*.6;" + "a.x=smoothstep(3.,3.5,v)*smoothstep(7.,5.,v)*.25*sin(v*3.);" "i=vec3(1,.2,.5);" "f=vec3(0,.2,1);" "c=vec3(-3,4.8,-30);" @@ -182,11 +182,11 @@ const char *mouton_vert = "}" "else if(g<96.)" "{" - "float C=g-87.,U=smoothstep(6.,9.,C);" - "m=vec3(0,0,C*.25-11.);" + "float v=g-87.,y=smoothstep(6.,9.,v);" + "m=vec3(0,0,v*.25-11.);" "x=vec3(-2,0,-8);" - "l=vec3(-.5,.25-U,1);" - "a.y=.5-U;" + "l=vec3(-.5,.25-y,1);" + "a.y=.5-y;" "i=vec3(1,.2,.5);" "f=vec3(-1,1,1)*.5;" "c=vec3(18,5,-5);" @@ -195,124 +195,124 @@ const char *mouton_vert = "}" "else if(g<102.)" "{" - "float C=g-96.;" + "float v=g-96.;" "i=vec3(0);" "f=vec3(0);" "x=vec3(0,0,-8);" - "e=mod(C,3.)<1.5?" + "e=mod(v,3.)<1.5?" "(n=0.,c=vec3(0,2,-8),vec3(0,3,0)):" "(c=vec3(0,5.5,2),vec3(0,5.75,0));" "l=vec3(0,-.1,1);" - "o=3.+C*.1;" + "o=3.+v*.1;" "}" "else if(g<110.)" "{" - "float C=g-103.5,U=sin(min(C,5.));" + "float v=g-103.5,y=sin(min(v,5.));" "i=vec3(0);" "f=vec3(0);" - "l=normalize(vec3(U*.7,0,1));" - "l=mix(l,vec3(-.3,.2,1),smoothstep(5.2,5.4,C));" - "a.x=U*.25;" - "p=smoothstep(6.,6.2,C)*.2;" - "m=vec3(0,(smoothstep(6.,6.2,C)-smoothstep(6.2,6.4,C))*.4,0);" + "l=normalize(vec3(y*.7,0,1));" + "l=mix(l,vec3(-.3,.2,1),smoothstep(5.2,5.4,v));" + "a.x=y*.25;" + "p=smoothstep(6.,6.2,v)*.2;" + "m=vec3(0,(smoothstep(6.,6.2,v)-smoothstep(6.2,6.4,v))*.4,0);" "o=3.5;" "c=vec3(0,2,-8);" "e=vec3(0,3,0);" "}" "else if(g<112.)" "{" - "float C=g-110.;" + "float v=g-110.;" "m=vec3(9e7);" "x=vec3(-2,0,-8);" "s=vec3(5,0,-20);" - "float U=smoothstep(.5,1.,C);" - "o=mix(3.,4.,U);" + "float y=smoothstep(.5,1.,v);" + "o=mix(3.,4.,y);" "c=vec3(0,5.5,2);" - "e=mix(vec3(-.5,5.75,0),vec3(5,2,-20),U);" - "d.x=U*.3;" + "e=mix(vec3(-.5,5.75,0),vec3(5,2,-20),y);" + "d.x=y*.3;" "}" "else if(g<117.8)" "{" - "float C=(g-112.)*1.2;" + "float v=(g-112.)*1.2;" "i=vec3(.1);" "f=vec3(.2);" - "o=2.8+C*.15;" - "int U=int(C);" - "if(U%4==1)" - "x=vec3(0,0,-8),c=vec3(2.5,2,-1),e=vec3(1,5.25,-8),o=2.8+pow(C*.3,1.2);" - "else if(U%4==3)" - "s=vec3(4,0,-8),c=vec3(0,5.5,2),e=vec3(4,3,-8),d.x=.3+.2/12.,d.y=C/12.;" + "o=2.8+v*.15;" + "int y=int(v);" + "if(y%4==1)" + "x=vec3(0,0,-8),c=vec3(2.5,2,-1),e=vec3(1,5.25,-8),o=2.8+pow(v*.3,1.2);" + "else if(y%4==3)" + "s=vec3(4,0,-8),c=vec3(0,5.5,2),e=vec3(4,3,-8),d.x=.3+.2/12.,d.y=v/12.;" "else" " c=vec3(0,2.4,-8),e=vec3(0,3,0);" - "float D=smoothstep(.3,.7,fract(C));" - "if(U%4==0)" - "D=1.-D;" - "a.x=-D*.1;" - "l=normalize(mix(vec3(.1,-.25,1),vec3(-.2,.2,1),D));" - "l+=vec3(cos(C*10.),cos(C*5.),1)*.01;" + "float z=smoothstep(.3,.7,fract(v));" + "if(y%4==0)" + "z=1.-z;" + "a.x=-z*.1;" + "l=normalize(mix(vec3(.1,-.25,1),vec3(-.2,.2,1),z));" + "l+=vec3(cos(v*10.),cos(v*5.),1)*.01;" "}" "else if(g<121.8)" "{" - "float C=g-118.;" + "float v=g-118.;" "m=vec3(9e7);" "x=vec3(-2,0,-8);" "s=vec3(5,0,-20);" - "o=9.+C*.2;" + "o=9.+v*.2;" "c=vec3(0,5.5,2);" "e=vec3(5,2,-20);" "d.x=.4;" - "d.y=C;" + "d.y=v;" "}" "else if(g<125.)" "{" - "float C=g-120.;" + "float v=g-120.;" "i=vec3(0,.1,0);" "f=vec3(0,.5,0);" "c=vec3(0,2.4,-8);" "e=vec3(0,3,0);" "a.x=-.1;" - "a.y=sin(C*2.)*.1;" - "p=smoothstep(0.,3.,C)*.1;" + "a.y=sin(v*2.)*.1;" + "p=smoothstep(0.,3.,v)*.1;" "l=vec3(-.2,.2,1);" - "o=3.2-C*.15;" + "o=3.2-v*.15;" "d.x=.1;" "d.y=5.;" "}" "else if(g<137.)" "{" - "float C=g-125.;" + "float v=g-125.;" "l=vec3(0,0,1);" - "m=vec3(0,0,-C*2.+2.);" + "m=vec3(0,0,-v*2.+2.);" "s=vec3(0,-.5,-30);" "i=vec3(1,1,.5);" "f=vec3(3,1.5,8);" - "c=vec3(-2,3.5,mix(-10.,-33.,smoothstep(0.,10.,C)));" - "e=vec3(2,2,-3.-C*2.);" + "c=vec3(-2,3.5,mix(-10.,-33.,smoothstep(0.,10.,v)));" + "e=vec3(2,2,-3.-v*2.);" "o=3.;" "}" "else if(g<142.)" "{" - "float C=g-137.2;" + "float v=g-137.2;" "l=vec3(0,0,1);" - "m=vec3(0,(1.-smoothstep(.3,.25,C))*-4.8,-22.-C*2.);" + "m=vec3(0,(1.-smoothstep(.3,.25,v))*-4.8,-22.-v*2.);" "s=vec3(2,0,-30);" "i=vec3(1,1,.5);" "f=vec3(3,1.5,8);" - "c=vec3(-20,6,-13)+vec3(cos(C*72.),cos(C*64.),sin(C*48.))*3.*smoothstep(.3,.31,C)*smoothstep(.7,.1,C);" + "c=vec3(-20,6,-13)+vec3(cos(v*72.),cos(v*64.),sin(v*48.))*3.*smoothstep(.3,.31,v)*smoothstep(.7,.1,v);" "e=vec3(3,2,-23);" - "o=mix(4.,4.2,smoothstep(0.,5.,C));" - "z=vec3(0,smoothstep(.3,.2,C)*13.,-22);" + "o=mix(4.,4.2,smoothstep(0.,5.,v));" + "z=vec3(0,smoothstep(.3,.2,v)*13.,-22);" "}" "else" "{" - "float C=g-143.;" + "float v=g-143.;" "l=vec3(0,0,1);" "m=vec3(9e7);" "x=vec3(-1,0,-8);" "s=vec3(1,0,-25);" "e=vec3(2,3.6,-18);" "c=vec3(5,5,2);" - "o=2.5+smoothstep(1.7,2.2,C)*4.2;" + "o=2.5+smoothstep(1.7,2.2,v)*4.2;" "z=vec3(7,0,-20);" "}" "l=normalize(l);" @@ -320,25 +320,25 @@ const char *mouton_vert = const char *mouton_frag = "#version 150\n" - "out vec4 C;" + "out vec4 U;" "const vec2 g=vec2(1920,1080);" "in vec3 i,f,m,s,y,x,z,r,c,e,l;" "in vec2 a,d;" "in float n,o,p,u,w;" "uniform float t;" - "const float U=acos(-1.);" + "const float C=acos(-1.);" "float D=0.;" - "vec2 h(vec2 i,vec2 C)" + "vec2 h(vec2 i,vec2 v)" "{" - "return i.x1e2||abs(y)<.001)" + "float x=K(v+y*i).x;" + "i+=x;" + "if(i>1e2||abs(x)<.001)" "break;" "}" "return i;" "}" - "float I(vec3 v,vec3 C)" + "float I(vec3 v,vec3 y)" "{" "float i=1.,f=.08;" - "for(int y=0;y<64;y++)" + "for(int x=0;x<64;x++)" "{" - "float m=K(v+C*f).x;" + "float m=K(v+y*f).x;" "i=min(i,30.*m/f);" "f+=m;" "if(i<1e-4||f>50.)" @@ -602,162 +602,162 @@ const char *mouton_frag = "}" "return clamp(i,0.,1.);" "}" - "float E(vec2 v,float i,float C,float x)" + "float E(vec2 v,float y,float x,float i)" "{" "v.x=abs(v.x);" - "float y=(i-C)/x,f=sqrt(1.-y*y),c=dot(v,vec2(-y,f));" + "float f=(y-x)/i,m=sqrt(1.-f*f),c=dot(v,vec2(-f,m));" "return c<0.?" - "length(v)-i:" - "c>f*x?" - "length(v-vec2(0,x))-C:" - "dot(v,vec2(f,y))-i;" + "length(v)-y:" + "c>m*i?" + "length(v-vec2(0,i))-x:" + "dot(v,vec2(m,f))-y;" "}" - "float J(vec2 v,float C)" + "float J(vec2 v,float y)" "{" - "vec2 i=vec2(.81,-.59),y=vec2(-i.x,i.y);" + "vec2 x=vec2(.81,-.59),f=vec2(-x.x,x.y);" "v.x=abs(v.x);" - "v-=2.*max(dot(i,v),0.)*i;" - "v-=2.*max(dot(y,v),0.)*y;" + "v-=2.*max(dot(x,v),0.)*x;" + "v-=2.*max(dot(f,v),0.)*f;" "v.x=abs(v.x);" - "v.y-=C;" - "y=.5*vec2(-i.y,i)-vec2(0,1);" - "float x=clamp(dot(v,y)/dot(y,y),0.,C);" - "return length(v-y*x)*sign(v.y*y.x-v.x*y.y);" + "v.y-=y;" + "f=.5*vec2(-x.y,x)-vec2(0,1);" + "float i=clamp(dot(v,f)/dot(f,f),0.,y);" + "return length(v-f*i)*sign(v.y*f.x-v.x*f.y);" "}" "void main()" "{" - "vec2 v=gl_FragCoord.xy/g,i=v*2.-1.;" - "i.x*=g.x/g.y;" - "vec3 m=c,f=A(m,e)*normalize(vec3(i,o-length(i)*u));" - "float U=H(m,f);" - "vec3 z=m+f*U;" - "vec2 a=K(z),n=vec2(1e-4,0);" - "vec3 G=normalize(vec3(a.x-K(z-n.xyy).x,a.x-K(z-n.yxy).x,a.x-K(z-n.yyx).x));" - "float w=smoothstep(0.,.3,r.y)+.1,k=B(z,G,.15,1.)*B(z,G,1.,.1)*.5,N=I(z,r),O=1.+dot(f,G);" - "vec3 L=vec3(1,.8,.7)*max(dot(G,r),0.)*pow(vec3(N),vec3(1,1.2,1.5)),M=vec3(1,.8,.7)*.1*max(dot(G,-r),0.)*k,P=vec3(.5)*mix(B(z,f,.3,.75),B(z,r,.3,.75),.5),Q=vec3(1)*max(dot(reflect(f,G),r),0.),R=vec3(0),S=vec3(.4,.45,.5)*k,T=vec3(0),b=vec3(0);" - "if(a.y==0.)" + "vec2 v=gl_FragCoord.xy/g,f=v*2.-1.;" + "f.x*=g.x/g.y;" + "vec3 i=c,m=A(i,e)*normalize(vec3(f,o-length(f)*u));" + "float z=H(i,m);" + "vec3 a=i+m*z;" + "vec2 G=K(a),n=vec2(1e-4,0);" + "vec3 C=normalize(vec3(G.x-K(a-n.xyy).x,G.x-K(a-n.yxy).x,G.x-K(a-n.yyx).x));" + "float w=smoothstep(0.,.3,r.y)+.1,k=B(a,C,.15,1.)*B(a,C,1.,.1)*.5,L=I(a,r),M=1.+dot(m,C);" + "vec3 N=vec3(1,.8,.7)*max(dot(C,r),0.)*pow(vec3(L),vec3(1,1.2,1.5)),O=vec3(1,.8,.7)*.1*max(dot(C,-r),0.)*k,P=vec3(.5)*mix(B(a,m,.3,.75),B(a,r,.3,.75),.5),Q=vec3(1)*max(dot(reflect(m,C),r),0.),R=vec3(0),S=vec3(.4,.45,.5)*k,T=vec3(0),b=vec3(0);" + "if(G.y==0.)" "b=vec3(3),P*=0.,Q*=0.;" - "else if(a.y==1.)" - "b=vec3(.4),P*=O*.5+.5,T=vec3(.35),Q=pow(Q,vec3(4))*O*.25;" - "else if(a.y==4.)" - "b=vec3(.025),P*=0.,Q=pow(Q,vec3(80))*O*10.;" - "else if(a.y==3.)" + "else if(G.y==1.)" + "b=vec3(.4),P*=M*.5+.5,T=vec3(.35),Q=pow(Q,vec3(4))*M*.25;" + "else if(G.y==4.)" + "b=vec3(.025),P*=0.,Q=pow(Q,vec3(80))*M*10.;" + "else if(G.y==3.)" "{" "P*=.5;" - "vec3 V=normalize(l+(B(vec3(t,t*.5,t*1.5))*2.-1.)*.01),W=cross(V,vec3(0,1,0)),X=cross(V,W);" - "W=cross(X,V);" - "vec3 Y=G.z*V+G.x*W+G.y*X,Z=f.z*l+f.x*W+f.y*X;" - "vec2 _=Z.xy/Z.z*length(Y.xy)/length(m-z)*.4;" - "Y.xy-=_*smoothstep(.01,0.,dot(Y,f));" - "float j=.2+p*.5,q=length(Y.xy),at=atan(Y.x,Y.y);" - "vec3 ay=mix(vec3(.5,.3,.1),vec3(0,.8,1),smoothstep(.16,.3,q)*.3+cos(at*15.)*.04);" - "float ax=smoothstep(j,j+.02,q);" - "b=mix(ay*.3,mix(ay*((smoothstep(-.9,1.,B(vec3(q*10.,at*30.+cos(q*50.+B(vec3(at))*50.),0)))+smoothstep(-.9,1.,B(vec3(q*10.,at*40.+cos(q*30.+B(vec3(at))*50.)*2.,0))))*.5+.5)*smoothstep(.3,.29,q)*(vec3(1,.8,.7)*pow(max(0.,dot(normalize(vec3(3,1,-1)),Y)),8.)*3e2+.5)*ax+pow(Q,vec3(800))*3,vec3(.8),smoothstep(.29,.3,q)),smoothstep(0.,.05,abs(q-.3)+.01));" - "G=mix(normalize(G+(l+G)*4.),G,smoothstep(.3,.32,q));" + "vec3 v=normalize(l+(B(vec3(t,t*.5,t*1.5))*2.-1.)*.01),y=cross(v,vec3(0,1,0)),x=cross(v,y);" + "y=cross(x,v);" + "vec3 f=C.z*v+C.x*y+C.y*x,s=m.z*l+m.x*y+m.y*x;" + "vec2 c=s.xy/s.z*length(f.xy)/length(i-a)*.4;" + "f.xy-=c*smoothstep(.01,0.,dot(f,m));" + "float g=.2+p*.5,z=length(f.xy),e=atan(f.x,f.y);" + "vec3 G=mix(vec3(.5,.3,.1),vec3(0,.8,1),smoothstep(.16,.3,z)*.3+cos(e*15.)*.04);" + "float o=smoothstep(g,g+.02,z);" + "b=mix(G*.3,mix(G*((smoothstep(-.9,1.,B(vec3(z*10.,e*30.+cos(z*50.+B(vec3(e))*50.),0)))+smoothstep(-.9,1.,B(vec3(z*10.,e*40.+cos(z*30.+B(vec3(e))*50.)*2.,0))))*.5+.5)*smoothstep(.3,.29,z)*(vec3(1,.8,.7)*pow(max(0.,dot(normalize(vec3(3,1,-1)),f)),8.)*3e2+.5)*o+pow(Q,vec3(800))*3,vec3(.8),smoothstep(.29,.3,z)),smoothstep(0.,.05,abs(z-.3)+.01));" + "C=mix(normalize(C+(l+C)*4.),C,smoothstep(.3,.32,z));" "{" - "vec3 ai=reflect(f,G),av=normalize(vec3(1,1.5,-1)),al=vec3(-av.x,av.y*.5,av.z);" - "R=(mix(mix(vec3(.3,.3,0),vec3(.1),smoothstep(-.7,.2,ai.y)),vec3(.3,.65,1),smoothstep(0.,1.,ai.y))+(h(ai,av,.1)+h(ai,al,2.)*.1+h(ai,normalize(av+vec3(.2,0,0)),.3)+h(ai,normalize(av+vec3(.2,0,.2)),.5)+h(ai,normalize(al+vec3(.1,0,.2)),8.)*.5)*vec3(1,.9,.8))*mix(.15,.2,ax)*sqrt(O)*2.5;" + "vec3 d=reflect(m,C),r=normalize(vec3(1,1.5,-1)),w=vec3(-r.x,r.y*.5,r.z);" + "R=(mix(mix(vec3(.3,.3,0),vec3(.1),smoothstep(-.7,.2,d.y)),vec3(.3,.65,1),smoothstep(0.,1.,d.y))+(h(d,r,.1)+h(d,w,2.)*.1+h(d,normalize(r+vec3(.2,0,0)),.3)+h(d,normalize(r+vec3(.2,0,.2)),.5)+h(d,normalize(w+vec3(.1,0,.2)),8.)*.5)*vec3(1,.9,.8))*mix(.15,.2,o)*sqrt(M)*2.5;" "}" - "K(z);" + "K(a);" "b*=smoothstep(0.,.015,D)*.4+.6;" "Q*=0.;" "}" - "else if(a.y==5.)" - "b=vec3(.85,.95,1),P*=0.,Q=pow(Q,vec3(8))*O*2.;" - "else if(a.y==6.)" + "else if(G.y==5.)" + "b=vec3(.85,.95,1),P*=0.,Q=pow(Q,vec3(8))*M*2.;" + "else if(G.y==6.)" "{" - "vec3 Y=z-x;" + "vec3 y=a-x;" "P*=0.;" - "Q=pow(Q,vec3(8))*O*20.;" - "b=G.z>.5?" - "mix(mix(vec3(1.5,0,0),vec3(2),smoothstep(.005,0.,F(Y-vec3(0,7.5,-5),vec2(1.3,.2),.01))),vec3(0),smoothstep(.13,.1295,distance(Y,vec3(0,7.1,-4.9)))+smoothstep(.005,0.,E(Y.xy-vec2(0,7.34),.06,.14,1.))):" + "Q=pow(Q,vec3(8))*M*20.;" + "b=C.z>.5?" + "mix(mix(vec3(1.5,0,0),vec3(2),smoothstep(.005,0.,F(y-vec3(0,7.5,-5),vec2(1.3,.2),.01))),vec3(0),smoothstep(.13,.1295,distance(y,vec3(0,7.1,-4.9)))+smoothstep(.005,0.,E(y.xy-vec2(0,7.34),.06,.14,1.))):" "vec3(.85,.95,1);" "}" - "else if(a.y==7.)" + "else if(G.y==7.)" "{" - "vec3 Y=z-y;" + "vec3 i=a-y;" "P*=0.;" - "Q=pow(Q,vec3(8))*O*10.;" - "if(G.z>.5)" + "Q=pow(Q,vec3(8))*M*10.;" + "if(C.z>.5)" "{" "b=vec3(0,0,1.5);" - "Y.y-=7.4;" - "float q=B(Y-vec3(0,.1,-5),vec3(.8,.8,1)),W=0.;" - "Y.xy=E(.8)*Y.xy;" - "W=(W+smoothstep(.01,0.,E(Y.xy-vec2(-.04,-.6),.1,.05,1.))+smoothstep(.01,0.,E(Y.xy-vec2(-.04,.5),.16,.135,.15)))*smoothstep(0.,.01,E(Y.xy-vec2(-.12,.56),.001,.02,.2))*smoothstep(0.,.01,E(Y.xy-vec2(0,.56),.001,.02,.2));" - "Y.xy=E(-1.6)*Y.xy;" - "W=W+smoothstep(.01,0.,E(Y.xy-vec2(.04,-.6),.1,.05,1.))+smoothstep(.01,0.,E(Y.xy-vec2(.04,.5),.16,.1,.15));" - "b=mix(mix(b,vec3(2),smoothstep(.01,0.,q)),vec3(0),W);" + "i.y-=7.4;" + "float y=B(i-vec3(0,.1,-5),vec3(.8,.8,1)),m=0.;" + "i.xy=E(.8)*i.xy;" + "m=(m+smoothstep(.01,0.,E(i.xy-vec2(-.04,-.6),.1,.05,1.))+smoothstep(.01,0.,E(i.xy-vec2(-.04,.5),.16,.135,.15)))*smoothstep(0.,.01,E(i.xy-vec2(-.12,.56),.001,.02,.2))*smoothstep(0.,.01,E(i.xy-vec2(0,.56),.001,.02,.2));" + "i.xy=E(-1.6)*i.xy;" + "m=m+smoothstep(.01,0.,E(i.xy-vec2(.04,-.6),.1,.05,1.))+smoothstep(.01,0.,E(i.xy-vec2(.04,.5),.16,.1,.15));" + "b=mix(mix(b,vec3(2),smoothstep(.01,0.,y)),vec3(0),m);" "}" "else" " b=vec3(1);" "}" - "else if(a.y==8.)" + "else if(G.y==8.)" "{" - "vec3 Y=z-s;" - "Y.x+=cos(.775+t)*3.1*.2;" - "Y.y-=2.8;" - "Y.zy=E(.75)*Y.zy;" - "b=mix(vec3(2,.75,0),vec3(2,2,0),smoothstep(0.,.45,length(Y-vec3(0,.3,0))))*1.8;" + "vec3 i=a-s;" + "i.x+=cos(.775+t)*3.1*.2;" + "i.y-=2.8;" + "i.zy=E(.75)*i.zy;" + "b=mix(vec3(2,.75,0),vec3(2,2,0),smoothstep(0.,.45,length(i-vec3(0,.3,0))))*1.8;" "P=vec3(.01);" "Q*=0.;" "}" - "else if(a.y==10.)" - "b=vec3(0,.05,0),Q*=O;" - "else if(a.y==9.)" + "else if(G.y==10.)" + "b=vec3(0,.05,0),Q*=M;" + "else if(G.y==9.)" "{" - "vec3 Y=z-s;" - "Y.x+=cos(.775+t)*3.1*.2;" - "Y.y-=2.8;" - "Y.zy=E(.75)*Y.zy;" - "b=mix(vec3(1)+.5,vec3(.75,.5,1),smoothstep(.5,1.1,length(Y-vec3(0,.3,0))))*2.;" + "vec3 i=a-s;" + "i.x+=cos(.775+t)*3.1*.2;" + "i.y-=2.8;" + "i.zy=E(.75)*i.zy;" + "b=mix(vec3(1)+.5,vec3(.75,.5,1),smoothstep(.5,1.1,length(i-vec3(0,.3,0))))*2.;" "P*=0.;" - "Q=pow(Q,vec3(4))*O;" + "Q=pow(Q,vec3(4))*M;" "}" - "else if(a.y==11.)" - "b=vec3(1),L*=vec3(.1)*O,S*=vec3(.1)*O,M*=0.,P*=0.,Q=pow(Q,vec3(100))*O*2.;" - "else if(a.y==12.)" - "b=vec3(1,.01,.01)*.3,L*=vec3(3),S*=vec3(2)*O*O,P*=0.,Q=vec3(1,.3,.3)*pow(Q,vec3(500))*5.;" - "else if(a.y==2.)" - "b=vec3(1,.7,.5),S*=vec3(1,.75,.75),P=pow(P,vec3(.5,2.5,5)+2.)*2.,Q=pow(Q,vec3(4))*O*.02;" - "b=clamp(mix((b*(S+L*.5+M*2.+P*2.)+R+Q*N+T)*w,A(f,i,w),smoothstep(90.,1e2,U)),0.,1.);" - "if(a.y==0.)" + "else if(G.y==11.)" + "b=vec3(1),N*=vec3(.1)*M,S*=vec3(.1)*M,O*=0.,P*=0.,Q=pow(Q,vec3(100))*M*2.;" + "else if(G.y==12.)" + "b=vec3(1,.01,.01)*.3,N*=vec3(3),S*=vec3(2)*M*M,P*=0.,Q=vec3(1,.3,.3)*pow(Q,vec3(500))*5.;" + "else if(G.y==2.)" + "b=vec3(1,.7,.5),S*=vec3(1,.75,.75),P=pow(P,vec3(.5,2.5,5)+2.)*2.,Q=pow(Q,vec3(4))*M*.02;" + "b=clamp(mix((b*(S+N*.5+O*2.+P*2.)+R+Q*L+T)*w,A(m,f,w),smoothstep(90.,1e2,z)),0.,1.);" + "if(G.y==0.)" "{" - "float Y=length(i)*.5,q=cos(atan(i.x,i.y)*15.-t*3.-Y*30.*d.y);" - "b=mix(b,mix(mix(vec3(1,.5,0),vec3(.8,.5,1),(cos(Y*5.+t*5.)*.5+.5)*d.y),vec3(1),smoothstep(-Y,Y,q)),d.x);" + "float v=length(f)*.5,y=cos(atan(f.x,f.y)*15.-t*3.-v*30.*d.y);" + "b=mix(b,mix(mix(vec3(1,.5,0),vec3(.8,.5,1),(cos(v*5.+t*5.)*.5+.5)*d.y),vec3(1),smoothstep(-v,v,y)),d.x);" "}" - "a=E(t*5.)*vec2(abs(i.x*5.-.35)-1.8,i.y*5.-1.4);" + "G=E(t*5.)*vec2(abs(f.x*5.-.35)-1.8,f.y*5.-1.4);" "w=(1.4+.2*sin(t*20.))*smoothstep(.5,1.,d.x);" - "b=pow(pow(mix(b,mix(vec3(1,.6,0),vec3(1,.2,0),smoothstep(-.1,.6,J(a,w*.5)))*1.3,smoothstep(0.,-.01,J(a,w))*d.x),vec3(1./2.2)),vec3(1,1.05,1.1));" + "b=pow(pow(mix(b,mix(vec3(1,.6,0),vec3(1,.2,0),smoothstep(-.1,.6,J(G,w*.5)))*1.3,smoothstep(0.,-.01,J(G,w))*d.x),vec3(1./2.2)),vec3(1,1.05,1.1));" "w=length(gl_FragCoord.xy/g.xx-vec2(.5,.3));" "k=max(.137,smoothstep(147.,146.,t));" "b*=smoothstep(k,k-.005,w);" "k=fract(23.*pow(w,.25));" "k-=smoothstep(.95,.99,k);" "b=smoothstep(0.,8.,t)*smoothstep(153.,150.,t)*mix(b,mix(vec3(1,.6,0),vec3(1,0,0),pow(k,1.)),smoothstep(.135,.136,w)*smoothstep(147.,148.,t));" - "C=vec4(b/(1.+pow(length(v*2.-1.),4.)*.04),1);" + "U=vec4(b/(1.+pow(length(v*2.-1.),4.)*.04),1);" "}"; const char *fxaa_frag = "#version 150\n" - "out vec4 C;" + "out vec4 U;" "const vec2 b=vec2(1920,1080);" - "uniform sampler2D Y;" + "uniform sampler2D Q;" "void main()" "{" - "vec2 v=1./b,i=gl_FragCoord.xy*v;" - "vec4 f=vec4(i,i-v*.5);" - "vec3 y=vec3(.299,.587,.114);" - "float m=dot(textureLod(Y,f.zw,0.).xyz,y),x=dot(textureLod(Y,f.zw+vec2(1,0)*v.xy,0.).xyz,y),c=dot(textureLod(Y,f.zw+vec2(0,1)*v.xy,0.).xyz,y),U=dot(textureLod(Y,f.zw+vec2(1)*v.xy,0.).xyz,y),a=dot(textureLod(Y,f.xy,0.).xyz,y),s=min(a,min(min(m,x),min(c,U)));" - "a=max(a,max(max(m,x),max(c,U)));" - "i=vec2(-m-x+c+U,m+c-x-U);" - "m=1./(min(abs(i.x),abs(i.y))+1./128.);" - "i=min(vec2(8),max(vec2(-8),i*m))*v.xy;" - "vec3 g=.5*(textureLod(Y,f.xy+i*(1./3.-.5),0.).xyz+textureLod(Y,f.xy+i*(2./3.-.5),0.).xyz),l=g*.5+.25*(textureLod(Y,f.xy+i*-.5,0.).xyz+textureLod(Y,f.xy+i*.5,0.).xyz);" - "m=dot(l,y);" - "C=ma?" + "vec2 v=1./b,y=gl_FragCoord.xy*v;" + "vec4 i=vec4(y,y-v*.5);" + "vec3 x=vec3(.299,.587,.114);" + "float f=dot(textureLod(Q,i.zw,0.).xyz,x),c=dot(textureLod(Q,i.zw+vec2(1,0)*v.xy,0.).xyz,x),m=dot(textureLod(Q,i.zw+vec2(0,1)*v.xy,0.).xyz,x),s=dot(textureLod(Q,i.zw+vec2(1)*v.xy,0.).xyz,x),l=dot(textureLod(Q,i.xy,0.).xyz,x),e=min(l,min(min(f,c),min(m,s)));" + "l=max(l,max(max(f,c),max(m,s)));" + "y=vec2(-f-c+m+s,f+m-c-s);" + "f=1./(min(abs(y.x),abs(y.y))+1./128.);" + "y=min(vec2(8),max(vec2(-8),y*f))*v.xy;" + "vec3 g=.5*(textureLod(Q,i.xy+y*(1./3.-.5),0.).xyz+textureLod(Q,i.xy+y*(2./3.-.5),0.).xyz),z=g*.5+.25*(textureLod(Q,i.xy+y*-.5,0.).xyz+textureLod(Q,i.xy+y*.5,0.).xyz);" + "f=dot(z,x);" + "U=fl?" "vec4(g,1):" - "vec4(l,1);" + "vec4(z,1);" "}"; #endif // MOUTON_EXPECTED_ diff --git a/tests/real/oscars_chair.frag.expected b/tests/real/oscars_chair.frag.expected index 73c3fd14..eb9a3e65 100644 --- a/tests/real/oscars_chair.frag.expected +++ b/tests/real/oscars_chair.frag.expected @@ -93,65 +93,65 @@ const char *oscars_chair_frag = "else if(gl_TexCoord[0].y==1)" "{" "gl_FragColor*=0;" - "for(int p=-6;p<=6;++p)" - "for(int d=-6;d<=6;++d)" - "if(d*d+p*p<37)" - "gl_FragColor=mix(gl_FragColor,max(gl_FragColor,texelFetch(a,ivec2(gl_FragCoord.xy+vec2(d,p)*texelFetch(a,ivec2(gl_FragCoord.xy),0).w),0)),.06);" + "for(int v=-6;v<=6;++v)" + "for(int x=-6;x<=6;++x)" + "if(x*x+v*v<37)" + "gl_FragColor=mix(gl_FragColor,max(gl_FragColor,texelFetch(a,ivec2(gl_FragCoord.xy+vec2(x,v)*texelFetch(a,ivec2(gl_FragCoord.xy),0).w),0)),.06);" "}" "else if(abs((v.y+=.22)-.5)<.2)" "{" - "vec3 d=vec3(0);" - "for(int p=0;p<8;++p)" + "vec3 p=vec3(0);" + "for(int a=0;a<8;++a)" "{" "float t=2.7;" - "vec3 o=vec3(10+y/4,-4,-1),w=vec3(-7,-2,0);" + "vec3 d=vec3(10+y/4,-4,-1),o=vec3(-7,-2,0);" "m=0;" "if(y>97)" - "w=o=vec3(0,-4,y-97),w.z-=1,l=vec3(0,3,-22),s=.4,c=vec3(3,7,28),z=vec3(-4,0,13);" + "o=d=vec3(0,-4,y-97),o.z-=1,l=vec3(0,3,-22),s=.4,c=vec3(3,7,28),z=vec3(-4,0,13);" "else if(y>81)" - "w=o=vec3(0,-3.6,97-y),w.z-=1,l=vec3(0,5,-5),s=.01,t=1.7,c=vec3(7,5,9),z=vec3(0,0,-2);" + "o=d=vec3(0,-3.6,97-y),o.z-=1,l=vec3(0,5,-5),s=.01,t=1.7,c=vec3(7,5,9),z=vec3(0,0,-2);" "else if(y>60)" - "o=vec3((y-60)/5-1,-2,13),w=vec3(-7,-5,-7),l=vec3(0,5,-3),m=sin(y-60)/10-.9,c=vec3(7,5,9),z=vec3(-4,0,2);" + "d=vec3((y-60)/5-1,-2,13),o=vec3(-7,-5,-7),l=vec3(0,5,-3),m=sin(y-60)/10-.9,c=vec3(7,5,9),z=vec3(-4,0,2);" "else if(y>25)" - "o=vec3(0,0,25-y/2.7),w=vec3(0,-4,18-y/2.7),l=vec3(-2,5,-7),c=vec3(9,5,14),z=vec3(3.5,0,-6);" + "d=vec3(0,0,25-y/2.7),o=vec3(0,-4,18-y/2.7),l=vec3(-2,5,-7),c=vec3(9,5,14),z=vec3(3.5,0,-6);" "else" " m=-.9;" "f=7;" "r=vec3(0,cos(m),sin(m));" - "vec3 u=normalize(w-o),C=normalize(vec3(-u.z,0,u));" + "vec3 w=normalize(o-d),u=normalize(vec3(-w.z,0,w));" "if(y>81&&y<=97)" - "u.y+=n(vec2(y+6)/2,2)*.05,C.y+=n(vec2(y)/3,2)*.08;" - "u=mat3(C,cross(C,u),u)*normalize(vec3(v*2+vec2(p&1,p/2)/1200-1,t));" - "float D=e(o,u);" - "if(D<30)" - "x=o+u*D,g=vec3(.02,0,0),g=normalize(vec3(n(x+g.xyy)-m,n(x+g.yxy)-m,n(x+g.yyx)-m)),f=2,C=h(x,reflect(u,g))*pow(1+dot(u,g),3);" + "w.y+=n(vec2(y+6)/2,2)*.05,u.y+=n(vec2(y)/3,2)*.08;" + "w=mat3(u,cross(u,w),w)*normalize(vec3(v*2+vec2(a&1,a/2)/1200-1,t));" + "float C=e(d,w);" + "if(C<30)" + "x=d+w*C,g=vec3(.02,0,0),g=normalize(vec3(n(x+g.xyy)-m,n(x+g.yxy)-m,n(x+g.yyx)-m)),f=2,u=h(x,reflect(w,g))*pow(1+dot(w,g),3);" "else" "{" - "C=h(o,u);" - "t=(.3+.7*pow(1+dot(u,g),2)/4)*(.1+.9*step(x.y,-c.y+.01));" - "o=reflect(u,g);" - "D=m;" + "u=h(d,w);" + "t=(.3+.7*pow(1+dot(w,g),2)/4)*(.1+.9*step(x.y,-c.y+.01));" + "d=reflect(w,g);" + "C=m;" "f=2;" "i=1e2;" - "u=normalize(l-x);" - "e(x+u*.01,u);" - "C*=.4+.6*smoothstep(0,n(x)/5,i);" + "w=normalize(l-x);" + "e(x+w*.01,w);" + "u*=.4+.6*smoothstep(0,n(x)/5,i);" "if(x.y<-c.y+.01)" - "if(e(x,o)<30)" - "t*=.2,C*=.7;" - "C+=h(x,o)*t*mix(vec3(1),C,.8);" + "if(e(x,d)<30)" + "t*=.2,u*=.7;" + "u+=h(x,d)*t*mix(vec3(1),u,.8);" "}" "if(y>60&&y<=97)" "gl_FragColor.w=y<=81?" - "(D-15)/6:" - "D/15;" - "C=pow(.003+smoothstep(0,2,abs(y-60))*smoothstep(0,3,abs(y-112))*(1-(pow(abs(v.x*2-1),4)+pow(abs(v.y*2-1)*2.5,4))*.4)*C*40,vec3(1,1.1,1.2));" - "d+=C/(C+.4)*1.1;" + "(C-15)/6:" + "C/15;" + "u=pow(.003+smoothstep(0,2,abs(y-60))*smoothstep(0,3,abs(y-112))*(1-(pow(abs(v.x*2-1),4)+pow(abs(v.y*2-1)*2.5,4))*.4)*u*40,vec3(1,1.1,1.2));" + "p+=u/(u+.4)*1.1;" "}" "m=0;" - "for(int p=0;p<64;++p)" - "m+=texture(a,clamp((v-vec2(.4,.532)+vec2(p&7,p/8)/10000)*4*vec2(2.25,4),0,1)).x+texture(a,clamp((v-vec2(.38,.33)+vec2(p&7,p/8)/10000)*vec2(2.25,4),0,1)).y;" - "gl_FragColor.xyz=sqrt(d/8)+m/104*clamp((6-abs(y-10))/5,0,1);" + "for(int x=0;x<64;++x)" + "m+=texture(a,clamp((v-vec2(.4,.532)+vec2(x&7,x/8)/10000)*4*vec2(2.25,4),0,1)).x+texture(a,clamp((v-vec2(.38,.33)+vec2(x&7,x/8)/10000)*vec2(2.25,4),0,1)).y;" + "gl_FragColor.xyz=sqrt(p/8)+m/104*clamp((6-abs(y-10))/5,0,1);" "}" "}"; diff --git a/tests/real/the_real_party_is_in_your_pocket.frag.expected b/tests/real/the_real_party_is_in_your_pocket.frag.expected index 6a92fb64..826bd915 100644 --- a/tests/real/the_real_party_is_in_your_pocket.frag.expected +++ b/tests/real/the_real_party_is_in_your_pocket.frag.expected @@ -117,9 +117,9 @@ const char *the_real_party_is_in_your_pocket_frag = "{" "if(l.y<-.5)" "i=m(i+(1.-smoothstep(-.001,.002,x(l+vec3(0,.03,-.2),true)))*.005,-x(l+vec3(0,0,-.2),false),1024.);" - "vec2 k=vec2(-.32,-.314),p=vec2(.124,.033);" - "float b=length(l.xy-vec2(.405,-.28))-.07,o=length(l.xy-vec2(.202,-.345))-.07,e=v(v(l.xy-k,p)-.005,v(l.xy-k,p.yx)-.005,512.);" - "i=m(m(m(i,min(l.z,-b+.004),320.),min(l.z,-o+.004),320.),min(l.z,-min(1.,e)+.006),192.);" + "vec2 y=vec2(-.32,-.314),z=vec2(.124,.033);" + "float d=length(l.xy-vec2(.405,-.28))-.07,p=length(l.xy-vec2(.202,-.345))-.07,e=v(v(l.xy-y,z)-.005,v(l.xy-y,z.yx)-.005,512.);" + "i=m(m(m(i,min(l.z,-d+.004),320.),min(l.z,-p+.004),320.),min(l.z,-min(1.,e)+.006),192.);" "l.xy-=vec2(.405,-.28);" "float g=(1.-s(.002,min(min(n(l.xy,vec2(0,-.035),vec2(-.014,.024)),n(l.xy,vec2(-.03,-.035),vec2(-.014,.024))),n(l.xy,vec2(-.02),vec2(-.01,-.02)))-.0025))*.002;" "l.xy+=vec2(.405,-.28);" @@ -129,29 +129,29 @@ const char *the_real_party_is_in_your_pocket_frag = "r=min(min(r,abs(length(l.xy-vec2(-.018,-.02025))-.01475)),abs(length(l.xy-vec2(-.018,.00925))-.01475));" "r=(1.-s(.002,r-.0025))*.002;" "l.xy+=vec2(.202,-.345);" - "float h=max(-l.z,m(abs(l.z)-.17,max(-.015,c),96.)),t=min(max(-l.z,m(abs(l.z)-.17+r,o,128.)),max(-l.z,m(abs(l.z)-.17+g,b,128.)));" + "float k=max(-l.z,m(abs(l.z)-.17,max(-.015,c),96.)),b=min(max(-l.z,m(abs(l.z)-.17+r,p,128.)),max(-l.z,m(abs(l.z)-.17+g,d,128.)));" "vec3 w=l;" - "w.z-=pow(length(l.xy-k),2.)/2.-.01;" - "t=m(min(t,max(-l.z,m(abs(w.z)-.18,e,768.))),-length(w-vec3(k,.19))+.026,512.);" - "w.xy-=k;" + "w.z-=pow(length(l.xy-y),2.)/2.-.01;" + "b=m(min(b,max(-l.z,m(abs(w.z)-.18,e,768.))),-length(w-vec3(y,.19))+.026,512.);" + "w.xy-=y;" "w.xy=abs(w.xy);" "if(w.x0.)" - "a=vec2(a.x-C*a.y,-C*a.x-a.y)/2.;" + "a.y=a.y+1./h;" + "if(a.x+h*a.y>0.)" + "a=vec2(a.x-h*a.y,-h*a.x-a.y)/2.;" "a.x-=clamp(a.x,-2.,0.);" - "t=m(t,-max(-w.z,-length(a)*sign(a.y)+.565),512.);" - "if(t0.&&w.xw.y||abs(d)<1e-5)" + "k=s(f+z*r);" + "c=k.x;" + "if(r>w.y||abs(c)<1e-5)" "break;" - "r+=d;" + "r+=c;" "}" "if(r0.&&x.x<0.&&x.y<0.)" "y=vec3(-x*.5,0).zxy,m=w.y;" - "else if(f>0.&&(f0.&&(f0.&&(d0.&&(z5.||abs(a.y)>2.5||abs(a.z)>3.3?" "vec4(-1):" @@ -235,130 +235,130 @@ const char *the_real_party_is_in_your_pocket_frag = "for(int x=0;x<4;++x)" "{" "l=normalize(l);" - "vec3 f;" - "vec4 w=h(v,l,f);" - "float d=w.x;" - "if(d<0.)" + "vec3 z;" + "vec4 f=h(v,l,z);" + "float r=f.x;" + "if(r<0.)" "{" "y+=max(a*vec3(.9)*(.5+.5*dot(l,normalize(vec3(-2,4,1))))*.4*1.3*vec3(1,.9,.65)+a*vec3(.9)*step(.9,dot(l,normalize(vec3(6,2,1))))*10.4*2.3+a*vec3(.9)*step(.95,dot(l,normalize(vec3(-2,1,3))))*10.4*1.5,0.)*pow(max(.5+.5*-l.z,0.),.2);" "break;" "}" - "float r=floor(w.y/8.);" - "w.y=mod(w.y,8.);" - "vec3 z=v+l*d;" - "vec2 c=vec2(6.28319*h(),h()*2.-1.);" - "vec3 k=f+vec3(sqrt(1.-c.y*c.y)*vec2(cos(c.x),sin(c.x)),c.y);" - "float e=w.y>1.5?" - "mix(z.x>0.?" + "float c=floor(f.y/8.);" + "f.y=mod(f.y,8.);" + "vec3 w=v+l*r;" + "vec2 d=vec2(6.28319*h(),h()*2.-1.);" + "vec3 k=z+vec3(sqrt(1.-d.y*d.y)*vec2(cos(d.x),sin(d.x)),d.y);" + "float e=f.y>1.5?" + "mix(w.x>0.?" ".1:" - ".05,.5,pow(1.-clamp(dot(-l,f),0.,1.),2.)):" - "mix(.2,.8,pow(1.-clamp(dot(-l,f),0.,1.),1.5));" - "if(w.y>5.5&&w.y<6.5)" + ".05,.5,pow(1.-clamp(dot(-l,z),0.,1.),2.)):" + "mix(.2,.8,pow(1.-clamp(dot(-l,z),0.,1.),1.5));" + "if(f.y>5.5&&f.y<6.5)" "{" "if(i)" "break;" - "v=z+f*2e-4;" - "a*=mix(.1,.8,pow(1.-clamp(dot(-l,f),0.,1.),3.))*mix(vec3(1),vec3(1,.9,.5),.5);" - "l=reflect(l,f)+(vec3(h(),h(),h())-.5)*.3;" + "v=w+z*2e-4;" + "a*=mix(.1,.8,pow(1.-clamp(dot(-l,z),0.,1.),3.))*mix(vec3(1),vec3(1,.9,.5),.5);" + "l=reflect(l,z)+(vec3(h(),h(),h())-.5)*.3;" "}" - "else if(w.y>4.5&&w.y<5.5)" + "else if(f.y>4.5&&f.y<5.5)" "{" "if(i)" "break;" "e=.02;" "if(h()>e)" - "v=z-f*2e-4*-sign(l.z),l+=(vec3(h(),h(),h())-.5)*.1;" + "v=w-z*2e-4*-sign(l.z),l+=(vec3(h(),h(),h())-.5)*.1;" "else" - " v=z+f*2e-4,l=reflect(l,f)+(vec3(h(),h(),h())-.5)*.3;" + " v=w+z*2e-4,l=reflect(l,z)+(vec3(h(),h(),h())-.5)*.3;" "}" - "else if(w.y<.5||w.y>2.5)" + "else if(f.y<.5||f.y>2.5)" "{" - "vec3 t=w.y>2.5?" + "vec3 r=f.y>2.5?" "vec3(.08):" "vec3(.7);" - "if(w.y>3.5)" + "if(f.y>3.5)" "{" - "t=vec3(.008);" + "r=vec3(.008);" "if(!i)" "{" - "if(z.y>.5)" + "if(w.y>.5)" "{" - "vec2 p=w.zw-vec2(-.38,.6);" - "float b=min(min(min(min(min(min(max(length(p-vec2(.005))-.0125,-length(p-vec2(-.012,.005))+.025),max(length(p-vec2(-.02,.005))-.0125,-length(p-vec2(-.045,.005))+.03)),max(length(p-vec2(.005))-.0125,-length(p-vec2(-.012,.005))+.025)),max(length(p-vec2(.03,.005))-.0125,-length(p-vec2(.02,.005))+.02)),abs(length(p-vec2(-.037,-.0398))-.0104)),n(p,vec2(-.064,-.05),vec2(-.064,-.03))),max(-p.x-.063,abs(length(vec2(max(0.,p.x+.06),p.y+.035))-.006)));" - "p.x-=.091;" - "b=min(min(min(b,n(p,vec2(-.064,-.05),vec2(-.064,-.03))),max(-p.x-.063,abs(length(vec2(max(0.,p.x+.06),p.y+.035))-.006))),n(p,vec2(-.054,-.05),vec2(-.059,-.041)));" - "p.x+=.091;" - "b=min(min(min(min(b,n(p,vec2(.009,-.05),vec2(.009,-.03))),n(p,vec2(.009,-.05),vec2(.018,-.05))),n(p,vec2(.009,-.03),vec2(.018,-.03))),n(p,vec2(.009,-.039),vec2(.018,-.039)));" - "p.x=abs(p.x+.01);" - "p.x=abs(p.x-.006);" - "b=min(b,n(p,vec2(0,-.05),vec2(.006,-.03)));" - "t=mix(t,vec3(.3),step(b-.0018,0.));" + "vec2 l=f.zw-vec2(-.38,.6);" + "float m=min(min(min(min(min(min(max(length(l-vec2(.005))-.0125,-length(l-vec2(-.012,.005))+.025),max(length(l-vec2(-.02,.005))-.0125,-length(l-vec2(-.045,.005))+.03)),max(length(l-vec2(.005))-.0125,-length(l-vec2(-.012,.005))+.025)),max(length(l-vec2(.03,.005))-.0125,-length(l-vec2(.02,.005))+.02)),abs(length(l-vec2(-.037,-.0398))-.0104)),n(l,vec2(-.064,-.05),vec2(-.064,-.03))),max(-l.x-.063,abs(length(vec2(max(0.,l.x+.06),l.y+.035))-.006)));" + "l.x-=.091;" + "m=min(min(min(m,n(l,vec2(-.064,-.05),vec2(-.064,-.03))),max(-l.x-.063,abs(length(vec2(max(0.,l.x+.06),l.y+.035))-.006))),n(l,vec2(-.054,-.05),vec2(-.059,-.041)));" + "l.x+=.091;" + "m=min(min(min(min(m,n(l,vec2(.009,-.05),vec2(.009,-.03))),n(l,vec2(.009,-.05),vec2(.018,-.05))),n(l,vec2(.009,-.03),vec2(.018,-.03))),n(l,vec2(.009,-.039),vec2(.018,-.039)));" + "l.x=abs(l.x+.01);" + "l.x=abs(l.x-.006);" + "m=min(m,n(l,vec2(0,-.05),vec2(.006,-.03)));" + "r=mix(r,vec3(.3),step(m-.0018,0.));" "}" - "if(length(w.zw-vec2(-.43,.605))<.014)" - "y+=a*3.*vec3(1,.01,.01)*(.8+8.*(1.-s(.01,length(w.zw-vec2(-.43,.605)))));" - "if(w.w>0.&&z.y<.2)" + "if(length(f.zw-vec2(-.43,.605))<.014)" + "y+=a*3.*vec3(1,.01,.01)*(.8+8.*(1.-s(.01,length(f.zw-vec2(-.43,.605)))));" + "if(f.w>0.&&w.y<.2)" "{" - "t=mix(t,vec3(.3),step(n(w.zw-vec2(0,.103)),0.));" + "r=mix(r,vec3(.3),step(n(f.zw-vec2(0,.103)),0.));" "{" - "vec2 p=vec2(-.09,.03),b=vec2(-.1,0);" - "t=mix(t,vec3(.520661,.00153787,.064975),step(min(m(w.zw-vec2(.16,.103),b,b+normalize(b-p)*.03,vec2(-.065,-.026)),m(w.zw-vec2(.16,.103),vec2(-.07,.02),p,b))-.007,0.));" + "vec2 v=vec2(-.09,.03),l=vec2(-.1,0);" + "r=mix(r,vec3(.520661,.00153787,.064975),step(min(m(f.zw-vec2(.16,.103),l,l+normalize(l-v)*.03,vec2(-.065,-.026)),m(f.zw-vec2(.16,.103),vec2(-.07,.02),v,l))-.007,0.));" "}" "{" - "vec2 p=w.zw-vec2(.16,.103)-vec2(-.029,-.015);" - "p.x+=cos(p.y*30.)*.01;" - "p.y-=cos(p.x*20.)*.01;" - "t=mix(t,vec3(.093564,.0865052,.434048),step(abs(length(p)-.02)-.007,0.));" + "vec2 l=f.zw-vec2(.16,.103)-vec2(-.029,-.015);" + "l.x+=cos(l.y*30.)*.01;" + "l.y-=cos(l.x*20.)*.01;" + "r=mix(r,vec3(.093564,.0865052,.434048),step(abs(length(l)-.02)-.007,0.));" "}" "{" - "vec2 p=w.zw-vec2(.16,.103),b=vec2(-.007,0),o=vec2(-.007,-.0205);" - "t=mix(t,vec3(.186082,.481799,.0177778),step(min(m(p,o,o+normalize(o-b)*.01,vec2(.02,-.02)),m(p,vec2(-.01,.02),b,o))-.007,0.));" + "vec2 l=f.zw-vec2(.16,.103),v=vec2(-.007,0),y=vec2(-.007,-.0205);" + "r=mix(r,vec3(.186082,.481799,.0177778),step(min(m(l,y,y+normalize(y-v)*.01,vec2(.02,-.02)),m(l,vec2(-.01,.02),v,y))-.007,0.));" "}" "{" - "vec2 p=w.zw-vec2(.16,.103)-vec2(.045,-.015);" - "p.x+=cos(p.y*20.+1.)*.005;" - "p.y-=cos(p.x*20.+25.)*.01;" - "t=mix(t,vec3(.730857,.454964,.000553633),step(abs(length(p)-.02)-.007,0.));" + "vec2 l=f.zw-vec2(.16,.103)-vec2(.045,-.015);" + "l.x+=cos(l.y*20.+1.)*.005;" + "l.y-=cos(l.x*20.+25.)*.01;" + "r=mix(r,vec3(.730857,.454964,.000553633),step(abs(length(l)-.02)-.007,0.));" "}" "{" - "vec2 p=w.zw-vec2(.24,.103),b=vec2(-.002,0),o=vec2(-.007,.016),C=o+normalize(o-b)*.012,g=vec2(.02),D=vec2(.002,-.007),B=vec2(.025,-.028);" - "t=mix(t,vec3(0,.332318,.292872),step(min(min(min(m(p,o,C,g),m(p,vec2(-.006,-.026),b,o)),m(p,g,C+normalize(g-C)*.05,D)),m(p,D,(D+B)/2.+vec2(.001),B))-.007,0.));" + "vec2 l=f.zw-vec2(.24,.103),v=vec2(-.002,0),y=vec2(-.007,.016),x=y+normalize(y-v)*.012,a=vec2(.02),z=vec2(.002,-.007),i=vec2(.025,-.028);" + "r=mix(r,vec3(0,.332318,.292872),step(min(min(min(m(l,y,x,a),m(l,vec2(-.006,-.026),v,y)),m(l,a,x+normalize(a-x)*.05,z)),m(l,z,(z+i)/2.+vec2(.001),i))-.007,0.));" "}" "}" "{" - "vec2 p=vec2(160,144)/1.5,b=(w.zw-vec2(-.001,.486))*3.75*vec2(p.y/p.x,1)*.5+.5,o=fract(b*p);" - "b=floor(b*p)/p;" - "if(max(abs(b.x-.5),abs(b.y-.5))<.5)" + "vec2 l=vec2(160,144)/1.5,v=(f.zw-vec2(-.001,.486))*3.75*vec2(l.y/l.x,1)*.5+.5,x=fract(v*l);" + "v=floor(v*l)/l;" + "if(max(abs(v.x-.5),abs(v.y-.5))<.5)" "{" - "vec3 C=vec3(0);" - "vec2 g=(b*2.-1.)*vec2(p.x/p.y,1);" - "float D=floor(b.y*8.);" - "C=mix(.5+.5*cos(vec3(.8,.3,2)*(D+1.)),vec3(1),step(min(min(min(min(min(min(min(min(min(min(min(min(min(min(min(min(min(n(vec4(1.54,.53,.91,.72),g),n(vec4(.63,.78,.91,.72),g)),n(vec4(.61,1.675,.72,.64),g)),n(vec4(2.7,3.11,.72,.64),g)),n(vec4(3.45,3.65,.72,.64),g)),n(vec4(4.71,5.02,.72,.64),g)),n(vec4(5.3,5.51,.72,.64),g)),n(vec4(5.96,6.43,.72,.64),g)),n(vec4(3.2,1.27,.45,.35),g)),n(vec4(1.3,2.3,.45,.35),g)),n(vec4(2.58,4.2,.45,.35),g)),n(vec4(3.2,3.95,.35,.25),g)),n(vec4(5.2,5.93,.35,.25),g)),n(vec4(7.9,8.15,.35,.25),g)),n(vec4(.2,1.16,.32,.17),g)),max(length(g)-.84,-length(g)+.72)),max(length(g)-.52,-length(g)+.45)),max(length(g)-.17,-length(g)+.08)),0.))*vec3(1,1,.8)*(smoothstep(.1,.2,o.x)*smoothstep(.1,.2,o.y));" - "y+=a*3.*C;" - "t=vec3(.1);" + "vec3 i=vec3(0);" + "vec2 m=(v*2.-1.)*vec2(l.x/l.y,1);" + "float f=floor(v.y*8.);" + "i=mix(.5+.5*cos(vec3(.8,.3,2)*(f+1.)),vec3(1),step(min(min(min(min(min(min(min(min(min(min(min(min(min(min(min(min(min(n(vec4(1.54,.53,.91,.72),m),n(vec4(.63,.78,.91,.72),m)),n(vec4(.61,1.675,.72,.64),m)),n(vec4(2.7,3.11,.72,.64),m)),n(vec4(3.45,3.65,.72,.64),m)),n(vec4(4.71,5.02,.72,.64),m)),n(vec4(5.3,5.51,.72,.64),m)),n(vec4(5.96,6.43,.72,.64),m)),n(vec4(3.2,1.27,.45,.35),m)),n(vec4(1.3,2.3,.45,.35),m)),n(vec4(2.58,4.2,.45,.35),m)),n(vec4(3.2,3.95,.35,.25),m)),n(vec4(5.2,5.93,.35,.25),m)),n(vec4(7.9,8.15,.35,.25),m)),n(vec4(.2,1.16,.32,.17),m)),max(length(m)-.84,-length(m)+.72)),max(length(m)-.52,-length(m)+.45)),max(length(m)-.17,-length(m)+.08)),0.))*vec3(1,1,.8)*(smoothstep(.1,.2,x.x)*smoothstep(.1,.2,x.y));" + "y+=a*3.*i;" + "r=vec3(.1);" "}" "}" "}" "}" - "if(w.y>3.&&w.y<3.2)" - "t=vec3(.4);" - "a*=t;" - "v=z+f*2e-4;" + "if(f.y>3.&&f.y<3.2)" + "r=vec3(.4);" + "a*=r;" + "v=w+z*2e-4;" "l=k;" "i=true;" "}" "else" "{" - "vec3 p=r>1.5?" + "vec3 m=c>1.5?" "vec3(1,.02,.2):" - "r>.5?" + "c>.5?" "vec3(.2,1,.02):" "vec3(.02,.2,1);" "if(h()>mix(.2,1.,e))" "{" - "if(w.y>1.5)" - "p=vec3(.02);" - "a*=p;" - "v=z+f*2e-4;" + "if(f.y>1.5)" + "m=vec3(.02);" + "a*=m;" + "v=w+z*2e-4;" "l=k;" "i=true;" "}" @@ -366,11 +366,11 @@ const char *the_real_party_is_in_your_pocket_frag = "{" "if(i)" "break;" - "a*=w.y>1.5?" + "a*=f.y>1.5?" "vec3(.5):" - ".9*mix(p,vec3(1),.25);" - "v=z+f*2e-4;" - "l=reflect(l,f)+(vec3(h(),h(),h())-.5)*.4;" + ".9*mix(m,vec3(1),.25);" + "v=w+z*2e-4;" + "l=reflect(l,z)+(vec3(h(),h(),h())-.5)*.4;" "}" "}" "if(max(a.x,max(a.y,a.z))<.001)" diff --git a/tests/real/to_the_road_of_ribbon.expected b/tests/real/to_the_road_of_ribbon.expected index d753f410..8a093175 100644 --- a/tests/real/to_the_road_of_ribbon.expected +++ b/tests/real/to_the_road_of_ribbon.expected @@ -29,18 +29,18 @@ const char *to_the_road_of_ribbon_frag = "vec4 v=vec4(1);" "vec3 m=vec3(sin(time)*.5,cos(time*.5)*.25+.25,time),o=normalize(vec3(t.x*1.6,t.y,1)),c=m,f;" "float e=0.;" - "for(int r=0;r<64;r++)" + "for(int t=0;t<64;t++)" "e=o(c),c+=e*o;" "f=c;" - "float r=length(c-m)*.02;" + "float g=length(c-m)*.02;" "o=reflect(o,gn(c));" "c+=o;" - "for(int g=0;g<64;g++)" + "for(int t=0;t<64;t++)" "e=o(c),c+=e*o;" "v=max(dot(gn(c),vec3(.1,.1,0)),0.)+vec4(.3,cos(time*.5)*.5+.5,sin(time*.5)*.5+.5,1)*min(length(c-m)*.04,1.);" "if(oa(f)>ob(f))" "v=mix(v,vec4(cos(time*.3)*.5+.5,cos(time*.2)*.5+.5,sin(time*.3)*.5+.5,1),.3);" - "v=(v+vec4(r)+(1.-min(f.y+1.9,1.))*vec4(1,.8,.7,1))*min(time*.5,1.);" + "v=(v+vec4(g)+(1.-min(f.y+1.9,1.))*vec4(1,.8,.7,1))*min(time*.5,1.);" "gl_FragColor=vec4(v.xyz,1);" "}"; diff --git a/tests/real/yx_long_way_from_home.frag.expected b/tests/real/yx_long_way_from_home.frag.expected index be75b325..5a40229b 100644 --- a/tests/real/yx_long_way_from_home.frag.expected +++ b/tests/real/yx_long_way_from_home.frag.expected @@ -50,10 +50,10 @@ const char *yx_long_way_from_home_frag = "i.z+=sin(i.x*.5)*.5;" "i.z+=step(.5,mod(i.x,1.))*.3-.15;" "i.x=mod(i.x,.5)-.25;" - "float y=e(i.xz),z=smoothstep(.1,.13,y);" - "i.y+=.1-z*.03;" - "i.y-=smoothstep(.05,0.,abs(y-.16))*.004;" - "i.y-=(1.-z)*.01*p(i.xz);" + "float x=e(i.xz),y=smoothstep(.1,.13,x);" + "i.y+=.1-y*.03;" + "i.y-=smoothstep(.05,0.,abs(x-.16))*.004;" + "i.y-=(1.-y)*.01*p(i.xz);" "}" "i.y-=smoothstep(2.,0.,length(c.xz+vec2(-1.5,3.5)))*.2;" "i.y-=smoothstep(2.,0.,length(c.xz+vec2(1,-2)))*.2;" @@ -86,7 +86,7 @@ const char *yx_long_way_from_home_frag = "bool c(vec3 v,vec3 x,out vec3 y,out vec3 i,out float s)" "{" "float f=0.;" - "for(int c=0;c<100;++c)" + "for(int i=0;i<100;++i)" "{" "s=t(v+x*f);" "f+=s;" @@ -96,9 +96,9 @@ const char *yx_long_way_from_home_frag = "y=v+x*f;" "if(abs(s)<.004)" "{" - "vec2 c=vec2(.001,0);" + "vec2 v=vec2(.001,0);" "s=t(y);" - "i=normalize(vec3(t(y+c.xyy)-s,t(y+c.yxy)-s,t(y+c.yyx)-s));" + "i=normalize(vec3(t(y+v.xyy)-s,t(y+v.yxy)-s,t(y+v.yyx)-s));" "return true;" "}" "return false;" @@ -117,35 +117,35 @@ const char *yx_long_way_from_home_frag = "vec3 c(vec3 v,vec3 x)" "{" "vec3 y=normalize(vec3(.3,.36,-1));" - "const vec3 z=vec3(1,.6,.2)*2.;" - "vec3 n=vec3(1),l=vec3(0);" + "const vec3 p=vec3(1,.6,.2)*2.;" + "vec3 n=vec3(1),z=vec3(0);" "for(int r=0;r<10;++r)" "{" - "vec3 t,a;" - "float e;" - "if(c(v,x,t,a,e))" + "vec3 t,l;" + "float a;" + "if(c(v,x,t,l,a))" "{" - "float g=1.;" - "vec3 p=vec3(1);" + "float r=1.;" + "vec3 a=vec3(1);" "if(f==1)" - "p=vec3(.7);" - "g*=g;" + "a=vec3(.7);" + "r*=r;" "{" - "v=t+a*.002;" - "vec3 B=reflect(x,a),o=m(a);" - "x=normalize(mix(B,o,g));" - "n*=p;" + "v=t+l*.002;" + "vec3 g=reflect(x,l),o=m(l);" + "x=normalize(mix(g,o,r));" + "n*=a;" "}" "vec3 o=h(y);" - "float B=dot(a,o);" - "vec3 S,k;" - "float b;" - "if(B>0.&&!c(t+a*.002,o,S,k,b))" - "l+=n*B*z;" + "float g=dot(l,o);" + "vec3 B,e;" + "float k;" + "if(g>0.&&!c(t+l*.002,o,B,e,k))" + "z+=n*g*p;" "i=s(i.y);" "}" - "else if(abs(e)>.1)" - "return l+vec3(1,2,3)*.2*n;" + "else if(abs(a)>.1)" + "return z+vec3(1,2,3)*.2*n;" "else" " break;" "}" @@ -174,15 +174,15 @@ const char *yx_long_way_from_home_frag = "o.xy-=v*f*o.z/distance(y,z);" "vec3 a=z-y;" "x=-atan(a.y,length(a.xz));" - "float e=-atan(a.x,a.z);" + "float g=-atan(a.x,a.z);" "r.yz*=n(x);" "o.yz*=n(x);" - "r.xz*=n(e);" - "o.xz*=n(e);" + "r.xz*=n(g);" + "o.xz*=n(g);" "r+=y;" - "vec4 B=vec4(c(r,o),1);" - "gl_FragColor=!isnan(B.x)&&B.x>=0.?" - "B:" + "vec4 t=vec4(c(r,o),1);" + "gl_FragColor=!isnan(t.x)&&t.x>=0.?" + "t:" "vec4(0);" "}";