DirectX version of gl_NormalMatrix

Started by
6 comments, last by Evil Steve 16 years, 1 month ago
I was wondering if anyone knows what the equivalent DirectX code is for the OpenGL function gl_NormalMatrix()? Thanks.
Enoch DagorLead DeveloperDark Sky EntertainmentBeyond Protocol
Advertisement
What does gl_NormalMatrix do? Is it only used in GLSL? I can't find a reasonable explanation through Google.
Well, that's basically what I'm asking. :)
Enoch DagorLead DeveloperDark Sky EntertainmentBeyond Protocol
Yes gl_NormalMatrix() is for GLSL.
Quote:Original post by Evil Steve
What does gl_NormalMatrix do?

gl_NormalMatrix is the upper-left 3x3 part of the ModelViewProjection matrix (i.e. the rotational-component of the model-space to view-space transform). So multiplying a normal by gl_NormalMatrix transforms the normal into screen space.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

What are the other parts to be set to? 0 or 1?
Enoch DagorLead DeveloperDark Sky EntertainmentBeyond Protocol
Quote:Original post by EnochDagor
What are the other parts to be set to? 0 or 1?


It is a 3x3 matrix, so there are no other parts. If you want to do the same with a 4x4 matrix (which is more expensive to multiply), I believe you can do it by setting the remaining row and column to match the identity matrix:

N N N 0
N N N 0
N N N 0
0 0 0 1

Edit: actually, I am not all that sure about this, it would be great if someone could confirm.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Ah, I see. In that case there's no D3D equivalent. This thread is relevant I think.

This topic is closed to new replies.

Advertisement