Let's say I have my normals in worldspace and I want to transform them into viewspace. What should I do? I have already tried to multiply them by viewProjection matrix and by inversed transformed view matrix, but both didn't work. Blue channel (z axis) appears to be missing. I am confused.

- 703
- 2
- 8
- 19
-
How do you visualize your normals? If you just do somehting like `out_color.rgb=normal`, all the negative components of your normal will be clamped to 0. – derhass Apr 06 '14 at 12:33
1 Answers
on fixed pipeline do nothing it does the work for you
to work properly all world/object transforms should be inside modelview matrix else some advanced things like FOG will not work properly (ie
GL_PROJECTION
matrix abuse) but in most cases you do not see a thing ...on shaders you can handle lighting your self so this is the way
point' = object_2_world_matrix * world_2_camera_matrix * projection_matrix * point vector' = object_2_world_matrix(with origin 0,0,0) * world_2_camera_matrix(with origin 0,0,0) * vector
object_2_world_matrix
is transformation matrix representing rendered model spaceworld_2_camera_matrix
is inverted transformation matrix representing camera space
Z axis is usually view directionprojection_matrix
is just perspective matrix (used for rendering ...)you can make any matrix with origin
(0,0,0)
by setting its12,13,14
element to zero (elements are0,..,15
)
You did not remove matrix positions which transforms normal vectors to position of vertex ... That is the reason for weirdness ... so either substract the offset of matrices from the result or multiply by matrices without offset (origin = (0,0,0)
)

- 49,595
- 11
- 110
- 380
-
Your matrix multiplications are in reverse or transposed. Usual notation in computer graphics is vectors are column, and matrix multiplication is right-to-left (matrix multiplication is non-commutative). – datenwolf Apr 06 '14 at 11:44
-
oh you are right ... my mistake (I am a bit ill so i miss it) ... it shoud be reverse (as I use it too) I will edit it in while ... thx for pointing it out the element 12,13,14 stays as is (in that previous case it would be 4,8,12) – Spektre Apr 06 '14 at 14:09