Jump to content
  • Advertisement
Sign in to follow this  
jayhs

Water Reflection

This topic is 4719 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

Hail all, Even though this topic has been talked and taught so many times, my intelligence still doesn't allow me to implement this right. The one part that I never get it is the right order to mutiply the matrix together. From previous threads, I came to this conclusion: //first pass glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(...);// set objs into camera space? glScalef(1,-1,1);// reflect the geometric glTranslatef(0,2*camera.y,0);// not sure if I need this or not... glEnable(GL_CLIP_PLANE0)// plane = 0,-1,0,2h(water height) glFrontFace(GL_CW); render_objs(); glDisable(GL_CLIP_PLANE0); //second pass glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(...); glFrontFace(GL_CCW); render_objs(); render_water); Above is what I think the correct order. Please correct me if anything is worng with that. Thanks All

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Hail again,

I made it working now! And there was something wrong about my method posted above. The correct one(or at least works for me) is as following:

//first pass
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glScalef(1.0f, -1.0f, 1.0f);
glTranslatef(0.0f, -2*h, 0.0f); // h = your water height
glEnable(GL_CLIP_PLANE0);
glClipPlane(GL_CLIP_PLANE0,frontPlane);// plane = 0,1,0,-h
render_obj();//render object and use glCopyTexSubImage2D bind to texure
glDisable(GL_CLIP_PLANE0);
//second pass
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
render_obj();
render_water();// use the texture we saved from first pass

For the texture, I use projective texture mappinp.

Share this post


Link to post
Share on other sites
I thought I'd just reply and say I gave you a + on your rating for posting the fix. Almost everyone seems to take their fix and leave everyone wondering.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!