I'm currently learning about cube mapping, I found this tutorial: http://www.keithlantz.net/2011/10/lighting-and-environment-mapping-with-glsl/ He transform normal vector by multiplies with inverse of transposed Model
matrix. I wonder why don't he multiplies by inverse of transposed ModelView
matrix but Model
matrix?
Add a comment
|
cube map is defined in word space, it seems that the author wants to have texture coords in word space as well.
note that one normal is transformed to view space - for lighting, and the second is used only to lookup in cubemap.
two links for reference:
-
so, what different bettwen
fragNormal = ((inverse(transpose(ModelMatrix)) * vec4(gl_Normal, 0.0)).xyz
andfragNormal = ((inverse(transpose(ModelViewMatrix)) * vec4(gl_Normal, 0.0)).xyz
? And what does each one affects to texture coord? – Bình Nguyên Jan 10 '13 at 15:06 -
one normal is used for lighting and it is transformed by modelview to view space, the second one is used only for cube map, and it is in world space. Inverse(transpose(mat)) is used to properly transform normal vector. lighthouse3d.com/opengl/glsl/index.php/index.php?normalmatrix – fen Jan 10 '13 at 17:58
-
-