Water Reflection

Started by
1 comment, last by Boruki 18 years, 10 months ago
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
Advertisement
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.
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.

This topic is closed to new replies.

Advertisement