I’m currently trying to build my own lighting system (Phong) and have some trouble with the normals I need for the calculation.
I know I can get the world coordinates of each vertex by applying the spatials world transformation to it, but as far as I know I need the inverse transpose matrix for the normals.
So now I’m a bit lost with the transform object I get via getWorldTransform, is it possible to get the transformed normal with this one or is my idea of doing it already wrong?
Thanks in advance for any help!
You could try:
Edit: and make sure to multiply only for rotation… so leave the 4th component of the vector 0.0 instead of 1.0.
Is there a reason you are writing your own lighting instead of just dismantling the existing phong lighting shader?
Hey, thanks for your answer, so I guess I need to take a look at the shader tutorial before trying this…
I have to do this for university, so just dismantling the existing one won’t count.
@irreparabel said: Hey, thanks for your answer, so I guess I need to take a look at the shader tutorial before trying this... I have to do this for university, so just dismantling the existing one won't count. ;)
Well, you should at least look at it so you how values are configured, I guess. Or maybe the shader tutorial covers the global bindings already.
Edit: note: JME’s lighting shader does lighting in view space… if you were also doing lighting in view space then you could also use the pre-existing NormalMatrix.