Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

ApochPiQ

Transforms, normals, and lighting

This topic is 5730 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have an object under the scale transformation <1,2,1>. The shape and location of the object is correct, but lighting is not. Specifically, the diffuse shading of the object appears to move when the camera rotates. When the scale is changed to <1,1,1> this does not occur. I am doing the following in my code: - Transform ray by inverse matrix of the transformation - Test intersection - Transform intersection point by transformation (return to world coordinates) - Transform surface normal by inverse matrix - Light as normal The lighting model works fine, and the shape of the object is correct. The matrix math is fine. As near as I can tell, the problem is with the surface normal, but I can''t figure out what the problem IS. Any insight would be greatly appreciated!

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
See this thread: http://www.gamedev.net/community/forums/topic.asp?topic_id=124638

Share this post


Link to post
Share on other sites
Unfortunately I''m using a custom rendering engine at the moment, so I can''t make use of DirectX or OpenGL. Transforming normals is a piece of cake with either one :-)


I''m now transforming the normal by the inverse transposed matrix as suggested in the thread linked to in the anonymous post above [thanks btw]. This seems to have some effect on the lighting but its still off. I did find a bug in the point->world transform code I was using, so now I''ll see if a similar problem is present in the normal->world transforms.

Thanks again for the input.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
>I''m now transforming the normal by the inverse transposed matrix as suggested in the thread...

But didn''t you transform the normal using the inverse matrix before? In that case I think you should try the transposed but non inverse matrix instead.

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
>I''m now transforming the normal by the inverse transposed matrix as suggested in the thread...

But didn''t you transform the normal using the inverse matrix before? In that case I think you should try the transposed but non inverse matrix instead.



Tried the transposed pure matrix; still the same incorrectness. I don''t know if the bug is actually in the transform code; I''m beginning to suspect that it is a sign issue somewhere else in the code, because it behaves like the normal is pointing the wrong way. Agh!

Share this post


Link to post
Share on other sites
Someone mentioned the transpose and the inverse matrix... I assume they mean that the inverse of a rotation matrix is the transpose (correct). But that''s not the inverse of a scale matrix, the inverse is another scale matrix scale factors 1/x, 1/y, 1/z.

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
>I assume they mean that the inverse of a rotation matrix is the transpose (correct).

No, that was not what was meant. The inverse of any (invertable) transformation matrix can be found using standard methods. The question was how to apply a transformation matrix to a normal vector.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!