Jump to content
  • Advertisement
Sign in to follow this  
dukey

OpenGL Projective texture mapping to give real time relfection on water

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

I got some code to do this. And it works pretty much perfect but the problem is when i try to distort the texture coordinates. If i do this I get the affect i want but when the water surface touches the edge of the screen and opengl clips the textures on the polygons leaving white holes. And i can't figure out how to fix it. The problem I think is opengl clips the textures because the water is not planar. Well it is planar but the height texture coordinate is not zero. If i set it to zero the affect of getting holes when i distort the projective texture disappears but then the projective texture doesn't map correctly to the water surface because its simply the wrong height. Thats the only way i can describe it. I've tried multiplying the projective texture matrix by one of my own to try and distort the reflection this way but it hasn't quite worked right. heres a link to another forum post of mine http://forums.quakesrc.org/viewtopic.php?t=4070&start=0 it has some screenshots and some code on it. Hopefully you guys maybe able to give me a hand and fix it :P many thanks the line of code i am using to distort the texture coordinates is qglTexCoord3f(v[0], v[1], v[2]+ v[1]+calc_wave(v[0], v[1], rdt));

Share this post


Link to post
Share on other sites
Advertisement
Could you just change it to set the texture distortion to zero at the edges of the screen? That way you get the distortion working in the middle of the screen, and it being minorly incorrect but not ugly at the edges of the screen.

Oh, and:
<a href="http://forums.quakesrc.org/viewtopic.php?t=4070&start=0">teh linkay</a>
gives you:
teh linkay

also, the word you want is 'effect', not 'affect'.
/lenient-mode-grammar-nazi

Share this post


Link to post
Share on other sites
I'm not sure if I understand the problem correctly but I would guess that at the border of the screen, the texture coordinates into reflective texture just lie outside the reflective texture (i.e. outside [0,1]2).
To fix this, you could render the reflective texture with a FOV slightly larger than the actual FOV of the screen and use GL_CLAMP_TO_EDGE as texture clamp mode.

Share this post


Link to post
Share on other sites
You dont need to use a slightly higher fov, just use GL_CLAMP_TO_EDGE or the DX equivlent.

Share this post


Link to post
Share on other sites
na its exactly the same with GL_CLAMP_TO_EDGE
doesn't make any difference
i still get the holes down the side

Share this post


Link to post
Share on other sites
oh yeah
how on earth would i only distort the water in the middle of the screen
i have thought about this solution but have absolutely no idea how it could be done ..

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!