I used some of the dino.c sample code to draw some reflections and it works pretty well. However, I have noticed that sometimes I get some weird stuff happening when the object to reflect is “behind” the reflective surface.
I compiled and ran the dinoshade example at http://www.opengl.org//resources/code/samples/glut_examples/examples/examples.html. It worked fine. Then I modified the program to allow the dino to draw on the “under” side of the floor. This was easy, I just changed the line the idle routine (about line 667) from
jump = 4.0 * fabs(sin(time)*0.5);
jump = 30.0 * sin(time)*0.5;
This allows the dino to pass throught the floor. Once he is about 1/2 way through the floor, his legs are drawn under the floor (as they should be) and his head is reflected in the floor. However the legs also show above the floor and overtop of his head.
This basically recreates the problem of drawing without using the stencil buffer. Only the stencil buffer was used.
What’s the bext way to correct this?