X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=antikythera;a=blobdiff_plain;f=sdr%2Fshadow.v.glsl;fp=sdr%2Fshadow.v.glsl;h=8f9f045b93497359e22f6551ddbcc352cf8440c8;hp=0000000000000000000000000000000000000000;hb=ccc1a688b59e25bb934a0d3e2bbf477960068d4f;hpb=080d7a779d43f549fc16c44e709cbf5989180fdf diff --git a/sdr/shadow.v.glsl b/sdr/shadow.v.glsl new file mode 100644 index 0000000..8f9f045 --- /dev/null +++ b/sdr/shadow.v.glsl @@ -0,0 +1,27 @@ +uniform mat4 envmap_matrix; + +varying vec3 vdir, ldir[3], normal; +varying vec4 shadow_tc; +varying vec3 wdir; + +void main() +{ + gl_Position = ftransform(); + + vec3 vpos = (gl_ModelViewMatrix * gl_Vertex).xyz; + normal = gl_NormalMatrix * gl_Normal; + vdir = -vpos; + wdir = (envmap_matrix * vec4(vdir, 1.0)).xyz; // bring back to world space + ldir[0] = gl_LightSource[0].position.xyz - vpos; + ldir[1] = gl_LightSource[1].position.xyz - vpos; + ldir[2] = gl_LightSource[2].position.xyz - vpos; + gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; + + mat4 offmat = mat4(0.5, 0.0, 0.0, 0.0, + 0.0, 0.5, 0.0, 0.0, + 0.0, 0.0, 0.5, 0.0, + 0.5, 0.5, 0.5, 1.0); + mat4 tex_matrix = offmat * gl_TextureMatrix[1]; + + shadow_tc = tex_matrix * vec4(vpos, 1.0); +}