SLIDE 23 Eye Linear Texture Coordinate Generation
- Generating texture coordinates from eye-
space
coordinates
coordinates coordinates eye coordinates eye eye coordinates coordinates modelview matrix modelview modelview matrix matrix projection matrix projection projection matrix matrix divide by w divide divide by w by w viewport & depth range viewport & viewport & depth range depth range
normalized device coordinates normalized normalized device device coordinates coordinates
clip coordinates clip clip coordinates coordinates window coordinates window window coordinates coordinates eye-linear plane equations eye eye-
linear plane plane equations equations (s, t, r, q) (s, t, (s, t, r r, q) , q) (x, y, z) (x, y, z) (x, y, z)
Setting Up Eye Linear Texgen
– GLfloat Splane[4], Tplane[4], Rplane[4], Qplane[4]; – glTexGenfv(GL_S, GL_EYE_PLANE, Splane); – glTexGenfv(GL_T, GL_EYE_PLANE, Tplane); – glTexGenfv(GL_R, GL_EYE_PLANE, Rplane); – glTexGenfv(GL_Q, GL_EYE_PLANE, Qplane); – glEnable(GL_TEXTURE_GEN_S); – glEnable(GL_TEXTURE_GEN_T); – glEnable(GL_TEXTURE_GEN_R); – glEnable(GL_TEXTURE_GEN_Q);
- Each plane equation is transformed by current inverse
modelview matrix (a very handy thing for us)
Eye Linear Texgen Transform
- Plane equations form a projective transform
- The 4 eye linear plane equations form a 4x4 matrix
(No need for the texture matrix!) s t r q s s t t r r q q
Splane[0] Splane[1] Splane[2] Splane[3] Splane[0] Splane[1] Splane[0] Splane[1] Splane[2] Splane[2] Splane[3] Splane[3] Tplane[0] Tplane[1] Tplane[2] Tplane[3] Tplane[0] Tplane[1] Tplane[2] Tplane[3] Tplane[0] Tplane[1] Tplane[2] Tplane[3] Rplane[0] Rplane[1] Rplane[2] Rplane[3] Rplane[0] Rplane[0] Rplane[1] Rplane[2] Rplane[1] Rplane[2] Rplane[3] Rplane[3] Qplane[0] Qplane[1] Qplane[2] Qplane[3] Qplane[0] Qplane[1] Qplane[2] Qplane[3] Qplane[0] Qplane[1] Qplane[2] Qplane[3]
= = = xe ye ze we x xe
e
y ye
e
z ze
e
w we
e
Shadow Map Eye Linear Texgen Transform
1/2 1/2 1/2 1/2 1/2 1/2 1/2 1/2 1/2 1 1 1 1/2 1/2 1/2 1/2 1/2 1/2 1/2 1/2 1/2 Light frustum (projection) matrix Light Light frustum frustum (projection) (projection) matrix matrix Light view (look at) matrix Light Light view view (look at) (look at) matrix matrix Inverse eye view (look at) matrix Inverse Inverse eye eye view view (look at) (look at) matrix matrix Eye view (look at) matrix Eye Eye view view (look at) (look at) matrix matrix Modeling matrix Modeling Modeling matrix matrix
xo yo zo wo x xo
yo
zo
wo
ye ze we x xe
e
y ye
e
z ze
e
w we
e
= = = = = =
xe ye ze we x xe
e
y ye
e
z ze
e
w we
e
s t r q s s t t r r q q
glTexGen automatically applies this when modelview matrix contains just the eye view transform glTexGen automatically applies glTexGen automatically applies this when modelview matrix this when modelview matrix contains just the eye view contains just the eye view transform transform
Supply this combined transform to glTexGen Supply this combined transform to glTexGen Supply this combined transform to glTexGen