tavli

diff sdr/shadow.v.glsl @ 18:986c0b76513f

shadows, not completed
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 29 Jun 2015 01:29:36 +0300
parents
children 37dead56f01e
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/sdr/shadow.v.glsl	Mon Jun 29 01:29:36 2015 +0300
     1.3 @@ -0,0 +1,22 @@
     1.4 +varying vec3 vdir, ldir, normal;
     1.5 +varying vec4 shadow_tc;
     1.6 +
     1.7 +void main()
     1.8 +{
     1.9 +	gl_Position = ftransform();
    1.10 +
    1.11 +	vec3 vpos = (gl_ModelViewMatrix * gl_Vertex).xyz;
    1.12 +	normal = gl_NormalMatrix * gl_Normal;
    1.13 +	vdir = -vpos;
    1.14 +	ldir = gl_LightSource[0].position.xyz - vpos;
    1.15 +	gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
    1.16 +
    1.17 +	mat4 offmat = mat4(0.5, 0.0, 0.0, 0.0,
    1.18 +			0.0, 0.5, 0.0, 0.0,
    1.19 +			0.0, 0.0, 0.5, 0.0,
    1.20 +			0.5, 0.5, 0.5, 1.0);
    1.21 +	mat4 tex_matrix = offmat * gl_TextureMatrix[1];
    1.22 +
    1.23 +	shadow_tc = tex_matrix * gl_Vertex;
    1.24 +	shadow_tc = shadow_tc / shadow_tc.w;
    1.25 +}