Results 1 to 5 of 5

Thread: Transforms, normals, lighting

  1. #1

    Thread Starter
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226

    Angry 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!
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

  2. #2
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    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.

  3. #3

    Thread Starter
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226
    Alright, I'm now transforming by the inverse transposed matrix. Still the same effect; I'm looking elsewhere for bugs.
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

  4. #4
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    You may end up re-computing the normals... however much that would suck.

    Z.

  5. #5

    Thread Starter
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226
    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.
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width