|
-
Dec 5th, 2002, 05:58 PM
#1
Thread Starter
Frenzied Member
Transforms, normals, lighting
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!
-
Dec 5th, 2002, 07:02 PM
#2
Frenzied Member
Think about it. If you have a random face normal, and scale it by <1, 2, 1>, the resulting normal has it's y value increased, when it should decrease instead.
Think about it. If you non-uniformly scale, the normals don't get
transformed the same way. Draw a couple of examples on paper to convince
yourself. To properly transform normals when you have an abitrary
matrix, you need to multiply by the inverse transpose. (You'll note that
in the case of an orthogonal matrix, i.e. one with just rotations, the
inverse transpose is exactly the matrix you started with - as expected).
Tony Cox - Development Lead, Hockey
Microsoft Games Studios - Sports
Z.
-
Dec 5th, 2002, 09:48 PM
#3
Thread Starter
Frenzied Member
Alright, I'm now transforming by the inverse transposed matrix. Still the same effect; I'm looking elsewhere for bugs.
-
Dec 6th, 2002, 09:28 AM
#4
Frenzied Member
You may end up re-computing the normals... however much that would suck.
Z.
-
Dec 6th, 2002, 11:50 AM
#5
Thread Starter
Frenzied Member
You don't comprehend the problem. The normals are fine. It is the transformations that are the problem. Recomputing rotated normals is slightly impossible without using ... GASP... rotation transforms.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|