summaryrefslogtreecommitdiff
path: root/shaders/tesseract/351.shader_test
diff options
context:
space:
mode:
Diffstat (limited to 'shaders/tesseract/351.shader_test')
-rw-r--r--shaders/tesseract/351.shader_test191
1 files changed, 191 insertions, 0 deletions
diff --git a/shaders/tesseract/351.shader_test b/shaders/tesseract/351.shader_test
new file mode 100644
index 0000000..4e1121c
--- /dev/null
+++ b/shaders/tesseract/351.shader_test
@@ -0,0 +1,191 @@
+[require]
+GLSL >= 1.10
+
+[vertex shader]
+#version 120
+#extension GL_ARB_texture_rectangle : enable
+#define flat
+#define texture2DRectOffset(sampler, coords, offset) texture2DRect(sampler, coords + vec2(offset))
+#define shadow2DRectOffset(sampler, coords, offset) shadow2DRect(sampler, coords + vec2(offset))
+attribute vec4 vvertex;
+ uniform mat4 lightmatrix;
+ void main(void)
+ {
+ gl_Position = lightmatrix * vvertex;
+ }
+
+[fragment shader]
+#version 120
+#extension GL_ARB_texture_rectangle : enable
+#define flat
+#define texture2DRectOffset(sampler, coords, offset) texture2DRect(sampler, coords + vec2(offset))
+#define shadow2DRectOffset(sampler, coords, offset) shadow2DRect(sampler, coords + vec2(offset))
+#define fragdata(loc, name, type)
+#define fragcolor gl_FragData[0]
+uniform sampler2DRect tex0, tex1, tex3 ;
+
+
+ uniform sampler2DRectShadow tex4;
+
+
+ uniform vec4 lightpos[1];
+ uniform vec3 lightcolor[1];
+
+
+ uniform vec4 shadowparams[1];
+ uniform vec2 shadowoffset[1];
+
+
+
+ uniform vec3 splitcenter[3];
+ uniform vec3 splitbounds[3];
+ uniform vec3 splitscale[3];
+ uniform vec3 splitoffset[3];
+
+
+ uniform vec3 camera;
+ uniform mat4 worldmatrix;
+ uniform vec4 fogdir;
+ uniform vec3 fogcolor;
+ uniform vec2 fogdensity;
+ uniform vec4 radialfogscale;
+ uniform vec2 shadowatlasscale;
+ uniform vec4 lightscale;
+
+
+ uniform vec3 gdepthscale;
+ uniform vec3 gdepthunpackparams;
+
+ fragdata(0, fragcolor, vec4)
+
+
+ vec3 getshadowtc(vec3 dir, vec4 shadowparams, vec2 shadowoffset, float distbias)
+ {
+ vec3 adir = abs(dir);
+ float m = max(adir.x, adir.y), mz = max(adir.z, m);
+ vec2 mparams = shadowparams.xy / max(mz + distbias, 1e-5);
+ vec4 proj;
+ if(adir.x > adir.y) proj = vec4(dir.zyx, 0.0); else proj = vec4(dir.xzy, 1.0);
+ if(adir.z > m) proj = vec4(dir, 2.0);
+ return vec3(proj.xy * mparams.x + vec2(proj.w, step(proj.z, 0.0)) * shadowparams.z + shadowoffset, mparams.y + shadowparams.w);
+ }
+
+
+
+ #define shadowval(center, xoff, yoff) float(shadow2DRect(tex4, center + vec3(xoff, yoff, 0.0)))
+ float filtershadow(vec3 shadowtc)
+ {
+ vec2 offset = fract(shadowtc.xy - 0.5);
+ vec3 center = shadowtc;
+
+
+
+
+
+
+
+ center.xy -= offset*0.5;
+ vec4 size = vec4(offset + 1.0, 2.0 - offset);
+ return (1.0/9.0)*dot(size.zxzx*size.wwyy,
+ vec4(shadowval(center, -0.5, -0.5),
+ shadowval(center, 1.0, -0.5),
+ shadowval(center, -0.5, 1.0),
+ shadowval(center, 1.0, 1.0)));
+ }
+
+
+
+
+ void main(void)
+ {
+
+ #define gfetch(sampler, coords) texture2DRect(sampler, coords)
+
+ #define accumlight(light) fragcolor.rgb = light
+ #define accumalpha(alpha) fragcolor.a = alpha
+
+
+
+
+
+
+ #define depthvals gfetch(tex3, gl_FragCoord.xy)
+
+
+ float depth = depthvals.r;
+
+ vec4 pos = worldmatrix * vec4(gl_FragCoord.xy, depth, 1.0);
+ pos.xyz /= pos.w;
+
+
+
+
+
+
+
+
+ vec3 light = vec3(0.0);
+
+
+
+
+
+ vec3 light0dir = pos.xyz * lightpos[0].w - lightpos[0].xyz;
+ float light0dist2 = dot(light0dir, light0dir);
+ if(light0dist2 < 1.0)
+ {
+
+ vec4 normal = gfetch(tex1, gl_FragCoord.xy);
+
+ normal.xyz = normal.xyz*2.0 - 1.0;
+
+ #define glowscale normal.a
+
+
+ float light0facing = dot(light0dir, normal.xyz);
+ if(light0facing < 0.0)
+ {
+ float light0invdist = inversesqrt(light0dist2);
+
+ float light0atten = light0facing * (1.0 - light0invdist);
+
+ float fogcoord = length(camera - pos.xyz);
+
+
+ #define distbias 0.0
+
+
+ vec3 shadow0tc = getshadowtc(light0dir, shadowparams[0], shadowoffset[0], distbias * lightpos[0].w);
+ light0atten *= filtershadow(shadow0tc);
+
+
+ vec4 diffuse = gfetch(tex0, gl_FragCoord.xy);
+
+
+ diffuse.rgb *= glowscale;
+
+
+
+
+ vec3 camdir = normalize(camera - pos.xyz);
+ float facing = 2.0*dot(normal.xyz, camdir);
+
+ float light0spec = pow(clamp(light0invdist*(dot(camdir, light0dir) - light0facing*facing), 0.0, 1.0), 16.0) * diffuse.a;
+ light += (diffuse.rgb + light0spec) * lightcolor[0] * light0atten;
+
+ float foglerp = clamp(exp2(fogcoord*fogdensity.x)*fogdensity.y, 0.0, 1.0);
+ light *= foglerp;
+
+
+
+ }
+ }
+
+
+ accumlight(light);
+ accumalpha(0.0);
+
+
+
+ }
+