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?

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.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.