Jump to content
  • Advertisement
Sign in to follow this  

Reflection Problem

This topic is 4569 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all: I have a problem when I am drawing the reflections. My code is like following:
void Reflection(){
    glStencilFunc(GL_ALWAYS, 1, 0xffffffff);

    glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
    glStencilFunc(GL_EQUAL, 1, 0xffffffff);  /* draw if ==1 */
    glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
	glScalef(1.0f, -1.0f, 1.0f);
Outside this function I have enabled GL_BLEND and drawn the floor. The problem is that the object under the floor plane is always drawn as well. And I don't know how to remove it to just remain the reflection. I tried the method in NeHe's tutorial which uses glEnable(GL_CLIP_PLANE0); glClipPlane(GL_CLIP_PLANE0, eqr); glDisable(GL_CLIP_PLANE0); around the push and pop matrix. But it removed the reflection at the same time when I used it. Does anybody know where's the mistake please??? Thanks very much!!!

Share this post

Link to post
Share on other sites
When you are using the clip plane, are you sure that your plane normal is pointing to the right direction.

Is your plane in the correct space? For example in DX with shaders the clipping plane isn't in world space.

Edit: I am not familiar with the stencil mask for doing reflections, but I can imagine that there might be some issues with the z-buffer when doing it like this.

Share this post

Link to post
Share on other sites
Yeah, I am very sure the plane normal is pointing the right direction. I believe the stencil buffer works fine but I just don't know how to remove the extra object.
How can I add screen shot on the message please? So I can express my problem a bit clear.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!