summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2009-07-31 13:07:23 -0700
committerEric Anholt <eric@anholt.net>2009-07-31 13:07:23 -0700
commitee5cdc64d2edf60aa5509e51e1bf98c2969b520a (patch)
treee988270e2c8cde976d97ed6699cb9851141e4b08
parente38f1c7ef8136b845e0e54eb68cfa6caaa0e4da6 (diff)
Fix the viewport transform of world to shadow texcoords.
Math is hard.
-rw-r--r--ground.c6
-rw-r--r--ground.vert3
2 files changed, 5 insertions, 4 deletions
diff --git a/ground.c b/ground.c
index 558452b..382d0dd 100644
--- a/ground.c
+++ b/ground.c
@@ -62,11 +62,11 @@ install_ground_transform(void)
*/
memcpy(&temp, &gluIdentityMatrix, sizeof(gluIdentityMatrix));
temp.col[0].values[0] = (1.0 - 0.0) / 2.0;
- temp.col[0].values[3] = temp.col[0].values[0] + 0.0;
+ temp.col[3].values[0] = temp.col[0].values[0] + 0.0;
temp.col[1].values[1] = (1.0 - 0.0) / 2.0;
- temp.col[1].values[3] = temp.col[1].values[1] + 0.0;
+ temp.col[3].values[1] = temp.col[1].values[1] + 0.0;
temp.col[2].values[2] = (1.0 - 0.0) / 2.0;
- temp.col[2].values[3] = (1.0 - 0.0) / 2.0;
+ temp.col[3].values[2] = (1.0 - 0.0) / 2.0;
gluMult4m_4m(&world_to_shadow_texcoords, &temp, &world_to_light_ndc);
diff --git a/ground.vert b/ground.vert
index f4d7713..4fbfe4d 100644
--- a/ground.vert
+++ b/ground.vert
@@ -15,7 +15,8 @@ void main()
*/
gl_Position = mvp * gl_Vertex;
vertex_eye = vec3(mv * gl_Vertex);
- shadow_coords = (light_mvp * gl_Vertex).xy;
+ vec4 temp = light_mvp * gl_Vertex;
+ shadow_coords = (temp).xy / temp.w;
/*
mat3 tbn = mat3(t,
cross(n, t),