Projective texture mapping to give real time relfection on water

Started by
5 comments, last by dukey 19 years, 6 months ago
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));
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
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.
You dont need to use a slightly higher fov, just use GL_CLAMP_TO_EDGE or the DX equivlent.
its in opengl
i've give GL_CLAMP_TO_EDGE a got
thx :)
na its exactly the same with GL_CLAMP_TO_EDGE
doesn't make any difference
i still get the holes down the side

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 ..

This topic is closed to new replies.

Advertisement