lighting problems

Started by
2 comments, last by INVERSED 20 years ago
Hey all, I was wondering if anyone else has ever had this problem and might recognize it. I wrote a model exporter for milkshape recently, and I have my model displaying on the screen and everything, but there not much light seems to be getting to it, which I wouldn''t find wierd normall, but if I have it constantly rotate, every now and then it goes to full brightness. Anyone know what to do about that?
Write more poetry.http://www.Me-Zine.org
Advertisement
If you''re using shaders, you may have forgotten to transform the normals of your mesh along with its position. When you rotate a mesh, the normals of the mesh need to be tranformed as well.

However, because of the way the 3D math works, you can''t always transform the normals of a mesh with the same matrix you use to transform the vertices of the mesh. Do a search for something like "transforming normals" if you''re not sure what I mean.

If I remember correctly (brain is mush right now after having pulled an all-nighter), the matrix to transform normals is:

Mn = ( (M)^-1 )^T

This says that the Matrix to transform normals (Mn) is equal to the transpose (that''s the ^T part) of the inverse (that''s the ^-1 part) of the mesh''s original transformation matrix used to move the mesh around the scene.

neneboricua
hmm... not using shaders. I''ve never had to worry about transforming my normals before (I''ve used the same code to render a terrain with lighting). I wonder if maybe there is an issue with the normal as they are being exported from milkshape
Write more poetry.http://www.Me-Zine.org
If you''re using the fixed function pipeline, D3D takes care of transforming the normals for you. That''s why you''ve never run into that problem. When you use shaders, you''re responsible for all this kind of work. It''s easy to forget to transform normals when writing your shaders.

Your problem still sounds like it has something to do with the normals. If rotating your mesh causes lighting to work at some orientations and not others, it really sounds like a problem with your normals. Double check how the normals are being exported and that all your code dealing them is ok.

Perhaps other forum members will have other ideas about what could be the problem.

neneboricua

This topic is closed to new replies.

Advertisement