Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Touching Objects

  1. #1
    Newbie Newbie
    Join Date
    Aug 2013
    Posts
    3

    Touching Objects

    Say I'm drawing two objects that are lit with specular, diffusive and ambient lighting (specular and diffuse lighting coming from a single source), using shaders and a classic lighting model (e.g. like the one in the OpenGL Red Book). Shadow mapping has been included so if one object passes between the other object and the light source, a shadow is cast.

    Now imagine that the two objects touch, in line with the direction of the light. If the objects are the same size and shape, the one in front won't cast a shadow on the one behind (will it?) other than on the hidden face. It seems to me that in this case maintaining the same normals for each of the shape vertices is incorrect, e.g. the calculated normals should only take into account the "visible" faces at this point.

    So my question is - should I update normals when objects touch to get the lighting right?

  2. #2
    Newbie Newbie
    Join Date
    Aug 2013
    Posts
    3
    I've answered my own question.

    I was using a single vertex location and normal for each vertex on my object (e.g. a cube; 8 vertex locations, 8 normals). When the shapes touch I think this would have meant I would have had to have updated my normals to get the lighting right.

    Instead of doing this I used a single vertex location and normal for each face (e.g. a cube; 6 faces, 4 vertices per face = 24 vertex locations, 24 normals). Doing it this way I don't need to update my normals, if two faces are touching they are hidden anyway but adjacent faces just carry on reflecting light like they did before.

Posting Permissions

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