Skip to main content
gamedev.net
🔒 Locked 🎮 Unity

Light transformations

Started by GeneralQuery Oct 31, 2011 at 9:44 PM 3 replies 850+ views
Original Post
GeneralQuery
GeneralQuery
When lighting in object space, I transform the world space light position into object space by multiplying by the object's inverse world matrix. However, I read that when lighting in view space, you should transform the world space light position by only the rotational part of the view matrix. Why is this?
Jason Z
Jason Z
Where did you hear that? Unless there is a special context behind that statement, I don't think it makes any sense to leave out the translation component (or scaling for that matter) when you are moving a position from world space to object space...
Jason Zink :: DirectX MVP   Direct3D 11 engine on CodePlex: Hieroglyph 3 Direct3D Books: 
MJP
MJP
Typically the only time you want to ignore the translation component of a matrix is when applying it to a direction vector, such as a normal. For positions you usually apply the translation. For a light position transformed by a view matrix, you definitely want to apply the translation.
GeneralQuery
GeneralQuery
Ah yes, that makes perfect sense. I did wonder why that would be the case, in my head it did not fit with my understanding of transformations into different spaces. Thanks for clearing that up, guys.
Scoob Droolins
Scoob Droolins
If it's a directional light (like the sun), you could just do a rotate-only instead of a full translate/rotate. This would save you from having to renormalize the light vector.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.