port from perforce
This commit is contained in:
43
hgplus/ShaderMinifier/tests/real/chocolux.frag
Normal file
43
hgplus/ShaderMinifier/tests/real/chocolux.frag
Normal file
@@ -0,0 +1,43 @@
|
||||
uniform vec2 resolution;
|
||||
uniform float time;
|
||||
|
||||
float h(vec3 q)
|
||||
{
|
||||
float f=1.*distance(q,vec3(cos(time)+sin(time*.2),.3,2.+cos(time*.5)*.5));
|
||||
f*=distance(q,vec3(-cos(time*.7),.3,2.+sin(time*.5)));
|
||||
f*=distance(q,vec3(-sin(time*.2)*.5,sin(time),2.));
|
||||
f*=cos(q.y)*cos(q.x)-.1-cos(q.z*7.+time*7.)*cos(q.x*3.)*cos(q.y*4.)*.1;
|
||||
return f;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
|
||||
vec3 o=vec3(p.x,p.y*1.25-0.3,0.);
|
||||
vec3 d=vec3(p.x+cos(time)*0.3,p.y,1.)/64.;
|
||||
vec4 c=vec4(0.);
|
||||
float t=0.;
|
||||
for(int i=0;i<75;i++)
|
||||
{
|
||||
if(h(o+d*t)<.4)
|
||||
{
|
||||
t-=5.;
|
||||
for(int j=0;j<5;j++)
|
||||
{
|
||||
if(h(o+d*t)<.4)
|
||||
break;
|
||||
t+=1.;
|
||||
}
|
||||
vec3 e=vec3(.01,.0,.0);
|
||||
vec3 n=vec3(.0);
|
||||
n.x=h(o+d*t)-h(vec3(o+d*t+e.xyy));
|
||||
n.y=h(o+d*t)-h(vec3(o+d*t+e.yxy));
|
||||
n.z=h(o+d*t)-h(vec3(o+d*t+e.yyx));
|
||||
n=normalize(n);
|
||||
c+=max(dot(vec3(.0,.0,-.5),n),.0)+max(dot(vec3(.0,-.5,.5),n),.0)*.5;
|
||||
break;
|
||||
}
|
||||
t+=5.;
|
||||
}
|
||||
gl_FragColor=c+vec4(.1,.2,.5,1.)*(t*.025);
|
||||
}
|
||||
45
hgplus/ShaderMinifier/tests/real/clod.frag
Normal file
45
hgplus/ShaderMinifier/tests/real/clod.frag
Normal file
@@ -0,0 +1,45 @@
|
||||
uniform vec2 resolution;
|
||||
uniform float time;
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform sampler2D tex2;
|
||||
uniform sampler2D tex3;
|
||||
|
||||
float f(vec3 o)
|
||||
{
|
||||
float a=(sin(o.x)+o.y*.25)*.35;
|
||||
o=vec3(cos(a)*o.x-sin(a)*o.y,sin(a)*o.x+cos(a)*o.y,o.z);
|
||||
return dot(cos(o)*cos(o),vec3(1))-1.2;
|
||||
}
|
||||
vec3 s(vec3 o,vec3 d)
|
||||
{
|
||||
float t=0.,a,b;
|
||||
for(int i=0;i<75;i++)
|
||||
{
|
||||
if(f(o+d*t)<0.0)
|
||||
{
|
||||
a=t-.125;b=t;
|
||||
for(int i=0; i<10;i++)
|
||||
{
|
||||
t=(a+b)*.5;
|
||||
if(f(o+d*t)<0.0)
|
||||
b=t;
|
||||
else
|
||||
a=t;
|
||||
}
|
||||
vec3 e=vec3(.1,0.0,0.0);
|
||||
vec3 p=o+d*t;
|
||||
vec3 n=-normalize(vec3(f(p+e),f(p+e.yxy),f(p+e.yyx))+vec3((sin(p*75.)))*.01);
|
||||
|
||||
return vec3( mix( ((max(-dot(n,vec3(.577)),0.) + 0.125*max(-dot(n,vec3(-.707,-.707,0)),0.)))*(mod(length(p.xy)*20.,2.)<1.0?vec3(.71,.85,.25):vec3(.79,.93,.4))
|
||||
,vec3(.93,.94,.85), vec3(pow(t/9.,5.)) ) );
|
||||
}
|
||||
t+=.125;
|
||||
}
|
||||
return vec3(.93,.94,.85);
|
||||
}
|
||||
void main()
|
||||
{
|
||||
vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
|
||||
gl_FragColor=vec4(s(vec3(sin(time*1.5)*.5,cos(time)*.5,time), normalize(vec3(p.xy,1.0))),1.0);
|
||||
}
|
||||
27
hgplus/ShaderMinifier/tests/real/deform.frag
Normal file
27
hgplus/ShaderMinifier/tests/real/deform.frag
Normal file
@@ -0,0 +1,27 @@
|
||||
uniform float time;
|
||||
uniform vec2 resolution;
|
||||
uniform vec4 mouse;
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform sampler2D tex2;
|
||||
uniform sampler2D tex3;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
|
||||
vec2 m = -1.0 + 2.0 * mouse.xy / resolution.xy;
|
||||
|
||||
float a1 = atan(p.y-m.y,p.x-m.x);
|
||||
float r1 = sqrt(dot(p-m,p-m));
|
||||
float a2 = atan(p.y+m.y,p.x+m.x);
|
||||
float r2 = sqrt(dot(p+m,p+m));
|
||||
|
||||
vec2 uv;
|
||||
uv.x = 0.2*time + (r1-r2)*0.25;
|
||||
uv.y = sin(2.0*(a1-a2));
|
||||
|
||||
float w = r1*r2*0.8;
|
||||
vec3 col = texture2D(tex0,uv).xyz;
|
||||
|
||||
gl_FragColor = vec4(col/(.1+w),1.0);
|
||||
}
|
||||
48
hgplus/ShaderMinifier/tests/real/disco.frag
Normal file
48
hgplus/ShaderMinifier/tests/real/disco.frag
Normal file
@@ -0,0 +1,48 @@
|
||||
uniform vec2 resolution;
|
||||
uniform float time;
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform sampler2D tex2;
|
||||
uniform sampler2D tex3;
|
||||
|
||||
vec4 s(vec2 px,float z)
|
||||
{
|
||||
float l=3.1415;
|
||||
float k=time*sign(z);
|
||||
float x = px.x*320.0*.0065*z;
|
||||
float y = px.y*240.0*.0060*z;
|
||||
float c=sqrt(x*x+y*y);
|
||||
if(c>1.0)
|
||||
{
|
||||
return vec4(0.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
float u=-.4*sign(z)+sin(k*.05);
|
||||
float v=sqrt(1.0-x*x-y*y);
|
||||
float q=y*sin(u)-v*cos(u);
|
||||
y=y*cos(u)+v*sin(u);
|
||||
v=acos(y);
|
||||
u=acos(x/sin(v))/(2.0*l)*120.0*sign(q)-k;
|
||||
v=v*60.0/l;
|
||||
q=cos(floor(v/l));
|
||||
c=pow(abs(cos(u)*sin(v)),.2)*.1/(q+sin(float(int((u+l/2.0)/l))+k*.6+cos(q*25.0)))*pow(1.0-c,.9);
|
||||
|
||||
vec4 res;
|
||||
if(c<0.0)
|
||||
res = vec4(-c/2.0*abs(cos(k*.1)),0.0,-c*2.0*abs(sin(k*.04)),1.0);
|
||||
else
|
||||
res = vec4(c,c*2.0,c*2.0,1.0);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
|
||||
vec4 c = vec4(0.0);
|
||||
for(int i=80;i>0;i--)
|
||||
c+=s(p,1.0-float(i)/80.0)*(.008-float(i)*.00005);
|
||||
vec4 d=s(p,1.0);
|
||||
gl_FragColor = (d.a==0.0?s(p,-.2)*.02:d)+sqrt(c);
|
||||
}
|
||||
7
hgplus/ShaderMinifier/tests/real/extatique/blit.fs
Normal file
7
hgplus/ShaderMinifier/tests/real/extatique/blit.fs
Normal file
@@ -0,0 +1,7 @@
|
||||
uniform sampler2D tex;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 p = gl_TexCoord[0].xy;
|
||||
gl_FragColor = gl_Color * texture2D(tex, p);
|
||||
}
|
||||
6
hgplus/ShaderMinifier/tests/real/extatique/blit.vs
Normal file
6
hgplus/ShaderMinifier/tests/real/extatique/blit.vs
Normal file
@@ -0,0 +1,6 @@
|
||||
void main()
|
||||
{
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_FrontColor = gl_Color;
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
12
hgplus/ShaderMinifier/tests/real/extatique/blit2.fs
Normal file
12
hgplus/ShaderMinifier/tests/real/extatique/blit2.fs
Normal file
@@ -0,0 +1,12 @@
|
||||
uniform sampler2D tex1;
|
||||
uniform sampler2D tex2;
|
||||
|
||||
uniform float tex1Amount;
|
||||
uniform float tex2Amount;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 p = gl_TexCoord[0].xy;
|
||||
|
||||
gl_FragColor = vec4(tex1Amount) * texture2D(tex1, p) + vec4(tex2Amount) * texture2D(tex2, p);
|
||||
}
|
||||
5
hgplus/ShaderMinifier/tests/real/extatique/blit2.vs
Normal file
5
hgplus/ShaderMinifier/tests/real/extatique/blit2.vs
Normal file
@@ -0,0 +1,5 @@
|
||||
void main()
|
||||
{
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
13
hgplus/ShaderMinifier/tests/real/extatique/blitcorner.fs
Normal file
13
hgplus/ShaderMinifier/tests/real/extatique/blitcorner.fs
Normal file
@@ -0,0 +1,13 @@
|
||||
uniform sampler2D tex;
|
||||
uniform float ratio;
|
||||
uniform float factor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 p = gl_TexCoord[0].xy;
|
||||
|
||||
vec2 dist = (p - vec2(0.5, 0.5)) * vec2(1.0,ratio);
|
||||
vec4 darkF = vec4(max(0.0, 1.0 - factor * dot(dist,dist)));
|
||||
|
||||
gl_FragColor = gl_Color * darkF * texture2D(tex, p);
|
||||
}
|
||||
6
hgplus/ShaderMinifier/tests/real/extatique/blitcorner.vs
Normal file
6
hgplus/ShaderMinifier/tests/real/extatique/blitcorner.vs
Normal file
@@ -0,0 +1,6 @@
|
||||
void main()
|
||||
{
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_FrontColor = gl_Color;
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
26
hgplus/ShaderMinifier/tests/real/extatique/blitgirl.fs
Normal file
26
hgplus/ShaderMinifier/tests/real/extatique/blitgirl.fs
Normal file
@@ -0,0 +1,26 @@
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D noise;
|
||||
uniform vec2 size;
|
||||
uniform float border;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 p = gl_TexCoord[0].xy;
|
||||
|
||||
vec2 realP = p * size;
|
||||
|
||||
float alphaX = smoothstep(0.0, border, realP.x) - smoothstep(size.x - border, size.x, realP.x);
|
||||
float alphaY = smoothstep(0.0, border, realP.y) - smoothstep(size.y - border, size.y, realP.y);
|
||||
|
||||
float border2 = border * 3.0;
|
||||
float alphaX2 = smoothstep(0.0, border2, realP.x) - smoothstep(size.x - border2, size.x, realP.x);
|
||||
float alphaY2 = smoothstep(0.0, border2, realP.y) - smoothstep(size.y - border2, size.y, realP.y);
|
||||
|
||||
|
||||
float noise = texture2D(noise, realP).r;
|
||||
|
||||
float alpha = max(0.0, alphaX * alphaY - (noise * (1.0 - alphaX2 * alphaY2)));
|
||||
|
||||
gl_FragColor = vec4(gl_Color.rgb, alpha) * texture2D(tex, p);
|
||||
}
|
||||
6
hgplus/ShaderMinifier/tests/real/extatique/blitgirl.vs
Normal file
6
hgplus/ShaderMinifier/tests/real/extatique/blitgirl.vs
Normal file
@@ -0,0 +1,6 @@
|
||||
void main()
|
||||
{
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_FrontColor = gl_Color;
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
18
hgplus/ShaderMinifier/tests/real/extatique/blitsquare.fs
Normal file
18
hgplus/ShaderMinifier/tests/real/extatique/blitsquare.fs
Normal file
@@ -0,0 +1,18 @@
|
||||
uniform sampler2D tex;
|
||||
uniform vec2 size;
|
||||
uniform float border;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 p = gl_TexCoord[0].xy;
|
||||
|
||||
vec2 realP = p * size;
|
||||
|
||||
float alphaX = smoothstep(0.0, border, realP.x) - smoothstep(size.x - border, size.x, realP.x);
|
||||
float alphaY = smoothstep(0.0, border, realP.y) - smoothstep(size.y - border, size.y, realP.y);
|
||||
|
||||
float alpha = alphaX * alphaY;
|
||||
|
||||
gl_FragColor = vec4(gl_Color.rgb, alpha) * texture2D(tex, p);
|
||||
}
|
||||
6
hgplus/ShaderMinifier/tests/real/extatique/blitsquare.vs
Normal file
6
hgplus/ShaderMinifier/tests/real/extatique/blitsquare.vs
Normal file
@@ -0,0 +1,6 @@
|
||||
void main()
|
||||
{
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_FrontColor = gl_Color;
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
23
hgplus/ShaderMinifier/tests/real/extatique/distort.fs
Normal file
23
hgplus/ShaderMinifier/tests/real/extatique/distort.fs
Normal file
@@ -0,0 +1,23 @@
|
||||
uniform sampler2D tex;
|
||||
uniform float amount;
|
||||
uniform float colorSep;
|
||||
uniform vec4 glow;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 p = (gl_TexCoord[0].xy - vec2(0.5,0.5));
|
||||
vec2 p2 = p + vec2(colorSep, 0.0);
|
||||
vec2 p3 = p - vec2(colorSep, 0.0);
|
||||
|
||||
float distortion = amount / (1.0 + length(p * 5.0));
|
||||
|
||||
float cosd = cos(distortion);
|
||||
float sind = sin(distortion);
|
||||
|
||||
mat2 tranfo = mat2(cosd, -sind, sind, cosd);
|
||||
|
||||
vec4 color1 = vec4(1.0,0.5,0.0,0.5) * texture2D(tex, (vec2(0.5) + tranfo * p2));
|
||||
vec4 color2 = vec4(0.0,0.5,1.0,0.5) * texture2D(tex, (vec2(0.5) + tranfo * p3));
|
||||
gl_FragColor = gl_Color * (color1 + color2) + glow;
|
||||
}
|
||||
6
hgplus/ShaderMinifier/tests/real/extatique/distort.vs
Normal file
6
hgplus/ShaderMinifier/tests/real/extatique/distort.vs
Normal file
@@ -0,0 +1,6 @@
|
||||
void main()
|
||||
{
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_FrontColor = gl_Color;
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
33
hgplus/ShaderMinifier/tests/real/extatique/final.fs
Normal file
33
hgplus/ShaderMinifier/tests/real/extatique/final.fs
Normal file
@@ -0,0 +1,33 @@
|
||||
uniform sampler2D tex;
|
||||
uniform sampler3D gammaRamp;
|
||||
|
||||
uniform float blurType;
|
||||
uniform float blurAmount;
|
||||
uniform float invHeight;
|
||||
uniform float invWidth;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 p = gl_TexCoord[0].xy;
|
||||
|
||||
vec4 blur = ( texture2DLod(tex, p, 7.0)
|
||||
+ texture2DLod(tex, p, 6.0)
|
||||
+ texture2DLod(tex, p, 5.0)
|
||||
+ texture2DLod(tex, p, 4.0)
|
||||
+ texture2DLod(tex, p, 3.0)
|
||||
+ texture2DLod(tex, p, 2.0)
|
||||
+ texture2DLod(tex, p, 1.0)) * vec4(0.142857); /* 1/7 */
|
||||
|
||||
vec4 center = texture2D(tex, p);
|
||||
|
||||
|
||||
vec4 blurred = (vec4(1.0) - (vec4(1.0) - blur) * (vec4(1.0) - center));
|
||||
vec4 blurred2 = blurred * mix( blurred, vec4(1.0), blurType);
|
||||
|
||||
vec4 uncorrected = mix(center, blurred2, blurAmount);
|
||||
|
||||
/* gamma correction */
|
||||
|
||||
gl_FragColor = texture3D(gammaRamp, uncorrected.xyz);
|
||||
}
|
||||
5
hgplus/ShaderMinifier/tests/real/extatique/final.vs
Normal file
5
hgplus/ShaderMinifier/tests/real/extatique/final.vs
Normal file
@@ -0,0 +1,5 @@
|
||||
void main()
|
||||
{
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_Position = gl_Vertex;
|
||||
}
|
||||
11
hgplus/ShaderMinifier/tests/real/extatique/font.fs
Normal file
11
hgplus/ShaderMinifier/tests/real/extatique/font.fs
Normal file
@@ -0,0 +1,11 @@
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D fill;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 p = gl_TexCoord[0].xy;
|
||||
vec4 letter = texture2D(tex, p);
|
||||
vec4 fillColor = texture2D(fill, p * 3.0);
|
||||
|
||||
gl_FragColor = letter * fillColor * gl_Color;
|
||||
}
|
||||
7
hgplus/ShaderMinifier/tests/real/extatique/font.vs
Normal file
7
hgplus/ShaderMinifier/tests/real/extatique/font.vs
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_Position = ftransform();
|
||||
gl_FrontColor = gl_Color;
|
||||
}
|
||||
9
hgplus/ShaderMinifier/tests/real/extatique/glow.fs
Normal file
9
hgplus/ShaderMinifier/tests/real/extatique/glow.fs
Normal file
@@ -0,0 +1,9 @@
|
||||
uniform sampler1D tex;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 p = gl_TexCoord[0].xy;
|
||||
float a = length(p) / 2.04;
|
||||
gl_FragColor = gl_Color * vec4(1.0,1.0,1.0, texture1D(tex, a));
|
||||
}
|
||||
8
hgplus/ShaderMinifier/tests/real/extatique/glow.vs
Normal file
8
hgplus/ShaderMinifier/tests/real/extatique/glow.vs
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FrontColor = gl_Color;
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
110
hgplus/ShaderMinifier/tests/real/extatique/graindo12.fs
Normal file
110
hgplus/ShaderMinifier/tests/real/extatique/graindo12.fs
Normal file
@@ -0,0 +1,110 @@
|
||||
uniform float time;
|
||||
uniform float param1;
|
||||
|
||||
|
||||
uniform sampler1D distRamp;
|
||||
uniform vec3 matColor;
|
||||
uniform vec3 ambientColor;
|
||||
|
||||
|
||||
|
||||
float gausa( float a )
|
||||
{
|
||||
return texture1D(distRamp, abs(a) * 0.125 ).r; /* pow(0.5f, abs(a)); */
|
||||
}
|
||||
|
||||
float gausb( float a )
|
||||
{
|
||||
return pow(0.5, abs(a));
|
||||
}
|
||||
|
||||
mat3 rotationMatrix( float a , float b , float c )
|
||||
{
|
||||
float xvs = sin(a);
|
||||
float yvs = sin(b);
|
||||
float zvs = sin(c);
|
||||
|
||||
float xvc = cos(a);
|
||||
float yvc = cos(b);
|
||||
float zvc = cos(c);
|
||||
|
||||
float Ox1 = yvc * zvc;
|
||||
float Ox2 = xvc * yvs * zvc + xvs * zvs;
|
||||
float Ox3 = xvc * zvs - xvs * yvs * zvc;
|
||||
|
||||
float Oy1 = xvc * zvc + xvs * yvs * zvs;
|
||||
float Oy2 = xvs * zvc - xvc * yvs * zvs;
|
||||
float Oy3 = -yvc * zvs;
|
||||
|
||||
float Oz1 = xvc * yvc;
|
||||
float Oz2 = -xvs * yvc;
|
||||
float Oz3 = -yvs;
|
||||
|
||||
return mat3( Ox1 , Ox3 , Ox2 ,
|
||||
Oy3 , Oy1 , Oy2 ,
|
||||
Oz3 , Oz2 , Oz1 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
vec3 objet(vec3 c , vec3 v , float t )
|
||||
{
|
||||
vec3 vt = vec3(8.0,2.0,2.0);
|
||||
|
||||
float ti = cos(t * 3.0);
|
||||
float to = cos(t * 0.2) * 0.02 + 0.5;
|
||||
|
||||
vec3 co = vec3(0.0);
|
||||
|
||||
|
||||
mat3 disto = rotationMatrix( v.z , v.x , -v.y );
|
||||
|
||||
vec3 vi = v * disto;
|
||||
float lvi = length(vi);
|
||||
|
||||
float gg = gausa((lvi - 12.0 * to))
|
||||
* gausa((8.485 - 12.0 * to))
|
||||
* gausa((lvi - 8.485));
|
||||
|
||||
vec3 col = c * vec3(1.0 - gg);
|
||||
|
||||
vt.x = vi.x + 3.0;
|
||||
|
||||
|
||||
float size = param1;
|
||||
float gg2 = gausa(size * (lvi - 6.0 * to))
|
||||
* gausa(size * (lvi - length(vt)));
|
||||
|
||||
vec3 material = matColor;
|
||||
|
||||
return mix(col, material , gg2 * param1);
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
float t = time;
|
||||
|
||||
vec2 xy = gl_TexCoord[0].xy;
|
||||
|
||||
|
||||
vec3 coll = vec3(0.0);
|
||||
|
||||
const int iter = 3;
|
||||
|
||||
mat3 rotation = rotationMatrix( t, t, -t);
|
||||
|
||||
vec3 d = rotation * vec3(xy, float(iter));
|
||||
vec3 a = rotation * vec3(xy * vec2(2.0), -float(iter));
|
||||
|
||||
|
||||
for (int z = 0; z <= iter; ++z)
|
||||
{
|
||||
float fr = float(z) / float(iter);
|
||||
vec3 posi = mix(d, a, fr);
|
||||
coll = objet(coll, posi, t);
|
||||
|
||||
}
|
||||
gl_FragColor = vec4 (coll, 1.0);
|
||||
}
|
||||
6
hgplus/ShaderMinifier/tests/real/extatique/graindo12.vs
Normal file
6
hgplus/ShaderMinifier/tests/real/extatique/graindo12.vs
Normal file
@@ -0,0 +1,6 @@
|
||||
void main()
|
||||
{
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_FrontColor = gl_Color;
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
93
hgplus/ShaderMinifier/tests/real/extatique/lambert.fs
Normal file
93
hgplus/ShaderMinifier/tests/real/extatique/lambert.fs
Normal file
@@ -0,0 +1,93 @@
|
||||
varying vec3 N;
|
||||
varying vec3 pos;
|
||||
varying vec3 wpos;
|
||||
|
||||
varying vec3 l1_pos;
|
||||
varying vec3 l2_pos;
|
||||
varying vec3 l3_pos;
|
||||
|
||||
uniform vec3 light1Color;
|
||||
uniform vec3 light2Color;
|
||||
uniform vec3 light3Color;
|
||||
uniform vec3 ambientColor;
|
||||
|
||||
|
||||
uniform float light1Specular;
|
||||
uniform float light2Specular;
|
||||
uniform float light3Specular;
|
||||
uniform float light1Diffuse;
|
||||
uniform float light2Diffuse;
|
||||
uniform float light3Diffuse;
|
||||
uniform float thresholdZ;
|
||||
|
||||
const float linAtt = 0.20;
|
||||
const float quadAtt = 0.1;
|
||||
const float fogNear = 1.0;
|
||||
const float fogFar = 10.0;
|
||||
|
||||
uniform sampler2D noise;
|
||||
|
||||
|
||||
float AO(vec3 p)
|
||||
{
|
||||
return 1.0 / (1.0 + 0.012 * dot(p,p));
|
||||
}
|
||||
|
||||
vec3 desaturate(vec3 c, float s)
|
||||
{
|
||||
return mix( c, vec3(dot(vec3(0.3), c)), s);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
vec2 p = gl_TexCoord[0].xy;
|
||||
|
||||
vec3 perturb = vec3(texture2D(noise, p + vec2(0.13,0.46)).x, texture2D(noise, p).x, texture2D(noise, p + vec2(-0.33,0.14)).x);
|
||||
|
||||
perturb = (perturb - vec3(0.5)) * 5.0;
|
||||
|
||||
vec3 nml = normalize(N + perturb);
|
||||
|
||||
if (nml.z < thresholdZ) discard;
|
||||
|
||||
vec3 l1dist = l1_pos - pos;
|
||||
vec3 l2dist = l2_pos - pos;
|
||||
vec3 l3dist = l3_pos - pos;
|
||||
|
||||
float dist1 = length(l1dist);
|
||||
float dist2 = length(l2dist);
|
||||
float dist3 = length(l3dist);
|
||||
|
||||
vec3 lv1 = l1dist / dist1;
|
||||
vec3 lv2 = l2dist / dist2;
|
||||
vec3 lv3 = l3dist / dist3;
|
||||
|
||||
vec3 eye = normalize(-pos);
|
||||
|
||||
vec3 re1 = reflect(lv1, N);
|
||||
vec3 re2 = reflect(lv2, N);
|
||||
vec3 re3 = reflect(lv3, N);
|
||||
|
||||
float diffl1 = max(0.0, dot(nml,lv1) );
|
||||
float diffl2 = max(0.0, dot(nml,lv2) );
|
||||
float diffl3 = max(0.0, dot(nml,lv3) );
|
||||
|
||||
float specl1 = light1Specular * pow(max(0.0, dot(eye, re1)), 10.0);
|
||||
float specl2 = light2Specular * pow(max(0.0, dot(eye, re2)), 10.0);
|
||||
float specl3 = light3Specular * pow(max(0.0, dot(eye, re3)), 10.0);
|
||||
|
||||
|
||||
float ql1 = (diffl1 + specl1) / (1.0 + dist1 * (linAtt + quadAtt * dist1));
|
||||
float ql2 = (diffl2 + specl2) / (1.0 + dist2 * (linAtt + quadAtt * dist2));
|
||||
float ql3 = (diffl3 + specl3) / (1.0 + dist3 * (linAtt + quadAtt * dist3));
|
||||
|
||||
vec3 light = ambientColor + light1Color * vec3(ql1) + light2Color * vec3(ql2) + light3Color * vec3(ql3);
|
||||
|
||||
|
||||
float fogAmount = clamp( (pos.z - fogNear) / (fogFar - fogNear) , 0.0, 1.0);
|
||||
vec3 lightAO = desaturate(light * vec3(AO(wpos)), fogAmount);
|
||||
|
||||
|
||||
gl_FragColor = gl_Color * vec4(lightAO, 1.0);
|
||||
}
|
||||
27
hgplus/ShaderMinifier/tests/real/extatique/lambert.vs
Normal file
27
hgplus/ShaderMinifier/tests/real/extatique/lambert.vs
Normal file
@@ -0,0 +1,27 @@
|
||||
uniform vec3 light1Pos;
|
||||
uniform vec3 light2Pos;
|
||||
uniform vec3 light3Pos;
|
||||
uniform mat4 invCamMat;
|
||||
|
||||
varying vec3 N;
|
||||
varying vec3 pos;
|
||||
varying vec3 wpos;
|
||||
varying vec3 l1_pos;
|
||||
varying vec3 l2_pos;
|
||||
varying vec3 l3_pos;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
N = gl_NormalMatrix * gl_Normal;
|
||||
vec4 epos = gl_ModelViewMatrix * gl_Vertex;
|
||||
wpos = (invCamMat * epos).xyz;
|
||||
pos = epos.xyz;
|
||||
l1_pos = (gl_ModelViewMatrix * vec4(light1Pos,1.0)).xyz;
|
||||
l2_pos = (gl_ModelViewMatrix * vec4(light2Pos,1.0)).xyz;
|
||||
l3_pos = (gl_ModelViewMatrix * vec4(light3Pos,1.0)).xyz;
|
||||
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_FrontColor = gl_Color;
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
91
hgplus/ShaderMinifier/tests/real/extatique/lambert2.fs
Normal file
91
hgplus/ShaderMinifier/tests/real/extatique/lambert2.fs
Normal file
@@ -0,0 +1,91 @@
|
||||
varying vec3 N;
|
||||
varying vec3 pos;
|
||||
|
||||
|
||||
varying vec3 l1_pos;
|
||||
varying vec3 l2_pos;
|
||||
varying vec3 l3_pos;
|
||||
|
||||
uniform vec3 light1Color;
|
||||
uniform vec3 light2Color;
|
||||
uniform vec3 light3Color;
|
||||
uniform vec3 ambientColor;
|
||||
|
||||
|
||||
uniform float light1Specular;
|
||||
uniform float light2Specular;
|
||||
uniform float light3Specular;
|
||||
uniform float light1Diffuse;
|
||||
uniform float light2Diffuse;
|
||||
uniform float light3Diffuse;
|
||||
|
||||
const float linAtt = 0.30;
|
||||
const float quadAtt = 0.2;
|
||||
const float fogNear = 1.0;
|
||||
const float fogFar = 5.0;
|
||||
|
||||
uniform sampler2D noise;
|
||||
uniform sampler2D tex;
|
||||
|
||||
|
||||
|
||||
vec3 desaturate(vec3 c, float s)
|
||||
{
|
||||
return mix( c, vec3(dot(vec3(0.3), c)), s);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
vec2 p = gl_TexCoord[0].xy;
|
||||
|
||||
vec3 perturb = vec3(texture2D(noise, p + vec2(0.13,0.46)).x, texture2D(noise, p).x, texture2D(noise, p + vec2(-0.33,0.14)).x);
|
||||
|
||||
vec4 texColor = texture2D(tex,p);
|
||||
|
||||
perturb = (perturb - vec3(0.5)) * 10.0;
|
||||
|
||||
vec3 nml = normalize(N + perturb);
|
||||
|
||||
|
||||
|
||||
vec3 l1dist = l1_pos - pos;
|
||||
vec3 l2dist = l2_pos - pos;
|
||||
vec3 l3dist = l3_pos - pos;
|
||||
|
||||
float dist1 = length(l1dist);
|
||||
float dist2 = length(l2dist);
|
||||
float dist3 = length(l3dist);
|
||||
|
||||
vec3 lv1 = l1dist / dist1;
|
||||
vec3 lv2 = l2dist / dist2;
|
||||
vec3 lv3 = l3dist / dist3;
|
||||
|
||||
vec3 eye = normalize(-pos);
|
||||
|
||||
vec3 re1 = reflect(lv1, N);
|
||||
vec3 re2 = reflect(lv2, N);
|
||||
vec3 re3 = reflect(lv3, N);
|
||||
|
||||
float diffl1 = max(0.0, dot(nml,lv1) );
|
||||
float diffl2 = max(0.0, dot(nml,lv2) );
|
||||
float diffl3 = max(0.0, dot(nml,lv3) );
|
||||
|
||||
float specl1 = light1Specular * pow(max(0.0, dot(eye, re1)), 10.0);
|
||||
float specl2 = light2Specular * pow(max(0.0, dot(eye, re2)), 10.0);
|
||||
float specl3 = light3Specular * pow(max(0.0, dot(eye, re3)), 10.0);
|
||||
|
||||
|
||||
float ql1 = (diffl1 + specl1) / (1.0 + dist1 * (linAtt + quadAtt * dist1));
|
||||
float ql2 = (diffl2 + specl2) / (1.0 + dist2 * (linAtt + quadAtt * dist2));
|
||||
float ql3 = (diffl3 + specl3) / (1.0 + dist3 * (linAtt + quadAtt * dist3));
|
||||
|
||||
vec3 light = ambientColor + light1Color * vec3(ql1) + light2Color * vec3(ql2) + light3Color * vec3(ql3);
|
||||
|
||||
|
||||
float fogAmount = clamp( (pos.z - fogNear) / (fogFar - fogNear) , 0.0, 1.0);
|
||||
vec3 lightAO = desaturate(light , fogAmount);
|
||||
|
||||
|
||||
gl_FragColor = texColor * gl_Color * vec4(lightAO, 1.0);
|
||||
}
|
||||
27
hgplus/ShaderMinifier/tests/real/extatique/lambert2.vs
Normal file
27
hgplus/ShaderMinifier/tests/real/extatique/lambert2.vs
Normal file
@@ -0,0 +1,27 @@
|
||||
uniform vec3 light1Pos;
|
||||
uniform vec3 light2Pos;
|
||||
uniform vec3 light3Pos;
|
||||
uniform mat4 invCamMat;
|
||||
|
||||
varying vec3 N;
|
||||
varying vec3 pos;
|
||||
|
||||
varying vec3 l1_pos;
|
||||
varying vec3 l2_pos;
|
||||
varying vec3 l3_pos;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
N = gl_NormalMatrix * gl_Normal;
|
||||
vec4 epos = gl_ModelViewMatrix * gl_Vertex;
|
||||
|
||||
pos = epos.xyz;
|
||||
l1_pos = (gl_ModelViewMatrix * vec4(light1Pos,1.0)).xyz;
|
||||
l2_pos = (gl_ModelViewMatrix * vec4(light2Pos,1.0)).xyz;
|
||||
l3_pos = (gl_ModelViewMatrix * vec4(light3Pos,1.0)).xyz;
|
||||
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_FrontColor = gl_Color;
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
31
hgplus/ShaderMinifier/tests/real/extatique/loading.fs
Normal file
31
hgplus/ShaderMinifier/tests/real/extatique/loading.fs
Normal file
@@ -0,0 +1,31 @@
|
||||
uniform sampler2D tex;
|
||||
uniform sampler3D gammaRamp;
|
||||
|
||||
uniform float blurType;
|
||||
uniform float blurAmount;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 p = gl_TexCoord[0].xy;
|
||||
|
||||
vec4 blur = ( texture2DLod(tex, p, 7.0)
|
||||
+ texture2DLod(tex, p, 6.0)
|
||||
+ texture2DLod(tex, p, 5.0)
|
||||
+ texture2DLod(tex, p, 4.0)
|
||||
+ texture2DLod(tex, p, 3.0)
|
||||
+ texture2DLod(tex, p, 2.0)
|
||||
+ texture2DLod(tex, p, 1.0)) * vec4(0.142857); /* 1/7 */
|
||||
|
||||
vec4 center = texture2D(tex, p);
|
||||
|
||||
|
||||
vec4 blurred = (vec4(1.0) - (vec4(1.0) - blur) * (vec4(1.0) - center));
|
||||
vec4 blurred2 = blurred * mix( blurred, vec4(1.0), blurType);
|
||||
|
||||
vec4 uncorrected = mix(center, blurred2, blurAmount);
|
||||
|
||||
/* gamma correction */
|
||||
|
||||
gl_FragColor = texture3D(gammaRamp, uncorrected.xyz);
|
||||
}
|
||||
5
hgplus/ShaderMinifier/tests/real/extatique/loading.vs
Normal file
5
hgplus/ShaderMinifier/tests/real/extatique/loading.vs
Normal file
@@ -0,0 +1,5 @@
|
||||
void main()
|
||||
{
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_Position = gl_Vertex;
|
||||
}
|
||||
20
hgplus/ShaderMinifier/tests/real/extatique/log.fs
Normal file
20
hgplus/ShaderMinifier/tests/real/extatique/log.fs
Normal file
@@ -0,0 +1,20 @@
|
||||
uniform sampler2D tex;
|
||||
uniform float invGamma;
|
||||
|
||||
const vec3 LUMINANCECONV = vec3(0.11,0.6,0.29);
|
||||
void main()
|
||||
{
|
||||
vec2 p = gl_TexCoord[0].xy;
|
||||
|
||||
|
||||
|
||||
vec3 sample = texture2D(tex, p).xyz;
|
||||
|
||||
|
||||
sample = log2(sample + vec3(1.0));
|
||||
float luminance = dot(LUMINANCECONV, sample);
|
||||
|
||||
vec3 sampleC = sample * vec3(pow(luminance,invGamma));
|
||||
|
||||
gl_FragColor = gl_Color * vec4(sampleC,1.0);
|
||||
}
|
||||
6
hgplus/ShaderMinifier/tests/real/extatique/log.vs
Normal file
6
hgplus/ShaderMinifier/tests/real/extatique/log.vs
Normal file
@@ -0,0 +1,6 @@
|
||||
void main()
|
||||
{
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_FrontColor = gl_Color;
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
8
hgplus/ShaderMinifier/tests/real/extatique/particle.fs
Normal file
8
hgplus/ShaderMinifier/tests/real/extatique/particle.fs
Normal file
@@ -0,0 +1,8 @@
|
||||
uniform sampler2D tex;
|
||||
uniform float intensity;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 p = gl_TexCoord[0].xy;
|
||||
gl_FragColor = vec4(vec3(intensity), 1.0) * gl_Color * texture2D(tex, p);
|
||||
}
|
||||
17
hgplus/ShaderMinifier/tests/real/extatique/particle.vs
Normal file
17
hgplus/ShaderMinifier/tests/real/extatique/particle.vs
Normal file
@@ -0,0 +1,17 @@
|
||||
uniform float minDist;
|
||||
uniform float maxDist;
|
||||
uniform float minSize;
|
||||
uniform float maxSize;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
|
||||
vec4 pos = ftransform();
|
||||
gl_Position = pos;
|
||||
|
||||
float f = (pos.z - minDist) / (maxDist - minDist);
|
||||
|
||||
gl_FrontColor = gl_Color * vec4(vec3(1), f);
|
||||
gl_PointSize = minSize + maxSize * f;
|
||||
}
|
||||
58
hgplus/ShaderMinifier/tests/real/extatique/progress.fs
Normal file
58
hgplus/ShaderMinifier/tests/real/extatique/progress.fs
Normal file
@@ -0,0 +1,58 @@
|
||||
uniform sampler2D tex;
|
||||
uniform float progression;
|
||||
|
||||
vec3 desaturate(vec3 c, float s)
|
||||
{
|
||||
return mix( c, vec3(dot(vec3(0.33), c)), s);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
float A = 3.1415 * 0.5;
|
||||
float TOUR = 13.0;
|
||||
|
||||
float t = gl_TexCoord[0].y;
|
||||
float s = gl_TexCoord[0].x + 0.15 * sin(t * 2.0 * 3.1415);
|
||||
|
||||
float v = smoothstep(0.0,0.1,t) - smoothstep(0.9,1.0,t);
|
||||
|
||||
float center1 = 0.5 + 0.5 * sin(TOUR * t);
|
||||
float distu1 = abs(center1 - s);
|
||||
float value1 = sqrt(max(0.0, 2.5 - (9.0 - 3.0 * abs(cos(TOUR * t))) * distu1));
|
||||
float alpha1 = value1 *max(0.0,-cos(TOUR * t));
|
||||
|
||||
float center2 = 0.5 + 0.5 * sin(TOUR * t + A);
|
||||
float distu2 = abs(center2 - s);
|
||||
float value2 = sqrt(max(0.0, 2.5 - (9.0 - 3.0 * abs(cos(TOUR * t + A))) * distu2));
|
||||
float alpha2 = value2 *max(0.0,-cos(TOUR * t + A));
|
||||
|
||||
float center3 = 0.5 + 0.5 * sin(TOUR * t + A * 2.0);
|
||||
float distu3 = abs(center3 - s);
|
||||
float value3 = sqrt(max(0.0, 2.5 - (9.0 - 3.0 * abs(cos(TOUR * t + A * 2.0))) * distu3));
|
||||
float alpha3 = value3 *max(0.0,-cos(TOUR * t + A * 2.0));
|
||||
|
||||
float center4 = 0.5 + 0.5 * sin(TOUR * t + A * 3.0);
|
||||
float distu4 = abs(center4 - s);
|
||||
float value4 = sqrt(max(0.0, 2.5 - (9.0 - 3.0 * abs(cos(TOUR * t + A * 3.0))) * distu4));
|
||||
float alpha4 = value4 * max(0.0, -cos(TOUR * t + A * 3.0));
|
||||
|
||||
const float desat = 0.3;
|
||||
float refs1 = (gl_TexCoord[0].x + 0.51) / 2.0;
|
||||
float refs2 = (gl_TexCoord[0].x + 0.44) / 2.0;
|
||||
float refs3 = (gl_TexCoord[0].x + 0.55) / 2.0;
|
||||
float refs4 = (gl_TexCoord[0].x + 0.48) / 2.0;
|
||||
vec3 c1 = (refs1 < progression) ? desaturate(vec3(1.0, 0.59, 1.0), desat) : vec3(0.3,0.3,0.3);
|
||||
vec3 c2 = (refs2 < progression) ? desaturate(vec3(0.6,0.18,0.19), desat) : vec3(0.4,0.4,0.4);
|
||||
vec3 c3 = (refs3 < progression) ? desaturate(vec3(0.97,0.62,118.0/255.0), desat) : vec3(0.6,0.6,0.6);
|
||||
vec3 c4 = (refs4 < progression) ? desaturate(vec3(254.0/255.0,79.0/255.0,138.0/255.0), desat) : vec3(0.5,0.5,0.5);
|
||||
|
||||
vec4 final_color = vec4(alpha1 * c1
|
||||
+ alpha2 * c2
|
||||
+ alpha3 * c3
|
||||
+ alpha4 * c4, v * (alpha1 + alpha2 + alpha3 + alpha4));
|
||||
|
||||
vec2 p = gl_TexCoord[0].xy;
|
||||
gl_FragColor = gl_Color * final_color * mix(texture2D(tex, p * vec2(1.5, 4.5)), vec4(1.0,1.0,1.0,1.0), 0.5);
|
||||
}
|
||||
|
||||
|
||||
6
hgplus/ShaderMinifier/tests/real/extatique/progress.vs
Normal file
6
hgplus/ShaderMinifier/tests/real/extatique/progress.vs
Normal file
@@ -0,0 +1,6 @@
|
||||
void main()
|
||||
{
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_FrontColor = gl_Color;
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
4
hgplus/ShaderMinifier/tests/real/extatique/put.fs
Normal file
4
hgplus/ShaderMinifier/tests/real/extatique/put.fs
Normal file
@@ -0,0 +1,4 @@
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = gl_Color;
|
||||
}
|
||||
5
hgplus/ShaderMinifier/tests/real/extatique/put.vs
Normal file
5
hgplus/ShaderMinifier/tests/real/extatique/put.vs
Normal file
@@ -0,0 +1,5 @@
|
||||
void main()
|
||||
{
|
||||
gl_FrontColor = gl_Color;
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
59
hgplus/ShaderMinifier/tests/real/extatique/raymarch.fs
Normal file
59
hgplus/ShaderMinifier/tests/real/extatique/raymarch.fs
Normal file
@@ -0,0 +1,59 @@
|
||||
varying vec3 dir;
|
||||
|
||||
|
||||
float flr(vec3 p, float f)
|
||||
{
|
||||
return abs(f - p.y);
|
||||
}
|
||||
|
||||
float sph(vec3 p, vec4 spr)
|
||||
{
|
||||
return length(spr.xyz - p) - spr.w;
|
||||
}
|
||||
|
||||
float iso_tore(vec3 p, vec3 center, float r1, float r2)
|
||||
{
|
||||
p -= center;
|
||||
float xx = sqrt(p.x * p.x + p.z * p.z) - r1;
|
||||
float dist = sqrt(xx * xx + p.y * p.y) - r2;
|
||||
return mix(dist, dist, 0.9);
|
||||
}
|
||||
|
||||
float scene(vec3 p)
|
||||
{
|
||||
float d = iso_tore(p, vec3(0,0,15), 2.0, 0.5);
|
||||
return d;
|
||||
}
|
||||
|
||||
vec3 getN(vec3 p)
|
||||
{
|
||||
float eps = 0.01;
|
||||
return normalize(vec3(
|
||||
scene(p+vec3(eps,0,0))-scene(p-vec3(eps,0,0)),
|
||||
scene(p+vec3(0,eps,0))-scene(p-vec3(0,eps,0)),
|
||||
scene(p+vec3(0,0,eps))-scene(p-vec3(0,0,eps))
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
float g,d = 0.0;
|
||||
vec3 p = vec3(0);
|
||||
vec3 ndir = normalize(dir);
|
||||
|
||||
for(int i = 0; i < 64; i++)
|
||||
{
|
||||
d = scene(p);
|
||||
p = p + d * ndir;
|
||||
}
|
||||
if(d > 1.0)
|
||||
{
|
||||
gl_FragColor = vec4(1.0,0.0,0.0,1.0);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
vec3 n = getN(p);
|
||||
gl_FragColor = vec4(n, 1.0);
|
||||
}
|
||||
9
hgplus/ShaderMinifier/tests/real/extatique/raymarch.vs
Normal file
9
hgplus/ShaderMinifier/tests/real/extatique/raymarch.vs
Normal file
@@ -0,0 +1,9 @@
|
||||
varying vec3 dir;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 pos = ftransform();
|
||||
gl_Position = pos;
|
||||
dir = pos.xyz;
|
||||
|
||||
}
|
||||
41
hgplus/ShaderMinifier/tests/real/extatique/scene30.fs
Normal file
41
hgplus/ShaderMinifier/tests/real/extatique/scene30.fs
Normal file
@@ -0,0 +1,41 @@
|
||||
uniform sampler2D tex;
|
||||
uniform float angle;
|
||||
uniform float time;
|
||||
varying vec3 pos;
|
||||
varying vec3 N;
|
||||
|
||||
|
||||
vec4 getEnvColor(vec3 p)
|
||||
{
|
||||
float az = atan(p.x, p.y + 0.01);
|
||||
float ax = -pos.z;
|
||||
|
||||
vec4 sample = vec4(0.0);
|
||||
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
float fi = float(i);
|
||||
float s = ax * 2.0 / (1.0 + fi) + time * 0.01 * (2.0 + fi);
|
||||
float t = angle + (2.5) * az / 3.14159;
|
||||
|
||||
sample += texture2D(tex, vec2(s,t)) / (1.0 + 0.3 * fi);
|
||||
}
|
||||
return sample;
|
||||
}
|
||||
|
||||
vec3 diffuseLighting(vec3 pos, vec3 nml)
|
||||
{
|
||||
float df1 = 0.8 * max(0.0, dot(nml, vec3(1.0,0.2, 0.0)));
|
||||
float df2 = 0.2 * max(0.0, dot(nml, vec3(-1.0,-0.1, 0.0)));
|
||||
vec3 diffuse = vec3(df1) * vec3(0.8,0.7,0.6) + vec3(df2) * vec3(0.6,0.7,0.8);
|
||||
return diffuse;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 nml = normalize(N);
|
||||
vec3 R = reflect(-pos, normalize(nml));
|
||||
vec3 envColor = getEnvColor(R).xyz * mix(vec3(1.0), gl_Color.xyz, 0.4);
|
||||
vec3 diffuseColor = getEnvColor(pos).xyz * gl_Color.xyz;
|
||||
gl_FragColor = vec4( diffuseColor + envColor, 1.0);
|
||||
}
|
||||
11
hgplus/ShaderMinifier/tests/real/extatique/scene30.vs
Normal file
11
hgplus/ShaderMinifier/tests/real/extatique/scene30.vs
Normal file
@@ -0,0 +1,11 @@
|
||||
varying vec3 pos;
|
||||
varying vec3 N;
|
||||
|
||||
void main()
|
||||
{
|
||||
pos = (gl_ModelViewMatrix * gl_Vertex).xyz;
|
||||
gl_Position = ftransform();
|
||||
gl_FrontColor = gl_Color;
|
||||
N = gl_NormalMatrix * gl_Normal;
|
||||
|
||||
}
|
||||
177
hgplus/ShaderMinifier/tests/real/extatique/scene40.fs
Normal file
177
hgplus/ShaderMinifier/tests/real/extatique/scene40.fs
Normal file
@@ -0,0 +1,177 @@
|
||||
uniform sampler2D tex;
|
||||
varying vec3 wpos;
|
||||
varying vec3 N;
|
||||
uniform vec3 eyePos;
|
||||
uniform float radius;
|
||||
uniform float medium;
|
||||
uniform vec3 center;
|
||||
uniform vec3 light1;
|
||||
uniform vec3 light2;
|
||||
uniform vec3 light3;
|
||||
uniform vec3 light4;
|
||||
|
||||
|
||||
vec3 getEnvColor(vec3 pos, vec2 coord)
|
||||
{
|
||||
vec3 color = texture2D(tex, coord * 0.05).xyz;
|
||||
|
||||
vec3 light1_dist = pos * 0.1 - vec3(-0.5,-0.5,-0.5);
|
||||
vec3 light2_dist = pos * 0.1 - vec3(+0.5,+0.5,-0.5);
|
||||
vec3 light3_dist = pos * 0.1 - vec3(-0.5,+0.5,+0.5);
|
||||
vec3 light4_dist = pos * 0.1 - vec3(+0.5,-0.5,+0.5);
|
||||
|
||||
vec3 clight1 = light1 * vec3(max(0.0, 1.25 - 1.0 * dot(light1_dist, light1_dist)));
|
||||
vec3 clight2 = light2 * vec3(max(0.0, 1.25 - 1.0 * dot(light2_dist, light2_dist)));
|
||||
vec3 clight3 = light3 * vec3(max(0.0, 1.25 - 1.0 * dot(light3_dist, light3_dist)));
|
||||
vec3 clight4 = light4 * vec3(max(0.0, 1.25 - 1.0 * dot(light4_dist, light4_dist)));
|
||||
|
||||
|
||||
return color + clight1 + clight2 + clight3 + clight4;
|
||||
}
|
||||
|
||||
float exp3(float x)
|
||||
{
|
||||
float y = max(-1.15365, x);
|
||||
return 1.0 + y * (1.0 + y * (0.5 + y * 0.33333333));
|
||||
}
|
||||
|
||||
vec3 rayColor(vec3 startPos, vec3 startDir)
|
||||
{
|
||||
vec3 total = vec3(0.0);
|
||||
vec3 p = startPos;
|
||||
vec3 dir = startDir;
|
||||
vec3 blend = vec3(0.5);
|
||||
vec3 dpos;
|
||||
vec3 color = vec3(0.0);
|
||||
|
||||
vec3 ray;
|
||||
vec3 nml;
|
||||
vec2 coord;
|
||||
vec3 newdir;
|
||||
vec3 sample;
|
||||
|
||||
for (int i = 0; i < 1; ++i)
|
||||
{
|
||||
ray = 40.0 * dir;
|
||||
nml = vec3(0.0);
|
||||
coord = vec2(0.0);
|
||||
dpos = p + ray;
|
||||
|
||||
if (abs(dpos.x) > 10.0)
|
||||
{
|
||||
if (dpos.x > 10.0)
|
||||
{
|
||||
ray *= ((9.99 - p.x) / ray.x);
|
||||
nml = vec3(-1.0,0.0,0.0);
|
||||
dpos = ray + p;
|
||||
coord = dpos.yz;
|
||||
color = getEnvColor(dpos, coord);
|
||||
}
|
||||
else
|
||||
{
|
||||
ray *= ((-9.99 - p.x) / ray.x);
|
||||
nml = vec3(1.0,0.0,0.0);
|
||||
|
||||
|
||||
dpos = ray + p;
|
||||
coord = dpos.yz * vec2(-1.0,1.0);
|
||||
color = getEnvColor(dpos, coord);
|
||||
}
|
||||
}
|
||||
|
||||
if (abs(dpos.y) > 10.0)
|
||||
{
|
||||
if (dpos.y > 10.0)
|
||||
{
|
||||
ray *= ((9.99 - p.y) / ray.y);
|
||||
nml = vec3(0.0,-1.0,0.0);
|
||||
|
||||
|
||||
dpos = ray + p;
|
||||
coord = dpos.xz * vec2(-1.0,1.0);
|
||||
color = getEnvColor(dpos, coord);
|
||||
}
|
||||
else
|
||||
{
|
||||
ray *= ((-9.99 - p.y) / ray.y);
|
||||
nml = vec3(0.0,1.0,0.0);
|
||||
|
||||
dpos = ray + p;
|
||||
coord = dpos.xz;
|
||||
color = getEnvColor(dpos, coord);
|
||||
}
|
||||
}
|
||||
|
||||
if (abs(dpos.z) > 10.0)
|
||||
{
|
||||
if (dpos.z > 10.0)
|
||||
{
|
||||
ray *= ((9.99 - p.z) / ray.z);
|
||||
nml = vec3(0.0,0.0,-1.0);
|
||||
dpos = ray + p;
|
||||
coord = dpos.xy * vec2(-1.0,1.0);
|
||||
color = getEnvColor(dpos, coord);
|
||||
}
|
||||
else
|
||||
{
|
||||
ray *= ((-9.99 - p.z) / ray.z);
|
||||
nml = vec3(0.0,0.0,1.0);
|
||||
dpos = ray + p;
|
||||
coord = dpos.xy;
|
||||
color = getEnvColor(dpos, coord);
|
||||
}
|
||||
}
|
||||
|
||||
sample = color * vec3(exp3(-length(ray) * 0.04));
|
||||
|
||||
total += sample * blend;
|
||||
blend *= sample;
|
||||
|
||||
newdir = reflect(dir, nml);
|
||||
|
||||
p = dpos;
|
||||
dir = newdir;
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void snell(vec3 dir, vec3 normal, float n1, float n2, out vec3 reflectionDir, out vec3 refractionDir, out float cost2)
|
||||
{
|
||||
float n1n2 = n1 / n2;
|
||||
float cost1 = dot(-dir, normal);
|
||||
cost2 = sqrt(1.0 - n1n2 * n1n2 * (1.0 - cost1 * cost1));
|
||||
|
||||
reflectionDir = dir + normal * (2.0 * cost1);
|
||||
refractionDir = dir * n1n2 + normal * (cost2 + n1n2 * cost1);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 nml = normalize(N);
|
||||
vec3 dir = normalize(wpos - eyePos);
|
||||
|
||||
|
||||
vec3 R;
|
||||
vec3 RE;
|
||||
float cost2, fdummy;
|
||||
|
||||
|
||||
snell(dir, nml, 1.0, medium + 0.1, R, RE, cost2);
|
||||
|
||||
float dist = 2.0 * cost2 * radius;
|
||||
vec3 p2 = wpos + RE * vec3(dist);
|
||||
vec3 nml2 = -(p2 - center) / radius;
|
||||
vec3 Rdummy, Rout;
|
||||
snell(RE, nml2, medium + 0.3, 1.0, Rdummy, Rout, fdummy);
|
||||
float fact = 2.0 * exp3(-dot(dist,dist) * 0.2);
|
||||
vec3 diffracted = rayColor(p2, Rout) * vec3(fact);
|
||||
|
||||
|
||||
vec3 specular = rayColor(wpos, R) * gl_Color.xyz;
|
||||
|
||||
|
||||
|
||||
gl_FragColor = gl_Color * vec4( specular + diffracted, 1.0);
|
||||
}
|
||||
13
hgplus/ShaderMinifier/tests/real/extatique/scene40.vs
Normal file
13
hgplus/ShaderMinifier/tests/real/extatique/scene40.vs
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
varying vec3 wpos;
|
||||
varying vec3 N;
|
||||
uniform vec3 eyePos;
|
||||
|
||||
void main()
|
||||
{
|
||||
wpos = gl_Vertex.xyz;
|
||||
gl_Position = ftransform();
|
||||
gl_FrontColor = gl_Color;
|
||||
N = gl_Normal;
|
||||
|
||||
}
|
||||
14
hgplus/ShaderMinifier/tests/real/extatique/scene45.fs
Normal file
14
hgplus/ShaderMinifier/tests/real/extatique/scene45.fs
Normal file
@@ -0,0 +1,14 @@
|
||||
uniform sampler2D tex;
|
||||
uniform float time;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 p = gl_TexCoord[0].xy;
|
||||
float u = atan(p.y, p.x + 0.0001) * 1.0 / 3.1415926;
|
||||
float v = 0.002 / (0.01 + length(p)) - time * 0.1;
|
||||
vec4 space = texture2D(tex, vec2(u,v))
|
||||
+ vec4(0.5) * texture2D(tex, vec2(u,v * 4.0))
|
||||
+ vec4(0.25) * texture2D(tex, vec2(u,v * 16.0));
|
||||
gl_FragColor = gl_Color * space;
|
||||
}
|
||||
6
hgplus/ShaderMinifier/tests/real/extatique/scene45.vs
Normal file
6
hgplus/ShaderMinifier/tests/real/extatique/scene45.vs
Normal file
@@ -0,0 +1,6 @@
|
||||
void main()
|
||||
{
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_FrontColor = gl_Color;
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
32
hgplus/ShaderMinifier/tests/real/extatique/skybox.fs
Normal file
32
hgplus/ShaderMinifier/tests/real/extatique/skybox.fs
Normal file
@@ -0,0 +1,32 @@
|
||||
uniform sampler2D tex;
|
||||
uniform float angle;
|
||||
uniform float time;
|
||||
varying vec3 pos;
|
||||
|
||||
|
||||
|
||||
vec4 getEnvColor(vec3 p)
|
||||
{
|
||||
float az = atan(p.x, p.y + 0.01);
|
||||
float ax = -pos.z;
|
||||
|
||||
vec4 sample = vec4(0.0);
|
||||
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
float fi = float(i);
|
||||
float s = ax * 1.0 / (1.0 + fi) + time * 0.01 * (2.0 + fi);
|
||||
float t = angle + (2.5) * az / 3.14159;
|
||||
|
||||
sample += texture2D(tex, vec2(s,t)) / (1.0 + 0.3 * fi);
|
||||
}
|
||||
return sample;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 env = getEnvColor(pos);
|
||||
gl_FragColor = vec4(env.xyz, 1.0);
|
||||
}
|
||||
7
hgplus/ShaderMinifier/tests/real/extatique/skybox.vs
Normal file
7
hgplus/ShaderMinifier/tests/real/extatique/skybox.vs
Normal file
@@ -0,0 +1,7 @@
|
||||
varying vec3 pos;
|
||||
|
||||
void main()
|
||||
{
|
||||
pos = (gl_ModelViewMatrix * gl_Vertex).xyz;
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
142
hgplus/ShaderMinifier/tests/real/extatique/skybox2.fs
Normal file
142
hgplus/ShaderMinifier/tests/real/extatique/skybox2.fs
Normal file
@@ -0,0 +1,142 @@
|
||||
varying vec3 wpos;
|
||||
|
||||
uniform vec3 eyePos;
|
||||
|
||||
uniform sampler2D tex;
|
||||
uniform vec3 light1;
|
||||
uniform vec3 light2;
|
||||
uniform vec3 light3;
|
||||
uniform vec3 light4;
|
||||
|
||||
|
||||
vec3 getEnvColor(vec3 pos, vec2 coord)
|
||||
{
|
||||
vec3 color = texture2D(tex, coord * 0.05).xyz;
|
||||
|
||||
vec3 light1_dist = pos * 0.1 - vec3(-0.5,-0.5,-0.5);
|
||||
vec3 light2_dist = pos * 0.1 - vec3(+0.5,+0.5,-0.5);
|
||||
vec3 light3_dist = pos * 0.1 - vec3(-0.5,+0.5,+0.5);
|
||||
vec3 light4_dist = pos * 0.1 - vec3(+0.5,-0.5,+0.5);
|
||||
|
||||
vec3 clight1 = light1 * vec3(max(0.0, 1.25 - 1.0 * dot(light1_dist, light1_dist)));
|
||||
vec3 clight2 = light2 * vec3(max(0.0, 1.25 - 1.0 * dot(light2_dist, light2_dist)));
|
||||
vec3 clight3 = light3 * vec3(max(0.0, 1.25 - 1.0 * dot(light3_dist, light3_dist)));
|
||||
vec3 clight4 = light4 * vec3(max(0.0, 1.25 - 1.0 * dot(light4_dist, light4_dist)));
|
||||
|
||||
|
||||
return color + clight1 + clight2 + clight3 + clight4;
|
||||
}
|
||||
|
||||
float exp3(float x)
|
||||
{
|
||||
float y = max(-1.15365, x);
|
||||
return 1.0 + y * (1.0 + y * (0.5 + y * 0.33333333));
|
||||
}
|
||||
|
||||
vec3 rayColor(vec3 startPos, vec3 startDir)
|
||||
{
|
||||
vec3 total = vec3(0.0);
|
||||
vec3 p = startPos;
|
||||
vec3 dir = startDir;
|
||||
vec3 blend = vec3(0.5);
|
||||
vec3 dpos;
|
||||
vec3 color = vec3(0.0);
|
||||
|
||||
vec3 ray;
|
||||
vec3 nml;
|
||||
vec2 coord;
|
||||
vec3 newdir;
|
||||
vec3 sample;
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
ray = 50.0 * dir;
|
||||
nml = vec3(0.0);
|
||||
coord = vec2(0.0);
|
||||
dpos = p + ray;
|
||||
|
||||
if (abs(dpos.x) > 10.0)
|
||||
{
|
||||
if (dpos.x > 10.0)
|
||||
{
|
||||
ray *= ((9.99 - p.x) / ray.x);
|
||||
nml = vec3(-1.0,0.0,0.0);
|
||||
dpos = ray + p;
|
||||
coord = dpos.yz;
|
||||
color = getEnvColor(dpos, coord);
|
||||
}
|
||||
else
|
||||
{
|
||||
ray *= ((-9.99 - p.x) / ray.x);
|
||||
nml = vec3(1.0,0.0,0.0);
|
||||
|
||||
|
||||
dpos = ray + p;
|
||||
coord = dpos.yz * vec2(-1.0,1.0);
|
||||
color = getEnvColor(dpos, coord);
|
||||
}
|
||||
}
|
||||
|
||||
if (abs(dpos.y) > 10.0)
|
||||
{
|
||||
if (dpos.y > 10.0)
|
||||
{
|
||||
ray *= ((9.99 - p.y) / ray.y);
|
||||
nml = vec3(0.0,-1.0,0.0);
|
||||
|
||||
|
||||
dpos = ray + p;
|
||||
coord = dpos.xz * vec2(-1.0,1.0);
|
||||
color = getEnvColor(dpos, coord);
|
||||
}
|
||||
else
|
||||
{
|
||||
ray *= ((-9.99 - p.y) / ray.y);
|
||||
nml = vec3(0.0,1.0,0.0);
|
||||
|
||||
dpos = ray + p;
|
||||
coord = dpos.xz;
|
||||
color = getEnvColor(dpos, coord);
|
||||
}
|
||||
}
|
||||
|
||||
if (abs(dpos.z) > 10.0)
|
||||
{
|
||||
if (dpos.z > 10.0)
|
||||
{
|
||||
ray *= ((9.99 - p.z) / ray.z);
|
||||
nml = vec3(0.0,0.0,-1.0);
|
||||
dpos = ray + p;
|
||||
coord = dpos.xy * vec2(-1.0,1.0);
|
||||
color = getEnvColor(dpos, coord);
|
||||
}
|
||||
else
|
||||
{
|
||||
ray *= ((-9.99 - p.z) / ray.z);
|
||||
nml = vec3(0.0,0.0,1.0);
|
||||
dpos = ray + p;
|
||||
coord = dpos.xy;
|
||||
color = getEnvColor(dpos, coord);
|
||||
}
|
||||
}
|
||||
|
||||
sample = color * vec3(exp3(-length(ray) * 0.04));
|
||||
|
||||
total += sample * blend;
|
||||
blend *= sample;
|
||||
|
||||
newdir = reflect(dir, nml);
|
||||
|
||||
p = dpos;
|
||||
dir = newdir;
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 env = rayColor(eyePos, normalize(wpos - eyePos));
|
||||
|
||||
gl_FragColor = gl_Color * vec4(env, 1.0);
|
||||
}
|
||||
13
hgplus/ShaderMinifier/tests/real/extatique/skybox2.vs
Normal file
13
hgplus/ShaderMinifier/tests/real/extatique/skybox2.vs
Normal file
@@ -0,0 +1,13 @@
|
||||
varying vec3 wpos;
|
||||
|
||||
uniform vec3 eyePos;
|
||||
|
||||
void main()
|
||||
{
|
||||
wpos = gl_Vertex.xyz;
|
||||
/* pos = (gl_ModelViewMatrix * gl_Vertex).xyz; */
|
||||
gl_FrontColor = gl_Color;
|
||||
/* gl_TexCoord[0] = gl_MultiTexCoord0; */
|
||||
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
18
hgplus/ShaderMinifier/tests/real/extatique/snake.fs
Normal file
18
hgplus/ShaderMinifier/tests/real/extatique/snake.fs
Normal file
@@ -0,0 +1,18 @@
|
||||
varying vec3 normal;
|
||||
varying float profondeur;
|
||||
|
||||
vec4 desaturate(vec4 color, float t)
|
||||
{
|
||||
vec3 grey = vec3(dot(vec3(0.33), color.rgb));
|
||||
return vec4(mix(color.rgb, grey, t), color.a);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 N = normal;
|
||||
|
||||
vec3 e = vec3(0.0,0.0,-1.0);
|
||||
float diffuse = max(0.0, dot(N, e));
|
||||
vec4 C = gl_Color * vec4(0.1 + 0.9 * vec3(diffuse), diffuse);
|
||||
gl_FragColor = C * exp( -profondeur * 0.1 );
|
||||
}
|
||||
12
hgplus/ShaderMinifier/tests/real/extatique/snake.vs
Normal file
12
hgplus/ShaderMinifier/tests/real/extatique/snake.vs
Normal file
@@ -0,0 +1,12 @@
|
||||
varying vec3 normal;
|
||||
varying float profondeur;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FrontColor = gl_Color;
|
||||
|
||||
normal = normalize(gl_Normal);
|
||||
gl_Position = ftransform();
|
||||
|
||||
profondeur = gl_Position.z;
|
||||
}
|
||||
84
hgplus/ShaderMinifier/tests/real/extatique/water.fs
Normal file
84
hgplus/ShaderMinifier/tests/real/extatique/water.fs
Normal file
@@ -0,0 +1,84 @@
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D texu;
|
||||
uniform sampler2D texv;
|
||||
uniform float spacing;
|
||||
uniform float ratio;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 p0 = gl_TexCoord[0].xy;
|
||||
|
||||
vec4 total = texture2D(tex, p0 * 2.5);
|
||||
vec2 v0 = vec2(spacing) * (vec2(texture2D(texu, p0).x, texture2D(texv, p0).x));
|
||||
|
||||
vec2 p1 = p0 - v0;
|
||||
total = texture2D(tex, p1) * 0.9755297;
|
||||
vec2 v1 = vec2(spacing) *(vec2(texture2D(texu, p1).x, texture2D(texv, p1).x));
|
||||
|
||||
vec2 p2 = p1 - v1;
|
||||
total += texture2D(tex, p2) * 0.9045139;
|
||||
vec2 v2 = vec2(spacing) *(vec2(texture2D(texu, p2).x, texture2D(texv, p2).x));
|
||||
|
||||
vec2 p3 = p2 - v2;
|
||||
total += texture2D(tex, p1) * 0.7939039;
|
||||
vec2 v3 = vec2(spacing) *(vec2(texture2D(texu, p3).x, texture2D(texv, p3).x));
|
||||
|
||||
vec2 p4 = p3 - v3;
|
||||
total += texture2D(tex, p2) * 0.6545261;
|
||||
vec2 v4 = vec2(spacing) *(vec2(texture2D(texu, p4).x, texture2D(texv, p4).x));
|
||||
|
||||
vec2 p5 = p4 - v4;
|
||||
total += texture2D(tex, p1) * 0.5000232;
|
||||
vec2 v5 = vec2(spacing) *(vec2(texture2D(texu, p5).x, texture2D(texv, p5).x));
|
||||
|
||||
vec2 p6 = p5 - v5;
|
||||
total += texture2D(tex, p2) * 0.3455179;
|
||||
vec2 v6 = vec2(spacing) *(vec2(texture2D(texu, p6).x, texture2D(texv, p6).x));
|
||||
|
||||
vec2 p7 = p6 - v6;
|
||||
total += texture2D(tex, p1) * 0.2061336;
|
||||
vec2 v7 = vec2(spacing) *(vec2(texture2D(texu, p7).x, texture2D(texv, p7).x));
|
||||
|
||||
vec2 p8 = p7 - v7;
|
||||
total += texture2D(tex, p2) * 0.0955133;
|
||||
|
||||
|
||||
|
||||
vec2 p12 = p0 + v0;
|
||||
total += texture2D(tex, p12) * 0.9755297;
|
||||
vec2 v12 = vec2(spacing) *(vec2(texture2D(texu, p12).x, texture2D(texv, p12).x));
|
||||
|
||||
vec2 p22 = p12 + v12;
|
||||
total += texture2D(tex, p22) * 0.9045139;
|
||||
vec2 v22 = vec2(spacing) *(vec2(texture2D(texu, p22).x, texture2D(texv, p22).x));
|
||||
|
||||
vec2 p32 = p22 + v22;
|
||||
total += texture2D(tex, p12) * 0.7939039;
|
||||
vec2 v32 = vec2(spacing) *(vec2(texture2D(texu, p32).x, texture2D(texv, p32).x));
|
||||
|
||||
vec2 p42 = p32 + v32;
|
||||
total += texture2D(tex, p22) * 0.6545261;
|
||||
vec2 v42 = vec2(spacing) *(vec2(texture2D(texu, p42).x, texture2D(texv, p42).x));
|
||||
|
||||
vec2 p52 = p42 + v42;
|
||||
total += texture2D(tex, p12) * 0.5000232;
|
||||
vec2 v52 = vec2(spacing) *(vec2(texture2D(texu, p52).x, texture2D(texv, p52).x));
|
||||
|
||||
vec2 p62 = p52 + v52;
|
||||
total += texture2D(tex, p22) * 0.3455179;
|
||||
vec2 v62 = vec2(spacing) *(vec2(texture2D(texu, p62).x, texture2D(texv, p62).x));
|
||||
|
||||
vec2 p72 = p62 + v62;
|
||||
total += texture2D(tex, p12) * 0.2061336;
|
||||
vec2 v72 = vec2(spacing) *(vec2(texture2D(texu, p72).x, texture2D(texv, p72).x));
|
||||
|
||||
vec2 p82 = p72 + v72;
|
||||
total += texture2D(tex, p22) * 0.0955133;
|
||||
|
||||
vec2 dist = (p0 - vec2(0.5, 0.5)) * vec2(1.0,ratio);
|
||||
vec4 darkF = vec4(max(0.0, 1.0 - 2.5 * dot(dist,dist)));
|
||||
|
||||
vec4 finalColor = gl_Color * total * vec4(0.1) * darkF;
|
||||
|
||||
gl_FragColor = finalColor;
|
||||
}
|
||||
6
hgplus/ShaderMinifier/tests/real/extatique/water.vs
Normal file
6
hgplus/ShaderMinifier/tests/real/extatique/water.vs
Normal file
@@ -0,0 +1,6 @@
|
||||
void main()
|
||||
{
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_FrontColor = gl_Color;
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
20
hgplus/ShaderMinifier/tests/real/fly.frag
Normal file
20
hgplus/ShaderMinifier/tests/real/fly.frag
Normal file
@@ -0,0 +1,20 @@
|
||||
uniform vec2 resolution;
|
||||
uniform float time;
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform sampler2D tex2;
|
||||
void main(void)
|
||||
{
|
||||
vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
|
||||
vec2 uv;
|
||||
|
||||
float an = time*.25;
|
||||
|
||||
float x = p.x*cos(an)-p.y*sin(an);
|
||||
float y = p.x*sin(an)+p.y*cos(an);
|
||||
|
||||
uv.x = .25*x/abs(y);
|
||||
uv.y = .20*time + .25/abs(y);
|
||||
|
||||
gl_FragColor = vec4(texture2D(tex0,uv).xyz * y*y, 1.0);
|
||||
}
|
||||
213
hgplus/ShaderMinifier/tests/real/gfx monitor/ambiantocclusion.fs
Normal file
213
hgplus/ShaderMinifier/tests/real/gfx monitor/ambiantocclusion.fs
Normal file
@@ -0,0 +1,213 @@
|
||||
// FragmentProgram
|
||||
//
|
||||
// porting GLSL by kioku based on syoyo's AS3 Ambient Occlusion
|
||||
// [http://lucille.atso-net.jp/blog/?p=638]
|
||||
|
||||
varying vec3 org,dir;
|
||||
|
||||
struct Ray
|
||||
{
|
||||
vec3 org;
|
||||
vec3 dir;
|
||||
};
|
||||
struct Sphere
|
||||
{
|
||||
vec3 center;
|
||||
float radius;
|
||||
};
|
||||
struct Plane
|
||||
{
|
||||
vec3 p;
|
||||
vec3 n;
|
||||
};
|
||||
|
||||
struct Intersection
|
||||
{
|
||||
float t;
|
||||
vec3 p; // hit point
|
||||
vec3 n; // normal
|
||||
int hit;
|
||||
};
|
||||
|
||||
void shpere_intersect(Sphere s, Ray ray, inout Intersection isect)
|
||||
{
|
||||
// rs = ray.org - sphere.center
|
||||
vec3 rs = ray.org - s.center;
|
||||
float B = dot(rs, ray.dir);
|
||||
float C = dot(rs, rs) - (s.radius * s.radius);
|
||||
float D = B * B - C;
|
||||
|
||||
if (D > 0.0)
|
||||
{
|
||||
float t = -B - sqrt(D);
|
||||
if ( (t > 0.0) && (t < isect.t) )
|
||||
{
|
||||
isect.t = t;
|
||||
isect.hit = 1;
|
||||
|
||||
// calculate normal.
|
||||
vec3 p = vec3(ray.org.x + ray.dir.x * t,
|
||||
ray.org.y + ray.dir.y * t,
|
||||
ray.org.z + ray.dir.z * t);
|
||||
vec3 n = p - s.center;
|
||||
n = normalize(n);
|
||||
isect.n = n;
|
||||
isect.p = p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void plane_intersect(Plane pl, Ray ray, inout Intersection isect)
|
||||
{
|
||||
// d = -(p . n)
|
||||
// t = -(ray.org . n + d) / (ray.dir . n)
|
||||
float d = -dot(pl.p, pl.n);
|
||||
float v = dot(ray.dir, pl.n);
|
||||
|
||||
if (abs(v) < 1.0e-6)
|
||||
return; // the plane is parallel to the ray.
|
||||
|
||||
float t = -(dot(ray.org, pl.n) + d) / v;
|
||||
|
||||
if ( (t > 0.0) && (t < isect.t) )
|
||||
{
|
||||
isect.hit = 1;
|
||||
isect.t = t;
|
||||
isect.n = pl.n;
|
||||
|
||||
vec3 p = vec3(ray.org.x + t * ray.dir.x,
|
||||
ray.org.y + t * ray.dir.y,
|
||||
ray.org.z + t * ray.dir.z);
|
||||
isect.p = p;
|
||||
}
|
||||
}
|
||||
|
||||
Sphere sphere[3];
|
||||
Plane plane;
|
||||
void Intersect(Ray r, inout Intersection i)
|
||||
{
|
||||
for (int c = 0; c < 3; c++)
|
||||
{
|
||||
shpere_intersect(sphere[c], r, i);
|
||||
}
|
||||
plane_intersect(plane, r, i);
|
||||
}
|
||||
|
||||
void orthoBasis(out vec3 basis[3], vec3 n)
|
||||
{
|
||||
basis[2] = vec3(n.x, n.y, n.z);
|
||||
basis[1] = vec3(0.0, 0.0, 0.0);
|
||||
|
||||
if ((n.x < 0.6) && (n.x > -0.6))
|
||||
basis[1].x = 1.0;
|
||||
else if ((n.y < 0.6) && (n.y > -0.6))
|
||||
basis[1].y = 1.0;
|
||||
else if ((n.z < 0.6) && (n.z > -0.6))
|
||||
basis[1].z = 1.0;
|
||||
else
|
||||
basis[1].x = 1.0;
|
||||
|
||||
|
||||
basis[0] = cross(basis[1], basis[2]);
|
||||
basis[0] = normalize(basis[0]);
|
||||
|
||||
basis[1] = cross(basis[2], basis[0]);
|
||||
basis[1] = normalize(basis[1]);
|
||||
|
||||
}
|
||||
|
||||
int seed = 0;
|
||||
float random()
|
||||
{
|
||||
seed = int(mod(float(seed)*1364.0+626.0, 509.0));
|
||||
return float(seed)/509.0;
|
||||
}
|
||||
vec3 computeAO(inout Intersection isect)
|
||||
{
|
||||
int i, j;
|
||||
int ntheta = 8;
|
||||
int nphi = 8;
|
||||
float eps = 0.0001;
|
||||
|
||||
// Slightly move ray org towards ray dir to avoid numerical probrem.
|
||||
vec3 p = vec3(isect.p.x + eps * isect.n.x,
|
||||
isect.p.y + eps * isect.n.y,
|
||||
isect.p.z + eps * isect.n.z);
|
||||
|
||||
// Calculate orthogonal basis.
|
||||
vec3 basis[3];
|
||||
orthoBasis(basis, isect.n);
|
||||
|
||||
float occlusion = 0.0;
|
||||
|
||||
for (j = 0; j < ntheta; j++)
|
||||
{
|
||||
for (i = 0; i < nphi; i++)
|
||||
{
|
||||
// Pick a random ray direction with importance sampling.
|
||||
// p = cos(theta) / 3.141592
|
||||
float r = random();
|
||||
float phi = 2.0 * 3.141592 * random();
|
||||
|
||||
vec3 ref;
|
||||
ref.x = cos(phi) * sqrt(1.0 - r);
|
||||
ref.y = sin(phi) * sqrt(1.0 - r);
|
||||
ref.z = sqrt(r);
|
||||
|
||||
// local -> global
|
||||
vec3 rray;
|
||||
rray.x = ref.x * basis[0].x + ref.y * basis[1].x + ref.z * basis[2].x;
|
||||
rray.y = ref.x * basis[0].y + ref.y * basis[1].y + ref.z * basis[2].y;
|
||||
rray.z = ref.x * basis[0].z + ref.y * basis[1].z + ref.z * basis[2].z;
|
||||
|
||||
vec3 raydir = vec3(rray.x, rray.y, rray.z);
|
||||
|
||||
Ray ray;
|
||||
ray.org = p;
|
||||
ray.dir = raydir;
|
||||
|
||||
Intersection occIsect;
|
||||
occIsect.hit = 0;
|
||||
occIsect.t = 1.0e+30;
|
||||
occIsect.n = occIsect.p = vec3(0, 0, 0);
|
||||
Intersect(ray, occIsect);
|
||||
if (occIsect.hit != 0)
|
||||
occlusion += 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
// [0.0, 1.0]
|
||||
occlusion = (float(ntheta * nphi) - occlusion) / float(ntheta * nphi);
|
||||
return vec3(occlusion, occlusion, occlusion);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
sphere[0].center = vec3(-2.0, 0.0, -3.5);
|
||||
sphere[0].radius = 0.5;
|
||||
sphere[1].center = vec3(-0.5, 0.0, -3.0);
|
||||
sphere[1].radius = 0.5;
|
||||
sphere[2].center = vec3(1.0, 0.0, -2.2);
|
||||
sphere[2].radius = 0.5;
|
||||
plane.p = vec3(0,-0.5, 0);
|
||||
plane.n = vec3(0, 1.0, 0);
|
||||
|
||||
Intersection i;
|
||||
i.hit = 0;
|
||||
i.t = 1.0e+30;
|
||||
i.n = i.p = vec3(0, 0, 0);
|
||||
|
||||
Ray r;
|
||||
r.org = org;
|
||||
r.dir = normalize(dir);
|
||||
seed = int(mod(dir.x * dir.y * 4525434.0, 65536.0));
|
||||
|
||||
vec4 col = vec4(0,0,0,0);
|
||||
Intersect(r, i);
|
||||
if (i.hit != 0)
|
||||
{
|
||||
col.rgb = computeAO(i);
|
||||
}
|
||||
|
||||
gl_FragColor = col;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// VertexProgram
|
||||
// This program is for 16:10 aspect ratio
|
||||
varying vec3 org,dir;
|
||||
void main()
|
||||
{
|
||||
gl_Position=gl_Vertex;
|
||||
org=vec3(0,0,0);
|
||||
dir=normalize(-vec3(-gl_Vertex.x*1.6,-gl_Vertex.y,1));
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
// FragmentProgram
|
||||
// based on iq/rgba 's seminar
|
||||
// "Rendering Worlds with Two Triangles with raytracing on the GPU in 4096 bytes"
|
||||
// at NVSCENE 08
|
||||
// I have watched this great seminar, I have coded the below test program. ;)
|
||||
// [http://www.rgba.org/iq/]
|
||||
|
||||
varying vec3 org,dir;
|
||||
float flr(vec3 p, float f)
|
||||
{
|
||||
return abs(f - p.y);
|
||||
}
|
||||
|
||||
float sph(vec3 p, vec4 spr)
|
||||
{
|
||||
return length(spr.xyz-p) - spr.w;
|
||||
}
|
||||
|
||||
float cly(vec3 p, vec4 cld)
|
||||
{
|
||||
return length(vec2(cld.x + 0.5 * sin(p.y + p.z * 2.0), cld.z) - p.xz) - cld.w;
|
||||
}
|
||||
|
||||
float scene(vec3 p)
|
||||
{
|
||||
float d = flr(p, -5.0);
|
||||
d = min(d, flr(p, 5.0));
|
||||
d = min(d, sph(p, vec4( 0,-2, 15, 1.5)));
|
||||
d = min(d, sph(p, vec4(-8, 0, 20, 2.0)));
|
||||
d = min(d, sph(p, vec4(-5, 4, 15, 0.5)));
|
||||
d = min(d, sph(p, vec4(-1, 3, 15, 2.0)));
|
||||
d = min(d, sph(p, vec4( 2,-3, 15, 0.5)));
|
||||
d = min(d, cly(p, vec4(10, 0, 20, 1.0)));
|
||||
d = min(d, cly(p, vec4( 4, 0, 15, 1.0)));
|
||||
d = min(d, cly(p, vec4( 0, 0, 20, 1.0)));
|
||||
d = min(d, cly(p, vec4(-2, 0, 25, 1.0)));
|
||||
d = min(d, cly(p, vec4(-6, 0, 30, 1.0)));
|
||||
d = min(d, cly(p, vec4(-12,0, 35, 1.0)));
|
||||
return d;
|
||||
}
|
||||
|
||||
vec3 getN(vec3 p)
|
||||
{
|
||||
float eps = 0.01;
|
||||
return normalize(vec3(
|
||||
scene(p+vec3(eps,0,0))-scene(p-vec3(eps,0,0)),
|
||||
scene(p+vec3(0,eps,0))-scene(p-vec3(0,eps,0)),
|
||||
scene(p+vec3(0,0,eps))-scene(p-vec3(0,0,eps))
|
||||
));
|
||||
}
|
||||
|
||||
float AO(vec3 p,vec3 n)
|
||||
{
|
||||
float dlt = 0.5;
|
||||
float oc = 0.0, d = 1.0;
|
||||
for(int i = 0; i < 6; i++)
|
||||
{
|
||||
oc += (float(i) * dlt - scene(p + n * float(i) * dlt)) / d;
|
||||
d *= 2.0;
|
||||
}
|
||||
return 1.0 - oc;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
float g,d = 0.0;
|
||||
vec3 p = org;
|
||||
for(int i = 0; i < 64; i++)
|
||||
{
|
||||
d = scene(p);
|
||||
p = p + d * dir;
|
||||
}
|
||||
if(d > 1.0)
|
||||
{
|
||||
gl_FragColor = vec4(0,0,0,1);
|
||||
return;
|
||||
}
|
||||
vec3 n = getN(p);
|
||||
float a = AO(p,n);
|
||||
vec3 s = vec3(0,0,0);
|
||||
vec3 lp[3],lc[3];
|
||||
lp[0] = vec3(-4,0,4);
|
||||
lp[1] = vec3(2,3,8);
|
||||
lp[2] = vec3(4,-2,24);
|
||||
lc[0] = vec3(1.0,0.5,0.4);
|
||||
lc[1] = vec3(0.4,0.5,1.0);
|
||||
lc[2] = vec3(0.2,1.0,0.5);
|
||||
for(int i = 0; i < 3; i++)
|
||||
{
|
||||
vec3 l,lv;
|
||||
lv = lp[i] - p;
|
||||
l = normalize(lv);
|
||||
g = length(lv);
|
||||
g = max(0.0,dot(l,n)) / g * float(10);
|
||||
s += g * lc[i];
|
||||
}
|
||||
float fg = min(1.0,20.0 / length(p - org));
|
||||
gl_FragColor = vec4(s * a,1) * fg * fg;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// VertexProgram
|
||||
|
||||
varying vec3 org,dir;
|
||||
void main()
|
||||
{
|
||||
gl_Position=gl_Vertex;
|
||||
org=vec3(0,0,0);
|
||||
dir=normalize(vec3(gl_Vertex.x*1.6,gl_Vertex.y,2));
|
||||
}
|
||||
10
hgplus/ShaderMinifier/tests/real/gfx monitor/gradation.fs
Normal file
10
hgplus/ShaderMinifier/tests/real/gfx monitor/gradation.fs
Normal file
@@ -0,0 +1,10 @@
|
||||
// FragmentProgram
|
||||
|
||||
varying vec4 p;
|
||||
|
||||
void main()
|
||||
{
|
||||
float g = p.y * 0.5 + 0.5;
|
||||
gl_FragColor = vec4(g,g,g,0);
|
||||
return;
|
||||
}
|
||||
10
hgplus/ShaderMinifier/tests/real/gfx monitor/gradation.gs
Normal file
10
hgplus/ShaderMinifier/tests/real/gfx monitor/gradation.gs
Normal file
@@ -0,0 +1,10 @@
|
||||
// VertexProgram
|
||||
|
||||
varying vec4 p;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = gl_Vertex;
|
||||
p = gl_Vertex;
|
||||
}
|
||||
|
||||
191
hgplus/ShaderMinifier/tests/real/gfx monitor/raytrace.fs
Normal file
191
hgplus/ShaderMinifier/tests/real/gfx monitor/raytrace.fs
Normal file
@@ -0,0 +1,191 @@
|
||||
// FragmentProgram
|
||||
|
||||
const int raytraceDepth = 8;
|
||||
|
||||
varying vec3 org,dir;
|
||||
|
||||
struct Ray
|
||||
{
|
||||
vec3 org;
|
||||
vec3 dir;
|
||||
};
|
||||
struct Sphere
|
||||
{
|
||||
vec3 c;
|
||||
float r;
|
||||
vec3 col;
|
||||
};
|
||||
struct Plane
|
||||
{
|
||||
vec3 p;
|
||||
vec3 n;
|
||||
vec3 col;
|
||||
};
|
||||
|
||||
struct Intersection
|
||||
{
|
||||
float t;
|
||||
vec3 p; // hit point
|
||||
vec3 n; // normal
|
||||
int hit;
|
||||
vec3 col;
|
||||
};
|
||||
|
||||
void shpere_intersect(Sphere s, Ray ray, inout Intersection isect)
|
||||
{
|
||||
// rs = ray.org - sphere.c
|
||||
vec3 rs = ray.org - s.c;
|
||||
float B = dot(rs, ray.dir);
|
||||
float C = dot(rs, rs) - (s.r * s.r);
|
||||
float D = B * B - C;
|
||||
|
||||
if (D > 0.0)
|
||||
{
|
||||
float t = -B - sqrt(D);
|
||||
if ( (t > 0.0) && (t < isect.t) )
|
||||
{
|
||||
isect.t = t;
|
||||
isect.hit = 1;
|
||||
|
||||
// calculate normal.
|
||||
vec3 p = vec3(ray.org.x + ray.dir.x * t,
|
||||
ray.org.y + ray.dir.y * t,
|
||||
ray.org.z + ray.dir.z * t);
|
||||
vec3 n = p - s.c;
|
||||
n = normalize(n);
|
||||
isect.n = n;
|
||||
isect.p = p;
|
||||
isect.col = s.col;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void plane_intersect(Plane pl, Ray ray, inout Intersection isect)
|
||||
{
|
||||
// d = -(p . n)
|
||||
// t = -(ray.org . n + d) / (ray.dir . n)
|
||||
float d = -dot(pl.p, pl.n);
|
||||
float v = dot(ray.dir, pl.n);
|
||||
|
||||
if (abs(v) < 1.0e-6)
|
||||
return; // the plane is parallel to the ray.
|
||||
|
||||
float t = -(dot(ray.org, pl.n) + d) / v;
|
||||
|
||||
if ( (t > 0.0) && (t < isect.t) )
|
||||
{
|
||||
isect.hit = 1;
|
||||
isect.t = t;
|
||||
isect.n = pl.n;
|
||||
|
||||
vec3 p = vec3(ray.org.x + t * ray.dir.x,
|
||||
ray.org.y + t * ray.dir.y,
|
||||
ray.org.z + t * ray.dir.z);
|
||||
isect.p = p;
|
||||
float offset = 0.2;
|
||||
vec3 dp = p + offset;
|
||||
if ((mod(dp.x, 1.0) > 0.5 && mod(dp.z, 1.0) > 0.5)
|
||||
|| (mod(dp.x, 1.0) < 0.5 && mod(dp.z, 1.0) < 0.5))
|
||||
isect.col = pl.col;
|
||||
else
|
||||
isect.col = pl.col * 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
Sphere sphere[3];
|
||||
Plane plane;
|
||||
void Intersect(Ray r, inout Intersection i)
|
||||
{
|
||||
for (int c = 0; c < 3; c++)
|
||||
{
|
||||
shpere_intersect(sphere[c], r, i);
|
||||
}
|
||||
plane_intersect(plane, r, i);
|
||||
}
|
||||
|
||||
int seed = 0;
|
||||
float random()
|
||||
{
|
||||
seed = int(mod(float(seed)*1364.0+626.0, 509.0));
|
||||
return float(seed)/509.0;
|
||||
}
|
||||
vec3 computeLightShadow(in Intersection isect)
|
||||
{
|
||||
int i, j;
|
||||
int ntheta = 16;
|
||||
int nphi = 16;
|
||||
float eps = 0.0001;
|
||||
|
||||
// Slightly move ray org towards ray dir to avoid numerical probrem.
|
||||
vec3 p = vec3(isect.p.x + eps * isect.n.x,
|
||||
isect.p.y + eps * isect.n.y,
|
||||
isect.p.z + eps * isect.n.z);
|
||||
|
||||
vec3 lightPoint = vec3(5,5,5);
|
||||
Ray ray;
|
||||
ray.org = p;
|
||||
ray.dir = normalize(lightPoint - p);
|
||||
|
||||
Intersection lisect;
|
||||
lisect.hit = 0;
|
||||
lisect.t = 1.0e+30;
|
||||
lisect.n = lisect.p = lisect.col = vec3(0, 0, 0);
|
||||
Intersect(ray, lisect);
|
||||
if (lisect.hit != 0)
|
||||
return vec3(0.0,0.0,0.0);
|
||||
else
|
||||
{
|
||||
float shade = max(0.0, dot(isect.n, ray.dir));
|
||||
shade = pow(shade,3.0) + shade * 0.5;
|
||||
return vec3(shade,shade,shade);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
sphere[0].c = vec3(-2.0, 0.0, -3.5);
|
||||
sphere[0].r = 0.5;
|
||||
sphere[0].col = vec3(1,0.3,0.3);
|
||||
sphere[1].c = vec3(-0.5, 0.0, -3.0);
|
||||
sphere[1].r = 0.5;
|
||||
sphere[1].col = vec3(0.3,1,0.3);
|
||||
sphere[2].c = vec3(1.0, 0.0, -2.2);
|
||||
sphere[2].r = 0.5;
|
||||
sphere[2].col = vec3(0.3,0.3,1);
|
||||
plane.p = vec3(0,-0.5, 0);
|
||||
plane.n = vec3(0, 1.0, 0);
|
||||
plane.col = vec3(1,1, 1);
|
||||
seed = int(mod(dir.x * dir.y * 4525434.0, 65536.0));
|
||||
|
||||
Ray r;
|
||||
r.org = org;
|
||||
r.dir = normalize(dir);
|
||||
vec4 col = vec4(0,0,0,1);
|
||||
float eps = 0.0001;
|
||||
vec3 bcol = vec3(1,1,1);
|
||||
for (int j = 0; j < raytraceDepth; j++)
|
||||
{
|
||||
Intersection i;
|
||||
i.hit = 0;
|
||||
i.t = 1.0e+30;
|
||||
i.n = i.p = i.col = vec3(0, 0, 0);
|
||||
|
||||
Intersect(r, i);
|
||||
if (i.hit != 0)
|
||||
{
|
||||
col.rgb += bcol * i.col * computeLightShadow(i);
|
||||
bcol *= i.col;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
r.org = vec3(i.p.x + eps * i.n.x,
|
||||
i.p.y + eps * i.n.y,
|
||||
i.p.z + eps * i.n.z);
|
||||
r.dir = reflect(r.dir, vec3(i.n.x, i.n.y, i.n.z));
|
||||
}
|
||||
gl_FragColor = col;
|
||||
}
|
||||
10
hgplus/ShaderMinifier/tests/real/gfx monitor/raytrace.vs
Normal file
10
hgplus/ShaderMinifier/tests/real/gfx monitor/raytrace.vs
Normal file
@@ -0,0 +1,10 @@
|
||||
// VertexProgram
|
||||
// This program is 16:10 ratio
|
||||
|
||||
varying vec3 org,dir;
|
||||
void main()
|
||||
{
|
||||
gl_Position=gl_Vertex;
|
||||
org=vec3(0,0,0);
|
||||
dir=normalize(-vec3(-gl_Vertex.x*1.6,-gl_Vertex.y,1));
|
||||
}
|
||||
27
hgplus/ShaderMinifier/tests/real/heart.frag
Normal file
27
hgplus/ShaderMinifier/tests/real/heart.frag
Normal file
@@ -0,0 +1,27 @@
|
||||
uniform float time;
|
||||
uniform vec2 resolution;
|
||||
uniform vec4 mouse;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 p = (2.0*gl_FragCoord.xy-resolution)/resolution.y;
|
||||
|
||||
// animate
|
||||
float tt = mod(time,2.0)/2.0;
|
||||
float ss = pow(tt,.2)*0.5 + 0.5;
|
||||
ss -= ss*0.2*sin(tt*6.2831*5.0)*exp(-tt*6.0);
|
||||
p *= vec2(0.5,1.5) + ss*vec2(0.5,-0.5);
|
||||
|
||||
|
||||
float a = atan(p.x,p.y)/3.141593;
|
||||
float r = length(p);
|
||||
|
||||
// shape
|
||||
float h = abs(a);
|
||||
float d = (13.0*h - 22.0*h*h + 10.0*h*h*h)/(6.0-5.0*h);
|
||||
|
||||
// color
|
||||
float f = step(r,d)*pow(1.0-r/d,0.25);
|
||||
|
||||
gl_FragColor = vec4(f,0.0,0.0,1.0);
|
||||
}
|
||||
25
hgplus/ShaderMinifier/tests/real/julia.frag
Normal file
25
hgplus/ShaderMinifier/tests/real/julia.frag
Normal file
@@ -0,0 +1,25 @@
|
||||
uniform vec2 resolution;
|
||||
uniform float time;
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform sampler2D tex2;
|
||||
uniform sampler2D tex3;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
|
||||
vec2 cc = vec2( cos(.25*time), sin(.25*time*1.423) );
|
||||
|
||||
float dmin = 1000.0;
|
||||
vec2 z = p*vec2(1.33,1.0);
|
||||
for( int i=0; i<64; i++ )
|
||||
{
|
||||
z = cc + vec2( z.x*z.x - z.y*z.y, 2.0*z.x*z.y );
|
||||
float m2 = dot(z,z);
|
||||
if( m2>100.0 ) break;
|
||||
dmin=min(dmin,m2);
|
||||
}
|
||||
|
||||
float color = sqrt(sqrt(dmin))*0.7;
|
||||
gl_FragColor = vec4(color,color,color,1.0);
|
||||
}
|
||||
24
hgplus/ShaderMinifier/tests/real/kaleidoscope.frag
Normal file
24
hgplus/ShaderMinifier/tests/real/kaleidoscope.frag
Normal file
@@ -0,0 +1,24 @@
|
||||
uniform vec2 resolution;
|
||||
uniform float time;
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform sampler2D tex2;
|
||||
uniform sampler2D tex3;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
|
||||
vec2 uv;
|
||||
|
||||
float a = atan(p.y,p.x);
|
||||
float r = sqrt(dot(p,p));
|
||||
|
||||
uv.x = 7.0*a/3.1416;
|
||||
uv.y = -time+ sin(7.0*r+time) + .7*cos(time+7.0*a);
|
||||
|
||||
float w = .5+.5*(sin(time+7.0*r)+ .7*cos(time+7.0*a));
|
||||
|
||||
vec3 col = texture2D(tex0,uv*.5).xyz;
|
||||
|
||||
gl_FragColor = vec4(col*w,1.0);
|
||||
}
|
||||
293
hgplus/ShaderMinifier/tests/real/kinder_painter.frag
Normal file
293
hgplus/ShaderMinifier/tests/real/kinder_painter.frag
Normal file
@@ -0,0 +1,293 @@
|
||||
uniform vec2 resolution;
|
||||
uniform float time;
|
||||
uniform vec4 mouse;
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform sampler2D tex2;
|
||||
uniform sampler2D tex3;
|
||||
|
||||
vec4 fpar00[6];
|
||||
vec4 fpar01[6];
|
||||
|
||||
|
||||
float cylinder( in vec4 sph, in vec3 ro, in vec3 rd )
|
||||
{
|
||||
vec3 d = ro - sph.xyz;
|
||||
float a = dot( rd.xz, rd.xz );
|
||||
float b = dot( rd.xz, d.xz );
|
||||
float c = dot( d.xz, d.xz ) - sph.w*sph.w;
|
||||
float t;
|
||||
|
||||
t = b*b - a*c;
|
||||
if( t>0.0 )
|
||||
{
|
||||
t = -(b+sqrt( t ))/a;
|
||||
}
|
||||
|
||||
return t-.001;
|
||||
|
||||
}
|
||||
|
||||
|
||||
float esfera( in vec4 sph, in vec3 ro, in vec3 rd )
|
||||
{
|
||||
vec3 d = ro - sph.xyz;
|
||||
float b = dot( rd, d );
|
||||
float c = dot( d, d ) - sph.w*sph.w;
|
||||
float t = b*b - c;
|
||||
|
||||
if( t>0.0 )
|
||||
{
|
||||
t = -b - sqrt( t );
|
||||
}
|
||||
|
||||
return t-.001;
|
||||
}
|
||||
|
||||
|
||||
bool esfera2( in vec4 sph, in vec3 ro, in vec3 rd, in float tmin )
|
||||
{
|
||||
vec3 d = ro - sph.xyz;
|
||||
float b = dot( rd, d );
|
||||
float c = dot( d, d ) - sph.w*sph.w;
|
||||
|
||||
float t = b*b - c;
|
||||
bool r = false;
|
||||
|
||||
if( t>0.0 )
|
||||
{
|
||||
t = -b - sqrt( t );
|
||||
r = (t>0.0) && (t<tmin);
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
bool cylinder2( in vec4 sph, in vec3 ro, in vec3 rd, in float tmin )
|
||||
{
|
||||
vec3 d = ro - sph.xyz;
|
||||
float a = dot( rd.xz, rd.xz );
|
||||
float b = dot( rd.xz, d.xz );
|
||||
float c = dot( d.xz, d.xz ) - sph.w*sph.w;
|
||||
float t = b*b - a*c;
|
||||
bool r = false;
|
||||
if( t>0.0 )
|
||||
{
|
||||
t = -(b+sqrt(t));
|
||||
r = (t>0.0) && (t<(tmin*a));
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
float plane( in vec4 pla, in vec3 ro, in vec3 rd )
|
||||
{
|
||||
float de = dot(pla.xyz, rd);
|
||||
de = sign(de)*max( abs(de), 0.001);
|
||||
float t = -(dot(pla.xyz, ro) + pla.w)/de;
|
||||
return t-.001;
|
||||
}
|
||||
|
||||
|
||||
vec3 calcnor( in vec4 obj, in vec4 col, in vec3 inter, out vec2 uv )
|
||||
{
|
||||
vec3 nor;
|
||||
if( col.w>2.5 )
|
||||
{
|
||||
nor.xz = inter.xz - obj.xz;
|
||||
nor.y = 0.0;
|
||||
nor = nor/obj.w;
|
||||
//uv = vec2( atan(nor.x,nor.z)/3.14159, inter.y );
|
||||
uv = vec2( nor.x, inter.y );
|
||||
}
|
||||
else if( col.w>1.5 )
|
||||
{
|
||||
nor = obj.xyz;
|
||||
uv = inter.xz*.2;
|
||||
}
|
||||
else
|
||||
{
|
||||
nor = inter - obj.xyz;
|
||||
nor = nor/obj.w;
|
||||
uv = nor.xy;
|
||||
}
|
||||
|
||||
return nor;
|
||||
}
|
||||
|
||||
vec4 cmov( in vec4 a, in vec4 b, in bool cond )
|
||||
{
|
||||
return cond?b:a;
|
||||
}
|
||||
|
||||
float cmov( in float a, in float b, in bool cond )
|
||||
{
|
||||
return cond?b:a;
|
||||
}
|
||||
|
||||
int cmov( in int a, in int b, in bool cond )
|
||||
{
|
||||
return cond?b:a;
|
||||
}
|
||||
|
||||
float intersect( in vec3 ro, in vec3 rd, out vec4 obj, out vec4 col )
|
||||
{
|
||||
float tmin = 10000.0;
|
||||
float t;
|
||||
|
||||
col.w = -1.0;
|
||||
|
||||
bool isok;
|
||||
|
||||
t = esfera( fpar00[0], ro, rd );
|
||||
isok = (t>0.0) && (t<tmin);
|
||||
obj = cmov( obj, fpar00[0], isok );
|
||||
col = cmov( col, fpar01[0], isok );
|
||||
tmin = cmov( tmin, t, isok );
|
||||
|
||||
t = esfera( fpar00[1], ro, rd );
|
||||
isok = (t>0.0) && (t<tmin);
|
||||
obj = cmov( obj, fpar00[1], isok );
|
||||
col = cmov( col, fpar01[1], isok );
|
||||
tmin = cmov( tmin, t, isok );
|
||||
|
||||
t = cylinder( fpar00[2], ro, rd );
|
||||
isok = ( t>0.0 && t<tmin );
|
||||
obj = cmov( obj, fpar00[2], isok );
|
||||
col = cmov( col, fpar01[2], isok );
|
||||
tmin = cmov( tmin, t, isok );
|
||||
|
||||
t = cylinder( fpar00[3], ro, rd );
|
||||
isok = ( t>0.0 && t<tmin );
|
||||
obj = cmov( obj, fpar00[3], isok );
|
||||
col = cmov( col, fpar01[3], isok );
|
||||
tmin = cmov( tmin, t, isok );
|
||||
|
||||
t = plane( fpar00[4], ro, rd );
|
||||
isok = ( t>0.0 && t<tmin );
|
||||
obj = cmov( obj, fpar00[4], isok );
|
||||
col = cmov( col, fpar01[4], isok );
|
||||
tmin = cmov( tmin, t, isok );
|
||||
|
||||
t = plane( fpar00[5], ro, rd );
|
||||
isok = ( t>0.0 && t<tmin );
|
||||
obj = cmov( obj, fpar00[5], isok );
|
||||
col = cmov( col, fpar01[5], isok );
|
||||
tmin = cmov( tmin, t, isok );
|
||||
|
||||
return tmin;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool intersectShadow( in vec3 ro, in vec3 rd, in float l )
|
||||
{
|
||||
float t;
|
||||
|
||||
bvec4 sss;
|
||||
|
||||
sss.x = esfera2( fpar00[0], ro, rd, l );
|
||||
sss.y = esfera2( fpar00[1], ro, rd, l );
|
||||
sss.z = cylinder2( fpar00[2], ro, rd, l );
|
||||
sss.w = cylinder2( fpar00[3], ro, rd, l );
|
||||
|
||||
return any(sss);
|
||||
}
|
||||
|
||||
|
||||
vec4 basicShade( in vec3 inter, in vec4 obj, in vec4 col, in vec3 rd, in vec4 luz, out vec4 ref )
|
||||
{
|
||||
vec3 nor;
|
||||
float dif, spe;
|
||||
vec2 uv;
|
||||
|
||||
|
||||
nor = calcnor( obj, col, inter, uv );
|
||||
|
||||
|
||||
dif = dot( nor, luz.xyz );
|
||||
ref.xyz = reflect( rd, nor );
|
||||
spe = dot( ref.xyz, luz.xyz );
|
||||
spe = max( spe, 0.0 );
|
||||
spe = spe*spe;
|
||||
spe = spe*spe;
|
||||
|
||||
if( intersectShadow( inter, luz.xyz, luz.w ) )
|
||||
{
|
||||
dif = 0.0;
|
||||
}
|
||||
|
||||
|
||||
col *= texture2D( tex0, uv );
|
||||
|
||||
// amb + dif + spec
|
||||
dif = max(dif,0.0);
|
||||
col = col*( vec4(.3,.34,.38,1) + .5*vec4(1.0,0.95,0.8,1.0)*dif ) + .5*spe;
|
||||
|
||||
// fresnel
|
||||
dif = dot( nor, -rd );
|
||||
ref.w = dif;
|
||||
dif = 1.0 - dif*dif;
|
||||
dif = dif*dif;
|
||||
col = col + .35*vec4( dif );
|
||||
|
||||
return( col );
|
||||
}
|
||||
|
||||
void main( void )
|
||||
{
|
||||
vec4 luz;
|
||||
vec4 obj, col;
|
||||
vec3 nor;
|
||||
vec4 ref;
|
||||
|
||||
vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
|
||||
p *= vec2(resolution.x/resolution.y,1.0);
|
||||
|
||||
fpar00[0] = vec4( 1.2*sin( 6.2831*.33*time + 0.0 ), 0.0, 1.8*sin( 6.2831*.39*time + 1.0 ), 1 );
|
||||
fpar00[1] = vec4( 1.5*sin( 6.2831*.31*time + 4.0 ), 1.0*sin( 6.2831*.29*time + 1.9), 1.8*sin( 6.2831*.29*time + 0.0 ), 1 );
|
||||
fpar00[2] = vec4( -1.2, 0.0, -0.0, 0.4 );
|
||||
fpar00[3] = vec4( 1.2, 0.0, -0.0, 0.4 );
|
||||
fpar00[4] = vec4( 0.0, 1.0, 0.0, 2.0 );
|
||||
fpar00[5] = vec4( 0.0, -1.0, 0.0, 2.0 );
|
||||
|
||||
fpar01[0] = vec4( 0.9, 0.8, 0.6, 1.0 );
|
||||
fpar01[1] = vec4( 1.0, 0.6, 0.4, 1.0 );
|
||||
fpar01[2] = vec4( 0.8, 0.6, 0.5, 3.0 );
|
||||
fpar01[3] = vec4( 0.5, 0.5, 0.7, 3.0 );
|
||||
fpar01[4] = vec4( 1.0, 0.9, 0.9, 2.0 );
|
||||
fpar01[5] = vec4( 1.0, 0.9, 0.9, 2.0 );
|
||||
|
||||
float an = .15*time - 6.2831*mouse.x/resolution.x;
|
||||
float di = 2.0+3.0*mouse.y/resolution.y;
|
||||
vec2 sc = vec2(cos(an),sin(an));
|
||||
vec3 rd = normalize(vec3(p.x*sc.x-sc.y,p.y,sc.x+p.x*sc.y));
|
||||
vec3 ro = vec3(di*sc.y,0.0,-di*sc.x);
|
||||
|
||||
float tmin = intersect( ro, rd, obj, col );
|
||||
|
||||
vec3 inter = ro + rd*tmin;
|
||||
|
||||
luz.xyz = vec3(0.0,1.5,-3.0)-inter;
|
||||
luz.w = length( luz.xyz );
|
||||
luz.xyz = luz.xyz/luz.w;
|
||||
|
||||
col = basicShade( inter, obj, col, rd, luz, ref );
|
||||
|
||||
vec4 col2;
|
||||
vec4 ref2;
|
||||
tmin = intersect( inter, ref.xyz, obj, col2 );
|
||||
inter = inter + ref.xyz*tmin;
|
||||
luz.xyz = vec3(0.0,1.5,-1.0)-inter;
|
||||
luz.w = length( luz.xyz );
|
||||
luz.xyz = luz.xyz/luz.w;
|
||||
col2 = basicShade( inter, obj, col2, ref.xyz, luz, ref2 );
|
||||
|
||||
col = mix( col, col2, .5-.5*ref.w );
|
||||
|
||||
gl_FragColor = col;
|
||||
}
|
||||
182
hgplus/ShaderMinifier/tests/real/leizex.frag
Normal file
182
hgplus/ShaderMinifier/tests/real/leizex.frag
Normal file
@@ -0,0 +1,182 @@
|
||||
#extension GL_EXT_gpu_shader4: enable
|
||||
|
||||
uniform vec2 resolution;
|
||||
uniform float time;
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform sampler2D tex2;
|
||||
uniform sampler2D tex3;
|
||||
|
||||
float coolfFunc3d2( int n )
|
||||
{
|
||||
n = (n << 13) ^ n;
|
||||
n = (n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff;
|
||||
return float(n);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
float noise3f( in vec3 x, int sem )
|
||||
{
|
||||
ivec3 ip = ivec3(floor(x));
|
||||
vec3 f = fract(x);
|
||||
|
||||
f = f*f*(3.0-2.0*f);
|
||||
//f = f*f*f*(f*(f*6.0-15.0)+10.0);
|
||||
|
||||
int n = ip.x + ip.y * 57 + 113*ip.z + sem;
|
||||
|
||||
float res = mix(mix(mix( coolfFunc3d2(n+(0+57*0+113*0)), coolfFunc3d2(n+(1+57*0+113*0)),f.x),
|
||||
mix( coolfFunc3d2(n+(0+57*1+113*0)), coolfFunc3d2(n+(1+57*1+113*0)),f.x),f.y),
|
||||
mix(mix( coolfFunc3d2(n+(0+57*0+113*1)), coolfFunc3d2(n+(1+57*0+113*1)),f.x),
|
||||
mix( coolfFunc3d2(n+(0+57*1+113*1)), coolfFunc3d2(n+(1+57*1+113*1)),f.x),f.y),f.z);
|
||||
return 1.0 - res*(1.0/1073741824.0);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
vec2 celular( in vec3 x )
|
||||
{
|
||||
ivec3 ip = ivec3(floor(x));
|
||||
vec3 f = fract(x);
|
||||
|
||||
vec2 dmin = vec2( 1.0, 1.0 );
|
||||
|
||||
for( int k=-1; k<=1; k++ )
|
||||
for( int j=-1; j<=1; j++ )
|
||||
for( int i=-1; i<=1; i++ )
|
||||
{
|
||||
int nn = (ip.x+i) + 57*(ip.y+j) + 113*(ip.z+k);
|
||||
|
||||
vec3 di = vec3(float(i),float(j),float(k)) - f + vec3(coolfFunc3d2(nn), coolfFunc3d2(nn+1217), coolfFunc3d2(nn+2513))/2147483647.0;
|
||||
|
||||
float d2 = dot(di,di);
|
||||
|
||||
if( d2<dmin.x )
|
||||
{
|
||||
dmin.y = dmin.x;
|
||||
dmin.x = d2;
|
||||
}
|
||||
else if( d2<dmin.y )
|
||||
{
|
||||
dmin.y = d2;
|
||||
}
|
||||
}
|
||||
return 0.25*sqrt(dmin);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
float fbm( in vec3 x )
|
||||
{
|
||||
return 0.5000*noise3f( x*1.0, 0 ) +
|
||||
0.2500*noise3f( x*2.0, 0 ) +
|
||||
0.1250*noise3f( x*4.0, 0 ) +
|
||||
0.0625*noise3f( x*8.0, 0 );
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
float map( in vec3 x, out float ao )
|
||||
{
|
||||
vec3 d = mod( vec3(1024.0)+x, 1.0 ) - 0.5;
|
||||
|
||||
float dis = sqrt( dot(d,d) ) - 0.3*0.3;
|
||||
|
||||
float disp = noise3f( 4.0*x, 0 );
|
||||
dis += 0.8*disp;
|
||||
ao = clamp(-1.5*disp, 0.0, 1.0);
|
||||
|
||||
vec2 cel = celular( 16.0*x );
|
||||
float disp2 = clamp(cel[1] - cel[0], 0.0, 1.0);
|
||||
dis -= disp2;
|
||||
ao *= clamp(disp2*12.0, 0.0, 1.0);
|
||||
|
||||
return dis;
|
||||
}
|
||||
|
||||
|
||||
vec3 calcNormal( in vec3 pos )
|
||||
{
|
||||
float kk;
|
||||
float eps = 0.0002;
|
||||
vec3 nor = vec3( map( pos+vec3(eps,0.0,0.0), kk ) - map( pos-vec3(eps,0.0,0.0), kk ),
|
||||
map( pos+vec3(0.0,eps,0.0), kk ) - map( pos-vec3(0.0,eps,0.0), kk ),
|
||||
map( pos+vec3(0.0,0.0,eps), kk ) - map( pos-vec3(0.0,0.0,eps), kk ) );
|
||||
return normalize( nor );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void generateRay( out vec3 rayDir, out vec3 rayPos, in vec2 p, float ftime )
|
||||
{
|
||||
vec2 s = p;
|
||||
|
||||
float r2 = s.x*s.x*0.32 + s.y*s.y;
|
||||
vec2 d = s*(7.0-sqrt(37.5-11.5*r2))/(r2+1.0);
|
||||
|
||||
vec3 rayTar = vec3( 0.0, 1.5, 2.0 );
|
||||
|
||||
rayPos = rayTar + vec3( -sin(6.2831853*ftime/20.0), 0.75*cos(6.2831853*ftime/20.0+0.5), -cos(6.2831853*ftime/20.0) );
|
||||
|
||||
rayTar += 0.075*vec3( noise3f( vec3(2.0*ftime,0.0,0.5),0), noise3f( vec3(2.0*ftime,0.1,0.4),7), noise3f( vec3(2.0*ftime,0.2,0.3),9) );
|
||||
|
||||
float roll = 0.1*noise3f( vec3(2.0*ftime,0.0,0.0), 13 );
|
||||
|
||||
vec3 up = vec3( 0.0, cos(roll), sin(roll) );
|
||||
|
||||
vec3 dd = normalize( rayTar - rayPos );
|
||||
vec3 rr = normalize( cross( dd, up ) );
|
||||
vec3 uu = normalize( cross( rr, dd ) );
|
||||
|
||||
rayDir = normalize( d.x*rr + d.y*uu + dd );
|
||||
}
|
||||
|
||||
vec3 addbump( in vec3 nor, float bumpa, in vec3 x )
|
||||
{
|
||||
float ke = 0.0005;
|
||||
float kk = fbm( 256.0*x );
|
||||
vec3 xnor = vec3( fbm(256.0*(x+vec3(ke,0.0,0.0)))-kk,
|
||||
fbm(256.0*(x+vec3(0.0,ke,0.0)))-kk,
|
||||
fbm(256.0*(x+vec3(0.0,0.0,ke)))-kk );
|
||||
return normalize( nor + bumpa*xnor );
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
|
||||
|
||||
// genearete ray
|
||||
vec3 ro, rd;
|
||||
generateRay( rd, ro, p, time );
|
||||
|
||||
// ray march scene
|
||||
float t, ao; vec3 nor, pos;
|
||||
for( t=0.1; t<5.0; )
|
||||
{
|
||||
pos = ro + t*rd;
|
||||
float h = map( pos, ao );
|
||||
if( h<0.001 ) break;
|
||||
t += h*0.12;
|
||||
}
|
||||
nor = calcNormal( pos );
|
||||
|
||||
// shade
|
||||
vec3 col = vec3( 1.0 + 0.5*fbm( 96.0*pos ) );
|
||||
vec3 xnor = addbump( nor, 1.0, 0.25*pos );
|
||||
vec3 lig = vec3( 0.80, 0.50, -0.10 );
|
||||
float dif = clamp(dot( xnor, lig ), 0.0, 1.0);
|
||||
vec3 ref = vec3(0.50,0.55,0.60) + vec3(0.6,0.5,0.3)*dif*3.0;
|
||||
col = col*ref*ao;
|
||||
|
||||
// fog
|
||||
col = col/(1.0+t) + vec3(1.06, 1.14, 1.0) * (1.0-exp2(-0.25*t));
|
||||
|
||||
// contrast
|
||||
col = (col*col+col)*.5;
|
||||
// tint
|
||||
col = clamp( col*vec3(1.0,1.2,1.0), 0.0, 1.0 );
|
||||
// vigneting
|
||||
col *= 0.5 + 0.5*(1.0-p.x)*(1.0+p.x);
|
||||
|
||||
gl_FragColor = vec4(col,1.0);
|
||||
}
|
||||
391
hgplus/ShaderMinifier/tests/real/lunaquatic.frag
Normal file
391
hgplus/ShaderMinifier/tests/real/lunaquatic.frag
Normal file
@@ -0,0 +1,391 @@
|
||||
// Lunaquatic
|
||||
// This source is released exclusively for ShaderToy by rgba, for educational purposes only.
|
||||
// Feel free to be inspired by this code and play around with it. If you make a production with the help
|
||||
// of this code, it would be polite to greet our group in the intro or in the NFO file.
|
||||
// Have fun! - xTr1m / BluFlame
|
||||
|
||||
#extension GL_EXT_gpu_shader4: enable
|
||||
|
||||
// .xy = pixel position
|
||||
// .z = time
|
||||
vec4 Y;
|
||||
uniform vec2 resolution;
|
||||
uniform float time;
|
||||
|
||||
|
||||
// All data of our world
|
||||
vec4 artifactPos;
|
||||
vec3 lightPos, lightDir, ro, rd;
|
||||
float FAR, EXPLOSIONTIME, pi, eps=0.0001;
|
||||
|
||||
float saturate(float x) { return clamp(x,0.0,1.0); }
|
||||
float ftime(float t, float s, float e) { return (t-s)/(e-s); }
|
||||
|
||||
vec3 rotateY(vec3 v, float x)
|
||||
{
|
||||
return vec3(
|
||||
cos(x)*v.x - sin(x)*v.z,
|
||||
v.y,
|
||||
sin(x)*v.x + cos(x)*v.z
|
||||
);
|
||||
}
|
||||
|
||||
vec3 rotateX(vec3 v, float x)
|
||||
{
|
||||
return vec3(
|
||||
v.x,
|
||||
v.y*cos(x) - v.z*sin(x),
|
||||
v.y*sin(x) + v.z*cos(x)
|
||||
);
|
||||
}
|
||||
|
||||
// Pseudo random number base generator (credits go to iq/rgba)
|
||||
float rnd(vec2 x)
|
||||
{
|
||||
int n = int(x.x * 40.0 + x.y * 6400.0);
|
||||
n = (n << 13) ^ n;
|
||||
return 1.0 - float( (n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0;
|
||||
}
|
||||
|
||||
// Convert the cipher range from [-1,1] to [0,1]
|
||||
float norm(float x)
|
||||
{
|
||||
return x * 0.5 + 0.5;
|
||||
}
|
||||
|
||||
// Generate animated (t) caustic values
|
||||
float caustic(float u, float v, float t)
|
||||
{
|
||||
return pow((
|
||||
norm(sin(pi * 2.0 * (u + v + Y.z*t))) +
|
||||
norm(sin(pi * (v - u - Y.z*t))) +
|
||||
norm(sin(pi * (v + Y.z*t))) +
|
||||
norm(sin(pi * 3.0 * (u - Y.z*t)))) * 0.3, 2.0);
|
||||
}
|
||||
|
||||
// Generate cubic interpolated random values
|
||||
float smoothrnd(vec2 x)
|
||||
{
|
||||
x = mod(x,1000.0);
|
||||
vec2 a = fract(x);
|
||||
x -= a;
|
||||
vec2 u = a*a*(3.0-2.0*a);
|
||||
return mix(
|
||||
mix(rnd(x+vec2(0.0)),rnd(x+vec2(1.0,0.0)), u.x),
|
||||
mix(rnd(x+vec2(0.0,1.0)),rnd(x+vec2(1.0)), u.x), u.y);
|
||||
}
|
||||
|
||||
float height(vec2 x)
|
||||
{
|
||||
float maxV = Y.z - EXPLOSIONTIME;
|
||||
float l = mix(1., max(0., artifactPos.w - artifactPos.y), 1.0 - ((maxV > 0.0 && length(x - artifactPos.xz) < maxV) ? 1.0 : 0.0)) /
|
||||
pow(1./max(0., 1.0-length(artifactPos.xz-x)*0.8), 2.0);
|
||||
x += length(x-ro.xy);
|
||||
x *= min(length(x-ro.xy)*5.0, 4.0);
|
||||
|
||||
return caustic(x.x+Y.z*0.75, x.y*0.5, 0.3) * 0.006 +
|
||||
caustic(x.x*0.1+Y.z*0.2, x.y*0.1, 0.02) * 0.125 -
|
||||
0.15 - l*2.0;
|
||||
}
|
||||
|
||||
// Calculates the water "waves". To reduce the bumpiness, increment the y-axis
|
||||
vec3 getWaterNormal(vec3 p)
|
||||
{
|
||||
return normalize(vec3(
|
||||
caustic(p.x * 160.0 - 12.0 * cos(10.0 * p.z), p.z * 140.0, 4.0),
|
||||
8.0,
|
||||
caustic(p.z * 160.0 - 12.0 * sin(10.0 * p.x), p.x * 140.0, 4.0)) * 2.0 - 1.0);
|
||||
}
|
||||
|
||||
// Raymarch the terrain function, returns the distance from the ray origin to the terrain voxel
|
||||
// This function was originally adopted from an implementation by iq/rgba
|
||||
int traceTerrain(vec3 ro, vec3 rd, float maxt, out float depth)
|
||||
{
|
||||
float lh, ly, delt=0.0;
|
||||
// advance our sample position from our nearplane to our farplane
|
||||
for (float t = 0.1; t < maxt; t += delt)
|
||||
{
|
||||
// advance our ray
|
||||
ro += rd * delt;
|
||||
|
||||
// get the height at the given sample 2d (!) position (we could enhance this by sampling a voxel and returning only the distance to the voxel)
|
||||
depth = height(ro.xz);
|
||||
|
||||
if (ro.y <= depth)
|
||||
{
|
||||
// we need to know our improved (more accuracy here) real terrainposition and the old sampleposition
|
||||
// also we precalculate the traveled ray distance (its not a ray anymore if we use stuff like refraction, eg but hey lets stick to this word)
|
||||
depth = t - delt + delt*(lh-ly)/(ro.y-depth+lh-ly);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// store our last height and last sampleposition on the y-axis
|
||||
// we need this to calculate the improved terrainposition which will give us a smoother transition between our samplesteps (rd*delt)
|
||||
lh = depth;
|
||||
ly = ro.y;
|
||||
|
||||
// advance our steplength the more we travel the bigger our stepsize should be
|
||||
// with this we are able to sample finer details near to our camera
|
||||
delt = 0.002 + (t/(40.0 * clamp(rd.y+1.0,0.0,1.0))); //detail level
|
||||
}
|
||||
|
||||
// we hit nothing
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
vec3 calculateSkySub(vec3 rd)
|
||||
{
|
||||
return norm(smoothrnd(abs(rd.xy*rd.z+rd.y*2.0))) * vec3(0.15) +
|
||||
norm(smoothrnd(1.5*abs(rd.xy*rd.z+rd.y+10.0)))* vec3(0.15) +
|
||||
norm(smoothrnd(2.5*abs(rd.xy*rd.z+rd.y+20.0)))* vec3(0.15);
|
||||
}
|
||||
|
||||
|
||||
vec4 calcPlanet(vec3 ro, vec3 rd)
|
||||
{
|
||||
vec4 color = vec4(0.0);
|
||||
|
||||
vec3 planetPos = vec3(70.0, 20.0, 100.0);
|
||||
float dist = dot(rd, normalize(planetPos-ro))-0.95;
|
||||
if (dist>0.0)
|
||||
{
|
||||
dist = length(planetPos-ro)-dist*800.0;
|
||||
|
||||
vec3 p = ro+rd*dist;
|
||||
vec3 n = normalize(planetPos-p);
|
||||
vec2 uv = 0.5 + 0.5 * vec2(atan(n.z, n.x), acos(n.y)) / pi * vec2(5.0, 50.0);
|
||||
color.rgb = max(0., 0.2+dot(normalize(p-lightPos), n)) *
|
||||
(caustic(uv.x*0.5+Y.z*0.1, uv.y*0.5,0.)+0.5)*.15 * vec3(1.0,0.0,1.0);
|
||||
color.a = 1.0;
|
||||
}
|
||||
else dist = FAR*99.0;
|
||||
|
||||
// hit with plane
|
||||
vec3 pN = vec3(-0.96,0.96,-0.2);
|
||||
float t = dot(pN, planetPos-ro) / dot(pN, rd);
|
||||
if (t > 0.0 && t < dist)
|
||||
{
|
||||
float d = length(planetPos - (ro+rd*t));
|
||||
if (d > 52.0 && d < 80.0)
|
||||
color.rgb = mix(color.rgb, vec3(0.8, 0.64, 0.4), t / 200.0 * norm(sin((d-50.0)/30.0 * smoothrnd(vec2(d, 3.0)))));
|
||||
color.a = color.a < 1.0 ? 3.0 * length(color) : color.a;
|
||||
}
|
||||
|
||||
return vec4(max(vec3(0.0), color.xyz*0.3) * clamp(dot(rd, vec3(0.0,1.0,0.0))*8.0, 0., 1.0), color.a);
|
||||
}
|
||||
|
||||
vec3 calculateSky(vec3 ro, vec3 rd, int addPlanet)
|
||||
{
|
||||
// atmospheric scattering+sun
|
||||
vec3 color = max(vec3(0.0), (max(vec3(0.0), pow(dot(lightDir, rd), 6.0)) * .7 - rd.y) * mix(vec3(1.0,0.5,0.0), vec3(1.0), min(1.0, lightDir.y*1.5)) + lightDir.y * 3.0);
|
||||
|
||||
float phi = atan(rd.x, rd.z);
|
||||
float theta = acos(rd.y / length(rd));
|
||||
float coeff = smoothstep(0.0, 0.5, norm(0.5 * smoothrnd(300.0 * vec2(phi, theta))) + norm(0.75 * smoothrnd(500.0 * vec2(phi, theta))) - 1.25) * saturate(1.0-lightDir.y*5.0);
|
||||
if (addPlanet>0)
|
||||
{
|
||||
// a planet
|
||||
vec4 p = calcPlanet(ro, rd);
|
||||
color += coeff*saturate(1.0-p.a) + p.rgb;
|
||||
}
|
||||
|
||||
// the clouds
|
||||
rd.xy += ro.xy*eps;
|
||||
color += (calculateSkySub(normalize(rd + vec3(sin(Y.z*0.1),0.0,cos(Y.z*0.1)) * 0.1)*3.0) +
|
||||
calculateSkySub(normalize(rd + vec3(sin(Y.z*0.1),0.0,cos(Y.z*0.1)) * 0.2)*5.0)*0.1 +
|
||||
calculateSkySub(normalize(rd + vec3(sin(Y.z*0.1),0.0,cos(Y.z*0.1)) * 0.4)*7.0)*0.1 -
|
||||
calculateSkySub(normalize(rd + vec3(sin(Y.z*0.2),0.0,0) * 0.5))*1.5) * saturate(rd.y+0.5);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
float isoSurface(vec3 p)
|
||||
{
|
||||
float b = Y.z>80.0&&Y.z<112.0?1.0:0.0;
|
||||
p = rotateX(rotateY(rotateX(rotateY(p - artifactPos.xyz, 3.0*Y.z), 3.0*Y.z), b*sin(3.0*Y.z+3.0*p.y)), b*sin(3.0*Y.z+3.0*p.x));
|
||||
p *= 4.0 + 10.0 * max(0., Y.z - EXPLOSIONTIME);
|
||||
|
||||
return -0.4 +
|
||||
p.x*p.x*p.x*p.x*p.x*p.x*p.x*p.x +
|
||||
p.y*p.y*p.y*p.y*p.y*p.y*p.y*p.y +
|
||||
p.z*p.z*p.z*p.z*p.z*p.z*p.z*p.z;
|
||||
|
||||
}
|
||||
|
||||
float traceIso(vec3 ro, vec3 rd, float mint, float maxt, float s)
|
||||
{
|
||||
float lt, liso, exact, delt = (maxt-mint)/s;
|
||||
|
||||
for (float t = mint; t < maxt; t += delt)
|
||||
{
|
||||
vec3 p = ro + t * rd;
|
||||
float iso = isoSurface(p);
|
||||
if (iso <= 0.0)
|
||||
{
|
||||
for(int i = 0; i < 9; i++)
|
||||
{
|
||||
exact = (lt + t) / 2.0;
|
||||
if (isoSurface(ro + exact * rd) < 0.0) t = exact;
|
||||
else lt = exact;
|
||||
}
|
||||
return exact;
|
||||
}
|
||||
|
||||
lt = t;
|
||||
liso = iso;
|
||||
}
|
||||
|
||||
return FAR;
|
||||
}
|
||||
|
||||
void calcBurn(vec2 x, vec3 normal, inout vec3 color)
|
||||
{
|
||||
float gd = length(x - artifactPos.xz);
|
||||
float maxV = Y.z - EXPLOSIONTIME;
|
||||
if (maxV > 0.0 && gd < maxV)
|
||||
{
|
||||
float minV = maxV*0.9;
|
||||
if (gd < maxV-(maxV-minV))
|
||||
{
|
||||
float strength = saturate((gd-minV) / ((maxV-(maxV-minV)*2.0)-minV));
|
||||
color *= (1.0-strength*1.5);
|
||||
color += (1.0-strength*0.8) *
|
||||
pow(norm(normal.x) + norm(normal.y),
|
||||
2.0*norm(smoothrnd(0.4*Y.z+x*20.0))*
|
||||
norm(smoothrnd(10.0 +x*5.0 ))+
|
||||
1.
|
||||
) * vec3(1.5, 0.75, 0.5);
|
||||
}
|
||||
if(gd > maxV-(maxV-minV)*2.0)
|
||||
color += cos( (gd-minV) / (maxV-minV) * pi*0.5 ) * vec3(1.5, 0.75, 0.5) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
vec3 calcScene(vec3 ro, vec3 rd)
|
||||
{
|
||||
float upperPlane = (0.1-ro.y) / rd.y;
|
||||
float finalDepth = 200.0;
|
||||
vec3 color = calculateSky(ro, rd, 1);
|
||||
if (rd.y < -0.01 && traceTerrain(ro+rd*upperPlane, rd, finalDepth, finalDepth)>0) // prevent endless stuff and other funny shit
|
||||
{
|
||||
finalDepth += upperPlane;
|
||||
vec3 pos = ro+rd*finalDepth;
|
||||
vec3 normal = normalize(normalize(
|
||||
vec3(
|
||||
height(pos.xz - vec2(eps, 0.0)) - height(pos.xz + vec2(eps, 0.0)),
|
||||
eps*2.0,
|
||||
height(pos.xz - vec2(0.0, eps)) - height(pos.xz + vec2(0.0, eps))
|
||||
)
|
||||
) +
|
||||
(getWaterNormal(pos*0.2)*1.5+getWaterNormal(pos*0.1)) * max(0., 1.0-finalDepth/FAR*7.0)
|
||||
);
|
||||
|
||||
color = max(0., dot(normal, lightDir) // diffuse
|
||||
+ pow(max(0., dot(normal, normalize(lightDir-rd))), 2.0) // specular
|
||||
) *
|
||||
calculateSky(pos, reflect(rd, normal), 1);
|
||||
|
||||
// burn
|
||||
calcBurn(pos.xz, normal, color);
|
||||
|
||||
// depth fog
|
||||
color = mix( color,
|
||||
calculateSky(ro, rd, 0),
|
||||
saturate(finalDepth/FAR*1.6 + saturate(dot(normalize(normal+rd*.2), rd)))
|
||||
); // sky refl and fog
|
||||
}
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
FAR = 9.0;
|
||||
EXPLOSIONTIME = 127.0;
|
||||
pi = 3.1416;
|
||||
|
||||
|
||||
Y.xy = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
|
||||
Y.z = time;
|
||||
|
||||
rd = normalize(vec3(Y.xy - 0.5, 1.0));
|
||||
artifactPos = vec4(10.0, norm(sin(Y.z*1.0+4.0)), 13.0, 0.0);
|
||||
|
||||
ro = vec3(.0, .25, 0.);
|
||||
float t = Y.z;
|
||||
if (t < 16.0) // 1 intro
|
||||
{
|
||||
t = ftime(t,0.0,16.0);
|
||||
t = 1.0-pow(1.0-t, 2.);
|
||||
lightPos = vec3(-400.0, 100.0 - t*450.0, 1000.0);
|
||||
|
||||
t=(t-1.0)*0.7;
|
||||
rd = rotateX(rd, -t);
|
||||
}
|
||||
else if (t < 32.0) // 1 intro
|
||||
{
|
||||
t=ftime(t,16.0,32.0);
|
||||
t = 1.0-pow(1.0-t, 2.);
|
||||
lightPos = vec3(-400.0, -350.0+t*600.0, 1000.0);
|
||||
ro.y -= t*0.1;
|
||||
}
|
||||
else if (t < 40.0) // 2. wonderful flyby over the scenery
|
||||
{
|
||||
lightPos = vec3(-400.0, 250.0, 1000.0);
|
||||
ro.y -= 0.1;
|
||||
}
|
||||
else if (t < 64.0) //3. approaching the artifact
|
||||
{
|
||||
// Determine the scene we're in
|
||||
int scene = int((t-40.0)/6.0);
|
||||
if (scene >= 3)
|
||||
artifactPos.w = 1.;
|
||||
lightPos = vec3(-400.0, min(250., norm(rnd(vec2(scene, 2))) * 400.0), 1000.0);
|
||||
|
||||
// Get a random initial position for our camera
|
||||
ro.xz += vec2(0.1, 20.0) * vec2(rnd(vec2(scene, 5.0)), rnd(vec2(scene, 7.0)));
|
||||
|
||||
// Basing on the initial position, choose some "random" start and end points nearby
|
||||
ro = mix(
|
||||
ro+vec3(0.008)*abs(vec3(rnd(vec2(scene, 8.0)), 0.0, rnd(vec2(scene, 10.0)))),
|
||||
ro+vec3(.75) *abs(vec3(rnd(vec2(scene, 11.0)), 0.0, rnd(vec2(scene, 13.0)))),
|
||||
t-40.0-float(scene));
|
||||
ro.y = 0.2;
|
||||
rd = rotateY(rd, rnd(vec2(scene, 14.0))*pi);
|
||||
}
|
||||
else // 4. artifact is in the middle and 5. BOOM
|
||||
{
|
||||
artifactPos.w = 1.0;
|
||||
lightPos = vec3(-400.0, norm(sin(t+10.0)) * 250.0, 1000.0);
|
||||
float i = smoothstep(118.,120.,t);
|
||||
ro.xz = artifactPos.xz +
|
||||
mix(vec2(sin(t*0.6), cos(t*0.6))*mix(sin(t*1.5+10.0)+2.0,2.,i),
|
||||
vec2(0.0,2.0+0.75*(t - EXPLOSIONTIME)),
|
||||
smoothstep(-1.0, 1.0, t - EXPLOSIONTIME)
|
||||
);
|
||||
ro.y = mix(norm(sin(t*3.0)*(1.0-i))*0.3,
|
||||
0.0,
|
||||
smoothstep(-1.0, 1.0, t - EXPLOSIONTIME)
|
||||
) + 0.2;
|
||||
vec2 dir = normalize(artifactPos.xz-ro.xz);
|
||||
rd = rotateY(rd, atan(dir.y, dir.x)-pi/2.0);
|
||||
}
|
||||
|
||||
lightDir = normalize(lightPos-ro);
|
||||
|
||||
float dist = length(ro-artifactPos.xyz)-1.0;
|
||||
float isoDistance = artifactPos.w==1.0?traceIso(ro, rd, dist, dist+2.0, 99.0):FAR;
|
||||
if (isoDistance < FAR)
|
||||
{
|
||||
ro += isoDistance * rd;
|
||||
vec3 n = normalize(vec3(
|
||||
isoSurface(vec3(ro.x-eps, ro.y, ro.z))-isoSurface(vec3(ro.x+eps, ro.y, ro.z)),
|
||||
isoSurface(vec3(ro.x, ro.y-eps, ro.z))-isoSurface(vec3(ro.x, ro.y+eps, ro.z)),
|
||||
isoSurface(vec3(ro.x, ro.y, ro.z-eps))-isoSurface(vec3(ro.x, ro.y, ro.z+eps))));
|
||||
rd = reflect(rd, n);
|
||||
}
|
||||
|
||||
gl_FragColor = vec4(calcScene(ro, rd) * saturate(sin((Y.z/150.0)*pi)*10.0),1.0);
|
||||
}
|
||||
38
hgplus/ShaderMinifier/tests/real/mandel.frag
Normal file
38
hgplus/ShaderMinifier/tests/real/mandel.frag
Normal file
@@ -0,0 +1,38 @@
|
||||
uniform vec2 resolution;
|
||||
uniform float time;
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform sampler2D tex2;
|
||||
uniform sampler2D tex3;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
|
||||
p.x *= resolution.x/resolution.y;
|
||||
|
||||
float zoo = .62+.38*sin(.1*time);
|
||||
float coa = cos( 0.1*(1.0-zoo)*time );
|
||||
float sia = sin( 0.1*(1.0-zoo)*time );
|
||||
zoo = pow( zoo,8.0);
|
||||
vec2 xy = vec2( p.x*coa-p.y*sia, p.x*sia+p.y*coa);
|
||||
vec2 cc = vec2(-.745,.186) + xy*zoo;
|
||||
|
||||
vec2 z = vec2(0.0);
|
||||
vec2 z2 = z*z;
|
||||
float m2;
|
||||
float co = 0.0;
|
||||
for( int i=0; i<256; i++ )
|
||||
{
|
||||
z = cc + vec2( z.x*z.x - z.y*z.y, 2.0*z.x*z.y );
|
||||
m2 = dot(z,z);
|
||||
if( m2>1024.0 ) break;
|
||||
co += 1.0;
|
||||
}
|
||||
co = co + 1.0 - log2(.5*log2(m2));
|
||||
|
||||
co = sqrt(co/256.0);
|
||||
gl_FragColor = vec4( .5+.5*cos(6.2831*co+0.0),
|
||||
.5+.5*cos(6.2831*co+0.4),
|
||||
.5+.5*cos(6.2831*co+0.7),
|
||||
1.0 );
|
||||
}
|
||||
194
hgplus/ShaderMinifier/tests/real/mandelbulb.frag
Normal file
194
hgplus/ShaderMinifier/tests/real/mandelbulb.frag
Normal file
@@ -0,0 +1,194 @@
|
||||
uniform vec2 resolution;
|
||||
uniform float time;
|
||||
|
||||
bool isphere( in vec4 sph, in vec3 ro, in vec3 rd, out vec2 t )
|
||||
{
|
||||
vec3 oc = ro - sph.xyz;
|
||||
float b = dot(oc,rd);
|
||||
float c = dot(oc,oc) - sph.w*sph.w;
|
||||
|
||||
float h = b*b - c;
|
||||
if( h<0.0 )
|
||||
return false;
|
||||
|
||||
float g = sqrt( h );
|
||||
t.x = - b - g;
|
||||
t.y = - b + g;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const int NumIte = 7;
|
||||
const float Bailout = 100.0;
|
||||
|
||||
bool iterate( in vec3 q, out float resPot, out vec4 resColor )
|
||||
{
|
||||
vec4 trap = vec4(100.0);
|
||||
vec3 zz = q;
|
||||
float m = dot(zz,zz);
|
||||
if( m > Bailout )
|
||||
{
|
||||
resPot = 0.5*log(m)/pow(8.0,0.0);
|
||||
resColor = vec4(1.0);
|
||||
return false;
|
||||
}
|
||||
|
||||
for( int i=1; i<NumIte; i++ )
|
||||
{
|
||||
#if 0
|
||||
float zr = sqrt( dot(zz,zz) );
|
||||
float zo = acos( zz.y/zr );
|
||||
float zi = atan( zz.x, zz.z );
|
||||
|
||||
zr = pow( zr, 8.0 );
|
||||
zo = zo * 8.0;
|
||||
zi = zi * 8.0;
|
||||
|
||||
zz = q + zr*vec3( sin(zo)*sin(zi), cos(zo), sin(zo)*cos(zi) );
|
||||
#else
|
||||
float x = zz.x; float x2 = x*x; float x4 = x2*x2;
|
||||
float y = zz.y; float y2 = y*y; float y4 = y2*y2;
|
||||
float z = zz.z; float z2 = z*z; float z4 = z2*z2;
|
||||
|
||||
float k3 = x2 + z2;
|
||||
float k2 = inversesqrt( k3*k3*k3*k3*k3*k3*k3 );
|
||||
float k1 = x4 + y4 + z4 - 6.0*y2*z2 - 6.0*x2*y2 + 2.0*z2*x2;
|
||||
float k4 = x2 - y2 + z2;
|
||||
|
||||
zz.x = q.x + 64.0*x*y*z*(x2-z2)*k4*(x4-6.0*x2*z2+z4)*k1*k2;
|
||||
zz.y = q.y + -16.0*y2*k3*k4*k4 + k1*k1;
|
||||
zz.z = q.z + -8.0*y*k4*(x4*x4 - 28.0*x4*x2*z2 + 70.0*x4*z4 - 28.0*x2*z2*z4 + z4*z4)*k1*k2;
|
||||
#endif
|
||||
|
||||
m = dot(zz,zz);
|
||||
|
||||
trap = min( trap, vec4(zz.xyz*zz.xyz,m) );
|
||||
|
||||
if( m > Bailout )
|
||||
{
|
||||
resColor = trap;
|
||||
resPot = 0.5*log(m)/pow(8.0,float(i));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
resColor = trap;
|
||||
resPot = 0.0;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ifractal( in vec3 ro, in vec3 rd, out float rest, in float maxt, out vec3 resnor, out vec4 rescol, float fov )
|
||||
{
|
||||
vec4 sph = vec4( 0.0, 0.0, 0.0, 1.25 );
|
||||
vec2 dis;
|
||||
|
||||
// bounding sphere
|
||||
if( !isphere(sph,ro,rd,dis) )
|
||||
return false;
|
||||
|
||||
// early skip
|
||||
if( dis.y<0.001 ) return false;
|
||||
// clip to near!
|
||||
if( dis.x<0.001 )dis.x = 0.001;
|
||||
|
||||
if( dis.y>maxt) dis.y = maxt;
|
||||
|
||||
float dt;
|
||||
vec3 gra;
|
||||
vec4 color;
|
||||
|
||||
float fovfactor = 1.0/sqrt(1.0+fov*fov);
|
||||
|
||||
// raymarch!
|
||||
for( float t=dis.x; t<dis.y; )
|
||||
{
|
||||
vec3 p = ro + rd*t;
|
||||
|
||||
float Surface = clamp( 0.001*t*fovfactor, 0.000001, 0.005 );
|
||||
|
||||
float eps = Surface*0.1;
|
||||
vec4 col2;
|
||||
float pot1; if( iterate(p,pot1,color) ) { rest = t; resnor=normalize(gra); rescol = color; return true; }
|
||||
float pot2; iterate(p+vec3(eps,0.0,0.0),pot2,col2);
|
||||
float pot3; iterate(p+vec3(0.0,eps,0.0),pot3,col2);
|
||||
float pot4; iterate(p+vec3(0.0,0.0,eps),pot4,col2);
|
||||
|
||||
gra = vec3( pot2-pot1, pot3-pot1, pot4-pot1 );
|
||||
dt = 0.5*pot1*eps/length(gra);
|
||||
|
||||
if( dt<Surface )
|
||||
{
|
||||
rescol = color;
|
||||
resnor = normalize( gra );
|
||||
rest = t;
|
||||
return true;
|
||||
}
|
||||
|
||||
t+=dt;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
|
||||
vec2 s = p*vec2(1.33,1.0);
|
||||
|
||||
vec3 light1 = vec3( 0.577, 0.577, 0.577 );
|
||||
vec3 light2 = vec3( -0.707, 0.000, 0.707 );
|
||||
|
||||
float fov = 1.0;
|
||||
float r = 1.4+0.2*cos(6.28318*time/20.0);
|
||||
vec3 campos = vec3( r*sin(6.28318*time/20.0), 0.3-0.4*sin(6.28318*time/20.0), r*cos(6.28318*time/20.0) );
|
||||
vec3 camtar = vec3(0.0,0.1,0.0);
|
||||
//camera matrix
|
||||
vec3 cw = normalize(camtar-campos);
|
||||
vec3 cp = vec3(0.0,1.0,0.0);
|
||||
vec3 cu = normalize(cross(cw,cp));
|
||||
vec3 cv = normalize(cross(cu,cw));
|
||||
// ray dir
|
||||
vec3 rd = normalize( s.x*cu + s.y*cv + 1.5*cw );
|
||||
|
||||
|
||||
vec3 nor, rgb;
|
||||
vec4 col;
|
||||
float t;
|
||||
if( !ifractal(campos,rd,t,1e20,nor,col,fov) )
|
||||
{
|
||||
rgb = 1.3*vec3(1.0,.98,0.9)*(0.7+0.3*rd.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
vec3 xyz = campos + t*rd;
|
||||
|
||||
// sun light
|
||||
float dif1 = clamp( 0.2 + 0.8*dot( light1, nor ), 0.0, 1.0 ); dif1=dif1*dif1;
|
||||
// back light
|
||||
float dif2 = clamp( 0.3 + 0.7*dot( light2, nor ), 0.0, 1.0 );
|
||||
// ambient occlusion
|
||||
float ao = clamp(1.25*col.w-.4,0.0,1.0); ao=ao*ao*0.5+0.5*ao;
|
||||
// shadow
|
||||
float lt1; vec3 ln; vec4 lc;
|
||||
if( dif1>0.001 ) if( ifractal(xyz,light1,lt1,1e20,ln,lc,fov) ) dif1 = 0.1;
|
||||
|
||||
// material color
|
||||
rgb = vec3(1.0,1.0,1.0);
|
||||
rgb = mix( rgb, vec3(0.8,0.6,0.2), sqrt(col.x)*1.25 );
|
||||
rgb = mix( rgb, vec3(0.8,0.3,0.3), sqrt(col.y)*1.25 );
|
||||
rgb = mix( rgb, vec3(0.7,0.4,0.3), sqrt(col.z)*1.25 );
|
||||
|
||||
// lighting
|
||||
rgb *= (0.5+0.5*nor.y)*vec3(.14,.15,.16)*0.8 + dif1*vec3(1.0,.85,.4) + 0.5*dif2*vec3(.08,.10,.14);
|
||||
rgb *= vec3( pow(ao,0.8), pow(ao,1.00), pow(ao,1.1) );
|
||||
|
||||
// gamma
|
||||
rgb = 1.5*(rgb*0.15 + 0.85*sqrt(rgb));
|
||||
}
|
||||
|
||||
vec2 uv = p*0.5+0.5;
|
||||
rgb *= 0.7 + 0.3*16.0*uv.x*uv.y*(1.0-uv.x)*(1.0-uv.y);
|
||||
|
||||
rgb = clamp( rgb, 0.0, 1.0 );
|
||||
gl_FragColor = vec4(rgb,1.0);
|
||||
}
|
||||
43
hgplus/ShaderMinifier/tests/real/metatunnel.frag
Normal file
43
hgplus/ShaderMinifier/tests/real/metatunnel.frag
Normal file
@@ -0,0 +1,43 @@
|
||||
uniform vec2 resolution;
|
||||
uniform float time;
|
||||
|
||||
float h(vec3 q)
|
||||
{
|
||||
float f=1.*distance(q,vec3(cos(time)+sin(time*.2),.3,2.+cos(time*.5)*.5));
|
||||
f*=distance(q,vec3(-cos(time*.7),.3,2.+sin(time*.5)));
|
||||
f*=distance(q,vec3(-sin(time*.2)*.5,sin(time),2.));
|
||||
f*=cos(q.y)*cos(q.x)-.1-cos(q.z*7.+time*7.)*cos(q.x*3.)*cos(q.y*4.)*.1;
|
||||
return f;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
|
||||
vec3 o=vec3(p.x,p.y*1.25-0.3,0.);
|
||||
vec3 d=vec3(p.x+cos(time)*0.3,p.y,1.)/64.;
|
||||
vec4 c=vec4(0.);
|
||||
float t=0.;
|
||||
for(int i=0;i<75;i++)
|
||||
{
|
||||
if(h(o+d*t)<.4)
|
||||
{
|
||||
t-=5.;
|
||||
for(int j=0;j<5;j++)
|
||||
{
|
||||
if(h(o+d*t)<.4)
|
||||
break;
|
||||
t+=1.;
|
||||
}
|
||||
vec3 e=vec3(.01,.0,.0);
|
||||
vec3 n=vec3(.0);
|
||||
n.x=h(o+d*t)-h(vec3(o+d*t+e.xyy));
|
||||
n.y=h(o+d*t)-h(vec3(o+d*t+e.yxy));
|
||||
n.z=h(o+d*t)-h(vec3(o+d*t+e.yyx));
|
||||
n=normalize(n);
|
||||
c+=max(dot(vec3(.0,.0,-.5),n),.0)+max(dot(vec3(.0,-.5,.5),n),.0)*.5;
|
||||
break;
|
||||
}
|
||||
t+=5.;
|
||||
}
|
||||
gl_FragColor=c+vec4(.1,.2,.5,1.)*(t*.025);
|
||||
}
|
||||
33
hgplus/ShaderMinifier/tests/real/monjori.frag
Normal file
33
hgplus/ShaderMinifier/tests/real/monjori.frag
Normal file
@@ -0,0 +1,33 @@
|
||||
uniform vec2 resolution;
|
||||
uniform float time;
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform sampler2D tex2;
|
||||
uniform sampler2D tex3;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
|
||||
float a = time*40.0;
|
||||
float d,e,f,g=1.0/40.0,h,i,r,q;
|
||||
e=400.0*(p.x*0.5+0.5);
|
||||
f=400.0*(p.y*0.5+0.5);
|
||||
i=200.0+sin(e*g+a/150.0)*20.0;
|
||||
d=200.0+cos(f*g/2.0)*18.0+cos(e*g)*7.0;
|
||||
r=sqrt(pow(i-e,2.0)+pow(d-f,2.0));
|
||||
q=f/r;
|
||||
e=(r*cos(q))-a/2.0;f=(r*sin(q))-a/2.0;
|
||||
d=sin(e*g)*176.0+sin(e*g)*164.0+r;
|
||||
h=((f+d)+a/2.0)*g;
|
||||
i=cos(h+r*p.x/1.3)*(e+e+a)+cos(q*g*6.0)*(r+h/3.0);
|
||||
h=sin(f*g)*144.0-sin(e*g)*212.0*p.x;
|
||||
h=(h+(f-e)*q+sin(r-(a+h)/7.0)*10.0+i/4.0)*g;
|
||||
i+=cos(h*2.3*sin(a/350.0-q))*184.0*sin(q-(r*4.3+a/12.0)*g)+tan(r*g+h)*184.0*cos(r*g+h);
|
||||
i=mod(i/5.6,256.0)/64.0;
|
||||
if(i<0.0) i+=4.0;
|
||||
if(i>=2.0) i=4.0-i;
|
||||
d=r/350.0;
|
||||
d+=sin(d*d*8.0)*0.52;
|
||||
f=(sin(a*g)+1.0)/2.0;
|
||||
gl_FragColor = vec4(f*i/1.6,i/2.0+d/13.0,i,1.0)*d*p.x+vec4(i/1.3+d/8.0,i/2.0+d/18.0,i,1.0)*d*(1.0-p.x);
|
||||
}
|
||||
41
hgplus/ShaderMinifier/tests/real/motion_blur.frag
Normal file
41
hgplus/ShaderMinifier/tests/real/motion_blur.frag
Normal file
@@ -0,0 +1,41 @@
|
||||
uniform vec2 resolution;
|
||||
uniform float time;
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform sampler2D tex2;
|
||||
uniform sampler2D tex3;
|
||||
|
||||
vec3 deform( in vec2 p, float scale )
|
||||
{
|
||||
vec2 uv;
|
||||
|
||||
float mtime = scale+time;
|
||||
float a = atan(p.y,p.x);
|
||||
float r = sqrt(dot(p,p));
|
||||
float s = r * (1.0+0.5*cos(mtime*1.7));
|
||||
|
||||
uv.x = .1*mtime +.05*p.y+.05*cos(-mtime+a*3.0)/s;
|
||||
uv.y = .1*mtime +.05*p.x+.05*sin(-mtime+a*3.0)/s;
|
||||
|
||||
float w = 0.8-0.2*cos(mtime+3.0*a);
|
||||
|
||||
vec3 res = texture2D(tex0,uv).xyz*w;
|
||||
return res*res;
|
||||
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
|
||||
vec3 total = vec3(0.0);
|
||||
float w = 0.0;
|
||||
for( int i=0; i<20; i++ )
|
||||
{
|
||||
vec3 res = deform(p,w);
|
||||
total += res;
|
||||
w += 0.02;
|
||||
}
|
||||
total /= 20.0;
|
||||
|
||||
gl_FragColor = vec4( 3.0*total,1.0);
|
||||
}
|
||||
21
hgplus/ShaderMinifier/tests/real/multitexture.frag
Normal file
21
hgplus/ShaderMinifier/tests/real/multitexture.frag
Normal file
@@ -0,0 +1,21 @@
|
||||
uniform vec2 resolution;
|
||||
uniform float time;
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
|
||||
// a rotozoom
|
||||
vec2 cst = vec2( cos(.5*time), sin(.5*time) );
|
||||
mat2 rot = 0.5*cst.x*mat2(cst.x,-cst.y,cst.y,cst.x);
|
||||
vec3 col1 = texture2D(tex0,rot*p).xyz;
|
||||
|
||||
// scroll
|
||||
vec3 col2 = texture2D(tex1,0.5*p+sin(0.1*time)).xyz;
|
||||
|
||||
// blend layers
|
||||
vec3 col = col2*col1;
|
||||
|
||||
gl_FragColor = vec4(col,1.0);
|
||||
}
|
||||
34
hgplus/ShaderMinifier/tests/real/postprocessing.frag
Normal file
34
hgplus/ShaderMinifier/tests/real/postprocessing.frag
Normal file
@@ -0,0 +1,34 @@
|
||||
uniform vec2 resolution;
|
||||
uniform float time;
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform sampler2D tex2;
|
||||
uniform sampler2D tex3;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 q = gl_FragCoord.xy / resolution.xy;
|
||||
vec2 uv = 0.5 + (q-0.5)*(0.9 + 0.1*sin(0.2*time));
|
||||
|
||||
vec3 oricol = texture2D(tex0,vec2(q.x,1.0-q.y)).xyz;
|
||||
vec3 col;
|
||||
|
||||
col.r = texture2D(tex0,vec2(uv.x+0.003,-uv.y)).x;
|
||||
col.g = texture2D(tex0,vec2(uv.x+0.000,-uv.y)).y;
|
||||
col.b = texture2D(tex0,vec2(uv.x-0.003,-uv.y)).z;
|
||||
|
||||
col = clamp(col*0.5+0.5*col*col*1.2,0.0,1.0);
|
||||
|
||||
col *= 0.5 + 0.5*16.0*uv.x*uv.y*(1.0-uv.x)*(1.0-uv.y);
|
||||
|
||||
col *= vec3(0.8,1.0,0.7);
|
||||
|
||||
col *= 0.9+0.1*sin(10.0*time+uv.y*1000.0);
|
||||
|
||||
col *= 0.97+0.03*sin(110.0*time);
|
||||
|
||||
float comp = smoothstep( 0.2, 0.7, sin(time) );
|
||||
col = mix( col, oricol, clamp(-2.0+2.0*q.x+3.0*comp,0.0,1.0) );
|
||||
|
||||
gl_FragColor = vec4(col,1.0);
|
||||
}
|
||||
112
hgplus/ShaderMinifier/tests/real/quaternion.frag
Normal file
112
hgplus/ShaderMinifier/tests/real/quaternion.frag
Normal file
@@ -0,0 +1,112 @@
|
||||
uniform vec2 resolution;
|
||||
uniform float time;
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform sampler2D tex2;
|
||||
uniform sampler2D tex3;
|
||||
|
||||
float jinteresct(in vec3 rO, in vec3 rD, in vec4 c, out float ao)
|
||||
{
|
||||
float mz2,md2,dist,t;
|
||||
float res=1000.0;
|
||||
vec4 z,nz;
|
||||
|
||||
ao = 0.0;
|
||||
for(t=0.0;t<6.0;t+=dist)
|
||||
{
|
||||
ao += 1.0;
|
||||
vec3 p=rO+t*rD;
|
||||
|
||||
// calc distance
|
||||
z=vec4(p,(c.y+c.x)*.3);
|
||||
md2=1.0;
|
||||
mz2=dot(z,z);
|
||||
|
||||
for(int i=0;i<9;i++)
|
||||
{
|
||||
// |dz|^2 -> 4*|dz|^2
|
||||
md2*=4.0*mz2;
|
||||
// z -> z2 + c
|
||||
nz.x=z.x*z.x-dot(z.yzw,z.yzw);
|
||||
nz.yzw=2.0*z.x*z.yzw;
|
||||
z=nz+c;
|
||||
|
||||
mz2=dot(z,z);
|
||||
if(mz2>4.0)
|
||||
break;
|
||||
}
|
||||
|
||||
dist=0.25*sqrt(mz2/md2)*log(mz2);
|
||||
|
||||
if(dist<0.0005)
|
||||
{
|
||||
res=t;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
vec3 calcNormal(in vec3 p, in vec4 c)
|
||||
{
|
||||
vec4 nz,ndz,dz[4];
|
||||
|
||||
vec4 z=vec4(p,(c.y+c.x)*.3);
|
||||
|
||||
dz[0]=vec4(1.0,0.0,0.0,0.0);
|
||||
dz[1]=vec4(0.0,1.0,0.0,0.0);
|
||||
dz[2]=vec4(0.0,0.0,1.0,0.0);
|
||||
//dz[3]=vec4(0.0,0.0,0.0,1.0);
|
||||
|
||||
for(int i=0;i<9;i++)
|
||||
{
|
||||
vec4 mz = vec4(z.x,-z.y,-z.z,-z.w);
|
||||
// derivative
|
||||
dz[0]=vec4(dot(mz,dz[0]),z.x*dz[0].yzw+dz[0].x*z.yzw);
|
||||
dz[1]=vec4(dot(mz,dz[1]),z.x*dz[1].yzw+dz[1].x*z.yzw);
|
||||
dz[2]=vec4(dot(mz,dz[2]),z.x*dz[2].yzw+dz[2].x*z.yzw);
|
||||
//dz[3]=vec4(dot(mz,dz[3]),z.x*dz[3].yzw+dz[3].x*z.yzw);
|
||||
|
||||
// z = z2 + c
|
||||
nz.x=dot(z, mz);
|
||||
nz.yzw=2.0*z.x*z.yzw;
|
||||
z=nz+c;
|
||||
|
||||
if(dot(z,z)>4.0)
|
||||
break;
|
||||
}
|
||||
|
||||
return normalize(vec3(dot(z,dz[0]),dot(z,dz[1]),dot(z,dz[2])));
|
||||
}
|
||||
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
|
||||
vec3 color = vec3(0.0);
|
||||
vec4 cccc = vec4( .7*cos(.5*time), .7*sin(.3*time), .7*cos(1.0*time), 0.0 );
|
||||
vec3 edir = normalize(vec3(p,1.0));
|
||||
vec3 wori = vec3(0.0,0.0,-2.0);
|
||||
|
||||
float ao;
|
||||
float t = jinteresct(wori,edir,cccc,ao);
|
||||
if(t<100.0)
|
||||
{
|
||||
vec3 inter = wori + t*edir;
|
||||
vec3 nor = calcNormal(inter,cccc);
|
||||
|
||||
float dif = .5 + .5*dot( nor, vec3(0.57703) );
|
||||
ao = max( 1.0-ao*0.005, 0.0 );
|
||||
|
||||
color = vec3(1.0,.9,.5)*dif*ao + .5*vec3(.6,.7,.8)*ao;
|
||||
}
|
||||
else
|
||||
{
|
||||
color = vec3(0.5,0.51,0.52)+vec3(0.5,0.47,0.45)*p.y;
|
||||
}
|
||||
|
||||
gl_FragColor = vec4(color,1.0);
|
||||
}
|
||||
43
hgplus/ShaderMinifier/tests/real/radial_blur.frag
Normal file
43
hgplus/ShaderMinifier/tests/real/radial_blur.frag
Normal file
@@ -0,0 +1,43 @@
|
||||
uniform vec2 resolution;
|
||||
uniform float time;
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform sampler2D tex2;
|
||||
uniform sampler2D tex3;
|
||||
|
||||
vec3 deform( in vec2 p )
|
||||
{
|
||||
vec2 uv;
|
||||
|
||||
vec2 q = vec2( sin(1.1*time+p.x),sin(1.2*time+p.y) );
|
||||
|
||||
float a = atan(q.y,q.x);
|
||||
float r = sqrt(dot(q,q));
|
||||
|
||||
uv.x = sin(0.0+1.0*time)+p.x*sqrt(r*r+1.0);
|
||||
uv.y = sin(0.6+1.1*time)+p.y*sqrt(r*r+1.0);
|
||||
|
||||
return texture2D(tex0,uv*.5).xyz;
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
|
||||
vec2 s = p;
|
||||
|
||||
vec3 total = vec3(0.0);
|
||||
vec2 d = (vec2(0.0,0.0)-p)/40.0;
|
||||
float w = 1.0;
|
||||
for( int i=0; i<40; i++ )
|
||||
{
|
||||
vec3 res = deform(s);
|
||||
res = smoothstep(0.1,1.0,res*res);
|
||||
total += w*res;
|
||||
w *= .99;
|
||||
s += d;
|
||||
}
|
||||
total /= 40.0;
|
||||
float r = 1.5/(1.0+dot(p,p));
|
||||
gl_FragColor = vec4( total*r,1.0);
|
||||
}
|
||||
|
||||
34
hgplus/ShaderMinifier/tests/real/relief_tunnel.frag
Normal file
34
hgplus/ShaderMinifier/tests/real/relief_tunnel.frag
Normal file
@@ -0,0 +1,34 @@
|
||||
uniform vec2 resolution;
|
||||
uniform float time;
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform sampler2D tex2;
|
||||
uniform sampler2D tex3;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
|
||||
vec2 uv;
|
||||
|
||||
float r = sqrt( dot(p,p) );
|
||||
float a = atan(p.y,p.x) + 0.5*sin(0.5*r-0.5*time);
|
||||
|
||||
float s = 0.5 + 0.5*cos(7.0*a);
|
||||
s = smoothstep(0.0,1.0,s);
|
||||
s = smoothstep(0.0,1.0,s);
|
||||
s = smoothstep(0.0,1.0,s);
|
||||
s = smoothstep(0.0,1.0,s);
|
||||
|
||||
uv.x = time + 1.0/( r + .2*s);
|
||||
uv.y = 3.0*a/3.1416;
|
||||
|
||||
float w = (0.5 + 0.5*s)*r*r;
|
||||
|
||||
vec3 col = texture2D(tex0,uv).xyz;
|
||||
|
||||
float ao = 0.5 + 0.5*cos(7.0*a);
|
||||
ao = smoothstep(0.0,0.4,ao)-smoothstep(0.4,0.7,ao);
|
||||
ao = 1.0-0.5*ao*r;
|
||||
|
||||
gl_FragColor = vec4(col*w*ao,1.0);
|
||||
}
|
||||
385
hgplus/ShaderMinifier/tests/real/slisesix.frag
Normal file
385
hgplus/ShaderMinifier/tests/real/slisesix.frag
Normal file
@@ -0,0 +1,385 @@
|
||||
#extension GL_EXT_gpu_shader4: enable
|
||||
|
||||
uniform vec2 resolution;
|
||||
uniform float time;
|
||||
uniform sampler2D tex0;
|
||||
|
||||
int icoolfFunc3d2( in int n )
|
||||
{
|
||||
n=(n<<13)^n;
|
||||
return (n*(n*n*15731+789221)+1376312589) & 0x7fffffff;
|
||||
}
|
||||
|
||||
float coolfFunc3d2( in int n )
|
||||
{
|
||||
return float(icoolfFunc3d2(n));
|
||||
}
|
||||
|
||||
float noise3f( in vec3 p )
|
||||
{
|
||||
ivec3 ip = ivec3(floor(p));
|
||||
vec3 u = fract(p);
|
||||
u = u*u*(3.0-2.0*u);
|
||||
|
||||
int n = ip.x + ip.y*57 + ip.z*113;
|
||||
|
||||
float res = mix(mix(mix(coolfFunc3d2(n+(0+57*0+113*0)),
|
||||
coolfFunc3d2(n+(1+57*0+113*0)),u.x),
|
||||
mix(coolfFunc3d2(n+(0+57*1+113*0)),
|
||||
coolfFunc3d2(n+(1+57*1+113*0)),u.x),u.y),
|
||||
mix(mix(coolfFunc3d2(n+(0+57*0+113*1)),
|
||||
coolfFunc3d2(n+(1+57*0+113*1)),u.x),
|
||||
mix(coolfFunc3d2(n+(0+57*1+113*1)),
|
||||
coolfFunc3d2(n+(1+57*1+113*1)),u.x),u.y),u.z);
|
||||
|
||||
return 1.0 - res*(1.0/1073741824.0);
|
||||
}
|
||||
|
||||
float fbm( in vec3 p )
|
||||
{
|
||||
return 0.5000*noise3f(p*1.0) +
|
||||
0.2500*noise3f(p*2.0) +
|
||||
0.1250*noise3f(p*4.0) +
|
||||
0.0625*noise3f(p*8.0);
|
||||
}
|
||||
|
||||
|
||||
float techo( in float x, in float y )
|
||||
{
|
||||
y = 1.0 - y;
|
||||
if( x<0.1 || x>0.9 ) return y;
|
||||
x = x - 0.5;
|
||||
return -(sqrt(x*x+y*y)-0.4);
|
||||
}
|
||||
|
||||
|
||||
float distToBox( in vec3 p, in vec3 abc )
|
||||
{
|
||||
vec3 di=max(abs(p)-abc,0.0);
|
||||
return dot(di,di);
|
||||
}
|
||||
|
||||
|
||||
float columna( in float x, in float y, in float z, in float mindist, in float offx )
|
||||
{
|
||||
vec3 p=vec3(x,y,z);
|
||||
float di0=distToBox( p, vec3(0.14,1.0,0.14) );
|
||||
if( di0 > (mindist*mindist) ) return mindist + 1.0;
|
||||
|
||||
float y2=y-0.40;
|
||||
float y3=y-0.35;
|
||||
float y4=y-1.00;
|
||||
|
||||
float di1=distToBox( p, vec3(0.10,1.00,0.10) );
|
||||
float di2=distToBox( p, vec3(0.12,0.40,0.12) );
|
||||
float di3=distToBox( p, vec3(0.05,0.35,0.14) );
|
||||
float di4=distToBox( p, vec3(0.14,0.35,0.05) );
|
||||
float di9=distToBox( vec3(x,y4,z), vec3(0.14,0.02,0.14) );
|
||||
|
||||
float di5=distToBox( vec3((x-y2)*0.7071, (y2+x)*0.7071, z), vec3(0.10*0.7071, 0.10*0.7071, 0.12) );
|
||||
float di6=distToBox( vec3(x, (y2+z)*0.7071, (z-y2)*0.7071), vec3(0.12, 0.10*0.7071, 0.10*0.7071) );
|
||||
float di7=distToBox( vec3((x-y3)*0.7071, (y3+x)*0.7071, z), vec3(0.10*0.7071, 0.10*0.7071, 0.14) );
|
||||
float di8=distToBox( vec3(x, (y3+z)*0.7071, (z-y3)*0.7071), vec3(0.14, 0.10*0.7071, 0.10*0.7071) );
|
||||
|
||||
float di=min(min(min(di1,di2),min(di3,di4)),min(min(di5,di6),min(di7,di8)));
|
||||
di=min(di,di9);
|
||||
|
||||
// di += 0.00000003*max( fbm(10.1*p), 0.0);
|
||||
|
||||
return di;
|
||||
}
|
||||
|
||||
|
||||
|
||||
float bicho( vec3 x, in float mindist )
|
||||
{
|
||||
// float ramo = noise3f( vec3(2.0*time, 2.3*time, 0.0) );
|
||||
|
||||
x -= vec3(0.64,0.5,1.5);
|
||||
|
||||
float r2 = dot(x,x);
|
||||
|
||||
float sa = smoothstep(0.0,0.5,r2);
|
||||
float fax = 0.75 + 0.25*sa;
|
||||
float fay = 0.80 + 0.20*sa;
|
||||
|
||||
x.x *= fax;
|
||||
x.y *= fay;
|
||||
x.z *= fax;
|
||||
|
||||
r2 = dot(x,x);
|
||||
|
||||
float r = sqrt(r2);
|
||||
|
||||
float a1 = 1.0-smoothstep( 0.0, 0.75, r );
|
||||
a1 *= 0.40;
|
||||
float si1 = sin(a1);
|
||||
float co1 = cos(a1);
|
||||
x.xy = mat2(co1,si1,-si1,co1)*x.xy;
|
||||
|
||||
|
||||
float mindist2 = 100000.0;
|
||||
|
||||
float rr = 0.05+sqrt(dot(x.xz,x.xz));
|
||||
float ca = (0.5-0.045*0.75) -6.0*rr*exp2(-10.0*rr);
|
||||
for( int j=1; j<7; j++ )
|
||||
{
|
||||
float an = (6.2831/7.0) * float(j);
|
||||
float aa = an + 0.40*rr*noise3f( vec3(4.0*rr, 2.5, an) ) + 0.29;
|
||||
float rc = cos(aa);
|
||||
float rs = sin(aa);
|
||||
vec3 q = vec3( x.x*rc-x.z*rs, x.y+ca, x.x*rs+x.z*rc );
|
||||
float dd = dot(q.yz,q.yz);
|
||||
if( q.x>0.0 && q.x<1.5 && dd<mindist2 ) mindist2=dd;
|
||||
}
|
||||
|
||||
float c = sqrt(mindist2) - 0.045;
|
||||
float d = r-0.30;
|
||||
float a = clamp( r*3.0, 0.0, 1.0 );
|
||||
return c*a + d*(1.0-a);
|
||||
}
|
||||
|
||||
|
||||
float map( in vec3 pos, out int sid, out int submat )
|
||||
{
|
||||
submat = 0;
|
||||
float dis, mindist;
|
||||
|
||||
//-----------------------
|
||||
// suelo
|
||||
//-----------------------
|
||||
dis = pos.y;
|
||||
vec2 axz = vec2(128.0) + 6.0*vec2(pos.x+pos.z,pos.x-pos.z);
|
||||
ivec2 ixz = ivec2( floor(axz) );
|
||||
submat = icoolfFunc3d2(ixz.x+53*ixz.y);
|
||||
vec2 peldxz = fract( axz );
|
||||
float peld = smoothstep( 0.975, 1.0, max( peldxz.x, peldxz.y ) );
|
||||
if( (((submat>>10)&7)>6) ) { peld = 1.0; }
|
||||
dis += 0.005*peld;
|
||||
mindist = dis;
|
||||
sid = 0;
|
||||
if( peld>0.0000001 ) sid = 2;
|
||||
|
||||
//-----------------------
|
||||
// techo
|
||||
//-----------------------
|
||||
float fx = fract( pos.x+128.0 );
|
||||
float fz = fract( pos.z+128.0 );
|
||||
if( pos.y>1.0 )
|
||||
{
|
||||
dis = max(techo(fx,pos.y),techo(fz,pos.y));
|
||||
if( dis<mindist )
|
||||
{
|
||||
mindist = dis;
|
||||
sid = 5;
|
||||
}
|
||||
}
|
||||
fx = fract( pos.x+128.0+.5 );
|
||||
fz = fract( pos.z+128.0+.5 );
|
||||
|
||||
//-----------------------
|
||||
// columnas
|
||||
dis = columna( fx-.5, pos.y, fz-.5, mindist, 13.1*floor(pos.x)+17.7*floor(pos.z) );
|
||||
if( dis<(mindist*mindist) )
|
||||
{
|
||||
mindist = sqrt(dis);
|
||||
sid = 1;
|
||||
}
|
||||
|
||||
//-----------------------
|
||||
// bicho
|
||||
//-----------------------
|
||||
|
||||
dis = bicho( pos, mindist );
|
||||
if( dis<mindist )
|
||||
{
|
||||
mindist = dis;
|
||||
sid = 4;
|
||||
}
|
||||
//-----------------------
|
||||
|
||||
return mindist;
|
||||
}
|
||||
|
||||
vec3 calcNormal( in vec3 pos )
|
||||
{
|
||||
float eps = 0.0002;
|
||||
vec3 nor;
|
||||
int kk, kk2;
|
||||
nor.x = map( vec3(pos.x+eps, pos.y, pos.z), kk, kk2 ) - map( vec3(pos.x-eps, pos.y, pos.z), kk, kk2 );
|
||||
nor.y = map( vec3(pos.x, pos.y+eps, pos.z), kk, kk2 ) - map( vec3(pos.x, pos.y-eps, pos.z), kk, kk2 );
|
||||
nor.z = map( vec3(pos.x, pos.y, pos.z+eps), kk, kk2 ) - map( vec3(pos.x, pos.y, pos.z-eps), kk, kk2 );
|
||||
return normalize( nor );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 pixel = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
|
||||
float an = time*0.15;
|
||||
vec2 sc = vec2(cos(an),sin(an));
|
||||
|
||||
float r2 = pixel.x*pixel.x*0.32 + pixel.y*pixel.y;
|
||||
float tt = (7.0-sqrt(37.5-11.5*r2))/(r2+1.0);
|
||||
pixel *= tt;
|
||||
|
||||
float asp = resolution.x/resolution.y;
|
||||
vec3 rd = normalize(vec3(asp*pixel.x*sc.x-sc.y,pixel.y,sc.x+asp*pixel.x*sc.y));
|
||||
vec3 ro = vec3(0.5+1.4*sc.y,0.5,1.5-1.4*sc.x);
|
||||
|
||||
float t;
|
||||
int matID=666;
|
||||
int subMatID;
|
||||
vec3 pos;
|
||||
vec3 rgb = vec3(0.0);
|
||||
|
||||
// cast ray
|
||||
#if 1
|
||||
for( t=0.5; t<12.0; )
|
||||
{
|
||||
pos = ro + t*rd;
|
||||
float h = map( pos, matID, subMatID );
|
||||
if( h<0.01 ) break;
|
||||
t += h;
|
||||
//if( t>30.0 ) break;
|
||||
}
|
||||
#else
|
||||
t = 0.5;
|
||||
for( int i=0; i<50; i++ )
|
||||
{
|
||||
pos = ro + t*rd;
|
||||
float h = map( pos, matID, sumMatID );
|
||||
if( h<0.001 ) break;
|
||||
t += h;
|
||||
//if( t>30.0 ) break;
|
||||
}
|
||||
#endif
|
||||
|
||||
// shade
|
||||
if( matID!=666 )
|
||||
{
|
||||
// calc normal
|
||||
vec3 nor = calcNormal(pos);
|
||||
|
||||
|
||||
// bump mapping
|
||||
float kke=0.0001;
|
||||
float bumpa=0.0075;
|
||||
if( matID!=5 ) bumpa*=0.75;
|
||||
if( matID==4 ) bumpa*=0.50;
|
||||
bumpa /= kke;
|
||||
float kk = fbm(32.0*pos);
|
||||
nor.x += bumpa*(fbm(32.0*vec3(pos.x+kke, pos.y, pos.z))-kk);
|
||||
nor.y += bumpa*(fbm(32.0*vec3(pos.x, pos.y+kke, pos.z))-kk);
|
||||
nor.z += bumpa*(fbm(32.0*vec3(pos.x, pos.y, pos.z+kke))-kk);
|
||||
nor = normalize(nor);
|
||||
|
||||
// light
|
||||
float spe = 0.0;
|
||||
vec3 lig = vec3( 0.5-pos.x, 0.8-pos.y, 1.5-pos.z );
|
||||
float llig = dot(lig,lig);
|
||||
float im = inversesqrt(llig);
|
||||
lig = lig * im;
|
||||
float dif = dot(nor,lig);
|
||||
if( matID==4 )
|
||||
{dif=0.5+0.5*dif;}
|
||||
else
|
||||
{dif=0.1+0.9*dif;}
|
||||
//if( dif<0.0 ) dif=0.0;
|
||||
//dif=max(dif,0.0);
|
||||
dif = clamp(dif,0.0,1.0);
|
||||
dif *= 2.5*exp2(-1.75*llig);
|
||||
float dif2=(nor[0]+nor[1])*0.075;
|
||||
|
||||
|
||||
// materials
|
||||
if( matID==0 )
|
||||
{
|
||||
float xoff = 13.1*float(subMatID&255);
|
||||
float fb = fbm(16.0*vec3(pos.x+xoff,pos.y,pos.z));
|
||||
rgb = vec3(0.7) + fb*vec3(0.20,0.22,0.25);
|
||||
|
||||
float baldscale = float((subMatID>>9)&15)/14.0;
|
||||
baldscale = 0.51 + 0.34*baldscale;
|
||||
rgb *= baldscale;
|
||||
float fx = 1.0;
|
||||
if( (subMatID&256)!=0 ) fx = -1.0;
|
||||
float m = sin( 64.0*pos.z*fx + 64.0*pos.x + 4.0*fb );
|
||||
m = smoothstep( 0.25, 0.5, m ) - smoothstep( 0.5, 0.75, m );
|
||||
rgb += m*vec3(0.15);
|
||||
}
|
||||
else if( matID==2 )
|
||||
{
|
||||
rgb = vec3(0.0);
|
||||
}
|
||||
else if( matID==1 )
|
||||
{
|
||||
float fb = fbm( 16.0*pos );
|
||||
float m = sin( 64.0*pos.z + 64.0*pos.x + 4.0*fb );
|
||||
m = smoothstep( 0.30, 0.5, m ) - smoothstep( 0.5, 0.70, m );
|
||||
rgb = vec3(0.59) + fb*vec3(0.17,0.18,0.21) + m*vec3(0.15) + vec3(dif2);
|
||||
}
|
||||
else if( matID==4 )
|
||||
{
|
||||
float ft = fbm( 16.0*pos );
|
||||
rgb = vec3(0.82,0.73,0.65) + ft*vec3(0.1);
|
||||
|
||||
float fs = 0.9+0.1*fbm( 32.0*pos );
|
||||
rgb *= fs;
|
||||
|
||||
float fre = max( -dot( nor, rd ), 0.0);
|
||||
rgb -= vec3(fre*fre*0.45);
|
||||
spe = clamp((nor.y-nor.z)*0.707,0.0,1.0);
|
||||
spe = 0.20*pow(spe,32.0);
|
||||
}
|
||||
// techo
|
||||
else //if( matID==5 )
|
||||
{
|
||||
float fb = fbm( 16.0*pos );
|
||||
rgb = vec3(0.64,0.61,0.59) + fb*vec3(0.21,0.19,0.19) + dif2;
|
||||
}
|
||||
|
||||
// AO
|
||||
float ao;
|
||||
float totao = 0.0;
|
||||
float sca = 10.0;
|
||||
for( int aoi=0; aoi<5; aoi++ )
|
||||
{
|
||||
float hr = 0.01 + 0.015*float(aoi*aoi);
|
||||
vec3 aopos = nor * hr + pos;
|
||||
int kk, kk2;
|
||||
float dd = map( aopos, kk, kk2 );
|
||||
ao = -(dd-hr);
|
||||
totao += ao*sca;
|
||||
sca *= 0.5;
|
||||
}
|
||||
ao = 1.0 - clamp( totao, 0.0, 1.0 );
|
||||
|
||||
// shadow
|
||||
float so = 0.0;
|
||||
for( int i=0; i<6; i++ )
|
||||
{
|
||||
float h = float(i)/6.0;
|
||||
float hr = 0.01 + h;
|
||||
vec3 aopos = lig * hr + pos;
|
||||
int kk, kk2;
|
||||
float dd = map( aopos, kk, kk2 );
|
||||
so += (1.0-h)*dd*2.0 * (10.0/6.0);
|
||||
}
|
||||
dif *= clamp( (so-0.40)*1.5, 0.0, 1.0 );
|
||||
|
||||
// lighting
|
||||
rgb = vec3(spe) + rgb * (ao*vec3(0.25,0.30,0.35) + dif*vec3(1.95,1.65,1.05));
|
||||
// fog
|
||||
rgb = rgb * exp2( -0.4*t );
|
||||
}
|
||||
|
||||
// color correct
|
||||
rgb =(sqrt(rgb)*0.7+0.3*rgb)*vec3(0.83,1.0,0.83)*1.2;
|
||||
|
||||
// vigneting
|
||||
rgb *= 0.25+0.75*clamp(0.60*abs(pixel.x-1.0)*abs(pixel.x+1.0),0.0,1.0);
|
||||
|
||||
gl_FragColor=vec4(rgb,1.0);
|
||||
}
|
||||
20
hgplus/ShaderMinifier/tests/real/square_tunnel.frag
Normal file
20
hgplus/ShaderMinifier/tests/real/square_tunnel.frag
Normal file
@@ -0,0 +1,20 @@
|
||||
uniform vec2 resolution;
|
||||
uniform float time;
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform sampler2D tex2;
|
||||
uniform sampler2D tex3;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
|
||||
vec2 uv;
|
||||
|
||||
float r = pow( pow(p.x*p.x,16.0) + pow(p.y*p.y,16.0), 1.0/32.0 );
|
||||
uv.x = .5*time + 0.5/r;
|
||||
uv.y = 1.0*atan(p.y,p.x)/3.1416;
|
||||
|
||||
vec3 col = texture2D(tex0,uv).xyz;
|
||||
|
||||
gl_FragColor = vec4(col*r*r*r,1.0);
|
||||
}
|
||||
28
hgplus/ShaderMinifier/tests/real/star.frag
Normal file
28
hgplus/ShaderMinifier/tests/real/star.frag
Normal file
@@ -0,0 +1,28 @@
|
||||
uniform float time;
|
||||
uniform vec2 resolution;
|
||||
uniform vec4 mouse;
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
uniform sampler2D tex2;
|
||||
uniform sampler2D tex3;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 uv;
|
||||
|
||||
vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
|
||||
float a = atan(p.y,p.x);
|
||||
float r = sqrt(dot(p,p));
|
||||
float s = r * (1.0+0.8*cos(time*1.0));
|
||||
|
||||
uv.x = .02*p.y+.03*cos(-time+a*3.0)/s;
|
||||
uv.y = .1*time +.02*p.x+.03*sin(-time+a*3.0)/s;
|
||||
|
||||
float w = .9 + pow(max(1.5-r,0.0),4.0);
|
||||
|
||||
w*=0.6+0.4*cos(time+3.0*a);
|
||||
|
||||
vec3 col = texture2D(tex0,uv).xyz;
|
||||
|
||||
gl_FragColor = vec4(col*w,1.0);
|
||||
}
|
||||
95
hgplus/ShaderMinifier/tests/real/sult.frag
Normal file
95
hgplus/ShaderMinifier/tests/real/sult.frag
Normal file
@@ -0,0 +1,95 @@
|
||||
// Scene from Sult by Loonies
|
||||
// Exclusive source release for ShaderToy
|
||||
// Blame the scene chosen on iq ;)
|
||||
// Feel free to be inspired, but please mention it (.readme) then :)
|
||||
// -Psycho/Loonies
|
||||
|
||||
// Actual, ugly, size optimized 4k version with minimal changes for ShaderToy
|
||||
// but before auto-obfuscation (whitespaces, comments, variable names)
|
||||
|
||||
// Inputs changed into more readable constants:
|
||||
float shaderparm=5.0, fov=.9, pitch=0.0, heading=90.0, dheading=0.0;
|
||||
vec3 lightdir=vec3(1,1,1), position=vec3(0,0,1), speed=vec3(0,0,1.5);
|
||||
|
||||
// constants for the other worm tunnel part:
|
||||
//float shaderparm=8, fov=.8, pitch=0, heading=-90, dheading=0;
|
||||
//vec3 lightdir=vec3(1,1,1), position=vec3(0,0,0), speed=vec3(0,0,0);
|
||||
|
||||
// shadertoy input
|
||||
uniform vec2 resolution;
|
||||
uniform float time;
|
||||
|
||||
|
||||
vec3 rotatey(vec3 r, float v)
|
||||
{ return vec3(r.x*cos(v)+r.z*sin(v),r.y,r.z*cos(v)-r.x*sin(v));
|
||||
}
|
||||
vec3 rotatex(vec3 r, float v)
|
||||
{ return vec3(r.y*cos(v)+r.z*sin(v),r.x,r.z*cos(v)-r.y*sin(v));
|
||||
}
|
||||
float mat=0.0, tmax=10.0;
|
||||
float eval(vec3 p)
|
||||
{
|
||||
////// this is the (only) part that changes for the scenes in Sult
|
||||
float t = time,r,c=0.0,g,r2,r3;
|
||||
vec3 pp;
|
||||
p += ( sin(p.zxy*1.7+t)+sin(p.yzx+t*3.) )*.2;
|
||||
if (shaderparm<6.0)
|
||||
c = length(p.xyz*vec3(1,1,.1)-vec3(0,-.1,t*.15-.3))-.34;
|
||||
else
|
||||
c = length(p.xy+vec2(.0,.7))-.3+ (sin(p.z*17.0+t*.6)+sin(p.z*2.0)*6.0)*.01;
|
||||
|
||||
p.xy = vec2( atan(p.x,p.y)*1.113, 1.6-length(p.xy)-sin(t*2.0)*.3);
|
||||
pp = fract(p.xzz+.5).xyz -.5; pp.y=(p.y-.35)*1.3;
|
||||
r = max( abs(p.y-.3)-.05, abs(length(fract(p.xz)-.5)-.4)-.03);
|
||||
mat = step(c,r);
|
||||
return min(min(r,c),p.y-.2);
|
||||
}
|
||||
vec3 diffdark= vec3(.19,.2,.24), difflight=vec3(1),
|
||||
diffrefl= vec3(.45,.01,0), background=vec3(.17,0,0);
|
||||
//////////
|
||||
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
|
||||
vec3 vdir= normalize(
|
||||
rotatey(rotatey(vec3(p.y*fov,p.x*fov*1.33,1),
|
||||
-pitch*.035).yxz,(heading+dheading*time)*.035)),
|
||||
vpos= position + speed*time;
|
||||
|
||||
float cf=1.0,rf=0.0,t,stp,tmin=0.0,c,r,m,d;
|
||||
vec3 e=vec3(.01,0,0),cx=e.yyy,n;
|
||||
while (cf>.1)
|
||||
{
|
||||
for (t=tmin,stp=1.0;t<tmax && stp>.005;t+=stp)
|
||||
stp = eval(vpos+vdir*t);
|
||||
if (t<tmax)
|
||||
{ vpos+= vdir*t;
|
||||
c= eval(vpos);
|
||||
m = mat;
|
||||
n= normalize(-vec3(c-eval(vpos+e.xyy),c-eval(vpos+e.yxy),
|
||||
c-eval(vpos+e.yyx)));
|
||||
r= clamp(eval(vpos+n*.05)*4.+eval(vpos+n*.1)*2.0+.5,.1,1.); // ao
|
||||
|
||||
// shade
|
||||
rf = m*.3;
|
||||
n= normalize(n+step(4.,shaderparm)*mat*sin(vpos.yzx*40.0)*.05);
|
||||
vdir=reflect(vdir,n);
|
||||
d=clamp(dot(normalize(lightdir),n),.0,1.);
|
||||
|
||||
n= mix(mix(diffdark,difflight,d),diffrefl*(d+.2), m)
|
||||
+vec3(.7 * pow( clamp( dot( normalize(lightdir),vdir)
|
||||
,.0,1.) ,12.)); // n = col..
|
||||
|
||||
cx += cf* mix(n*r, background, t/tmax);
|
||||
cf*= rf*(1.0-t/tmax);
|
||||
tmin= .1;
|
||||
}
|
||||
else{
|
||||
cx += cf*background;
|
||||
cf=0.0;
|
||||
}
|
||||
}
|
||||
gl_FragColor.xyz= cx;
|
||||
gl_FragColor.w= 1.0;
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
const int N_BALLS = 8; /* le nombre de points spirales */
|
||||
|
||||
uniform vec4 col[N_BALLS]; /* couleurs des points spirales */
|
||||
uniform vec3 pos[N_BALLS]; /* position des points spirales */
|
||||
uniform float intensity[N_BALLS]; /* "taille" des points spirales */
|
||||
|
||||
|
||||
uniform float localTime;
|
||||
uniform float progression;
|
||||
|
||||
/* renvoie la couleur de l'image en ce point.
|
||||
On l'appelle plusieurs fois pour faire des symétries (bourrin !) */
|
||||
vec3 coul(vec2 p)
|
||||
{
|
||||
float prog = progression;
|
||||
float p2 = prog * prog;
|
||||
float time = localTime;
|
||||
|
||||
vec3 couleur = vec3(0.0,0.0,0.0);
|
||||
|
||||
|
||||
float l = min(0.0, 1.5 * progression - 0.5);
|
||||
|
||||
float dist_factor = (6.0 + 3.0 * sin(time));
|
||||
|
||||
|
||||
for (int i = 0; i < N_BALLS; ++i)
|
||||
{
|
||||
vec2 diff = (pos[i].xy - p);
|
||||
float d = dot(diff, diff); /* d = distance entre le pixel et le point spirale i */
|
||||
|
||||
float angle = atan(diff.y, diff.x);
|
||||
|
||||
/* on accumule la contribution de chaque spirale */
|
||||
|
||||
float s = cos(5.0 * (angle - (1.0 + float(i) * 0.05 - prog * 1.5 ) * time) + d * dist_factor );
|
||||
|
||||
s *= min(1.0, abs(0.7 + prog * 0.3 - s) * 15.0);
|
||||
|
||||
float spiral_factor = max(0.0, s * (1.0 - p2) );
|
||||
float contrib = spiral_factor * intensity[i] * exp(-0.02 * d) + l;
|
||||
|
||||
couleur += col[i].rgb * contrib;
|
||||
|
||||
}
|
||||
return couleur;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 p = gl_TexCoord[0].xy * 0.7;
|
||||
|
||||
vec3 couleur = coul(p);
|
||||
|
||||
gl_FragColor = vec4( couleur * 1.1, 1.0 );
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
void main()
|
||||
{
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
uniform sampler2D tex;
|
||||
uniform float invTexWidth;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 p = gl_TexCoord[0].xy;
|
||||
vec2 dp = vec2(invTexWidth, 0.0);
|
||||
|
||||
/*
|
||||
vec3 a = texture2D(tex, p - 3.0 * dp).rgb;
|
||||
vec3 b = texture2D(tex, p - 2.0 * dp).rgb;
|
||||
vec3 c = texture2D(tex, p - 1.0 * dp).rgb;
|
||||
vec3 d = texture2D(tex, p ).rgb;
|
||||
vec3 e = texture2D(tex, p + 1.0 * dp).rgb;
|
||||
vec3 f = texture2D(tex, p + 2.0 * dp).rgb;
|
||||
vec3 g = texture2D(tex, p + 3.0 * dp).rgb;
|
||||
vec3 final = 0.015625 * (a + g)
|
||||
+ 0.09375 * (b + f)
|
||||
+ 0.234375 * (c + e)
|
||||
+ 0.3125 * d;
|
||||
|
||||
gl_FragColor = vec4( final, 1.0 );
|
||||
*/
|
||||
|
||||
|
||||
vec3 a = texture2D(tex, p - 2.1428571 * dp).rgb;
|
||||
vec3 b = texture2D(tex, p - 0.6 * dp).rgb;
|
||||
vec3 c = texture2D(tex, p + 0.6 * dp).rgb;
|
||||
vec3 d = texture2D(tex, p + 2.1428571 * dp).rgb;
|
||||
vec3 final = (2.0 * 0.21875) * (a + d)
|
||||
+ (2.0 * 0.78125) * (b + c);
|
||||
gl_FragColor = vec4( final, 1.0 );
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
void main()
|
||||
{
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
uniform sampler2D tex;
|
||||
uniform float invTexHeight;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 p = gl_TexCoord[0].xy;
|
||||
vec2 dp = vec2(0.0, invTexHeight);
|
||||
|
||||
const vec3 limit = vec3(0.5,0.5,0.5);
|
||||
const vec3 mini = vec3(0.0,0.0,0.0);
|
||||
|
||||
/* first version (7 samples) */
|
||||
/*
|
||||
vec3 a = max(mini, texture2D(tex, p - 3.0 * dp).rgb - limit);
|
||||
vec3 b = max(mini, texture2D(tex, p - 2.0 * dp).rgb - limit);
|
||||
vec3 c = max(mini, texture2D(tex, p - 1.0 * dp).rgb - limit);
|
||||
vec3 d = max(mini, texture2D(tex, p ).rgb - limit);
|
||||
vec3 e = max(mini, texture2D(tex, p + 1.0 * dp).rgb - limit);
|
||||
vec3 f = max(mini, texture2D(tex, p + 2.0 * dp).rgb - limit);
|
||||
vec3 g = max(mini, texture2D(tex, p + 3.0 * dp).rgb - limit);
|
||||
vec3 final = 0.015625 * (a + g)
|
||||
+ 0.09375 * (b + f)
|
||||
+ 0.234375 * (c + e)
|
||||
+ 0.3125 * d;
|
||||
|
||||
gl_FragColor = vec4( final * 2.0, 1.0 );
|
||||
*/
|
||||
|
||||
/* second version (4 samples) */
|
||||
|
||||
vec3 a = max(mini, texture2D(tex, p - 2.1428571 * dp).rgb - limit);
|
||||
vec3 b = max(mini, texture2D(tex, p - 0.6 * dp).rgb - limit);
|
||||
vec3 c = max(mini, texture2D(tex, p + 0.6 * dp).rgb - limit);
|
||||
vec3 d = max(mini, texture2D(tex, p + 2.1428571 * dp).rgb - limit);
|
||||
vec3 final = (2.0 * 0.21875) * (a + d)
|
||||
+ (2.0 * 0.78125) * (b + c);
|
||||
gl_FragColor = vec4( final, 1.0 );
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
void main()
|
||||
{
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
const float PI = 3.1415926;
|
||||
|
||||
|
||||
uniform float localTime;
|
||||
|
||||
vec3 coul2(float x, float y)
|
||||
{
|
||||
float h = (x + 1.0) * 350.0;
|
||||
float w = (y + 1.0) * 350.0;
|
||||
|
||||
float hi = (h - 350.0) / 20.0;
|
||||
float wi = (w - 350.0) / 20.0;
|
||||
|
||||
float xo = hi;
|
||||
float yo = wi + localTime;/*cos(hi/5.0) + wi + 0.1; */
|
||||
|
||||
float xa = cos(hi/5.0);
|
||||
float ya = cos(wi/5.0);
|
||||
|
||||
float cosxa = cos(xa);
|
||||
float sinxa = sin(xa);
|
||||
float cosya = cos(ya);
|
||||
float sinya = sin(ya);
|
||||
|
||||
vec3 res = vec3(0.0,0.0,0.0);
|
||||
|
||||
for (int l = 0; l <= 30; l++)
|
||||
{
|
||||
float li = (float(l) - 15.0) * 2.0;
|
||||
|
||||
float zo = li;
|
||||
|
||||
float za = cos(li / 20.0);
|
||||
|
||||
float tmp = yo * cosxa + zo * sinxa;
|
||||
zo = zo * cosxa - yo * sinxa;
|
||||
yo = tmp;
|
||||
|
||||
float tmp2 = xo * cosya + zo * sinya;
|
||||
zo = zo * cosya - xo * sinya;
|
||||
xo = tmp2;
|
||||
/*
|
||||
float tmp3 = xo * cos(za) + yo * sin(za);
|
||||
yo = yo * cos(za) - xo * sin(za);
|
||||
xo = tmp3;
|
||||
*/
|
||||
vec3 color = vec3(128.0) + vec3(128.0) * vec3(cos(zo), cos(zo + PI * 2.0 / 3.0), cos(zo - PI * 2.0 / 3.0));
|
||||
|
||||
float length = sqrt( xo * xo + yo * yo + zo * zo ) - 30.0;
|
||||
float contrib = 0.25 / (1.0 + 400.0 * length * length);
|
||||
|
||||
res = res * (1.0 - contrib) + color * contrib;
|
||||
/* res += contrib * color; */
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 p = 0.5 * gl_TexCoord[0].xy + vec2(0.1,0.1);
|
||||
|
||||
|
||||
gl_FragColor = vec4( 0.15 * coul2(p.x, p.y) , 1.0);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
uniform sampler2D tonemappedTexture;
|
||||
uniform sampler2D bloomTexture;
|
||||
uniform sampler2D paperTexture;
|
||||
uniform int paper;
|
||||
uniform float paperInvSize;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 p = gl_TexCoord[0].xy;
|
||||
|
||||
vec4 main = texture2D(tonemappedTexture, p);
|
||||
vec4 bloom = texture2D(bloomTexture, p);
|
||||
|
||||
vec4 paper = float(paper) * 1.8 * texture2D(paperTexture, gl_FragCoord.xy * paperInvSize) + vec4(1.0,1.0,1.0,1.0) * (1.0 - float(paper));
|
||||
|
||||
gl_FragColor = paper * (main * 0.8 + 0.2 * bloom);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
void main()
|
||||
{
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D fill;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 p = gl_TexCoord[0].xy;
|
||||
vec4 letter = texture2D(tex, p);
|
||||
vec4 fill = texture2D(fill, p * 3.0);
|
||||
|
||||
gl_FragColor = letter * fill * gl_Color;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_Position = ftransform();
|
||||
gl_FrontColor = gl_Color;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
uniform sampler2D tex;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 p = gl_TexCoord[0].xy;
|
||||
vec4 sample0 = texture2D(tex, p);
|
||||
gl_FragColor = gl_Color * sample0;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_Position = ftransform();
|
||||
gl_FrontColor = gl_Color;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D grain;
|
||||
|
||||
const int NPOINTS = 5;
|
||||
|
||||
uniform float env;
|
||||
|
||||
uniform vec3 pos[NPOINTS];
|
||||
uniform float intensity[NPOINTS];
|
||||
uniform float localTime;
|
||||
uniform float zoom;
|
||||
|
||||
|
||||
const float PI = 3.14159265;
|
||||
|
||||
void main()
|
||||
{
|
||||
float x = gl_TexCoord[0].s * zoom;
|
||||
float y = gl_TexCoord[0].t * zoom;
|
||||
float u = localTime * 0.25;
|
||||
|
||||
vec4 color = vec4(0.0);
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
vec3 diff = vec3(x, y, 0.0) - pos[i];
|
||||
float angle = atan(diff.y, diff.x);
|
||||
float d = env * 1.0; /* length(pos[i]);*/
|
||||
float t = (d + localTime) * 0.03 ;
|
||||
float s = u + angle / PI + (float(i) * 0.1);
|
||||
float dist = length(diff);
|
||||
vec4 grain = texture2D(grain, vec2(0.5, 0.3 * dist));
|
||||
|
||||
color += (texture2D(tex, vec2(s,t)) * grain) * (intensity[i] / (1.0 + 0.2 * dist));
|
||||
}
|
||||
|
||||
gl_FragColor = vec4(color.rgb * 0.6 + 0.4 * env, 1.0);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
uniform sampler2D tex;
|
||||
|
||||
uniform float intensity;
|
||||
uniform float alpha;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 color = texture2D(tex, gl_TexCoord[0].xy);
|
||||
float opacity = dot(color.rgb, vec3(0.33,0.33,0.33)) * color.a * alpha;
|
||||
|
||||
|
||||
if (opacity < 0.05) discard;
|
||||
|
||||
gl_FragData[0] = vec4(color.rgb * intensity, opacity);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user