I’m trying to render my scene to a texture then project it onto a water plane, and so far it works except for one little problem. When i’m looking at the water plane, on both sides of the viewing volume, the texture has been cut off. Here’s what i’m talking about.
If I render to the screen what I render to the texture, its just a square block on the screen and has exactly what is suppose to be rendered.
But I tried changing the aspect ratio in the projection from 1, to the same aspect when rendering normally, since 256/256 = 1.
Anyway, that got rid of the side cutoffs, but now if I zoom way out or zoom way in, the reflection becomes distorted or moves away from the actualy geometry it is underneath.
Here’s two screenshots of it actually working working working
But if I zoom way out and move from side to side, then the reflection of the mountains in the water moves away from the actualy terrain.
And if I zoom in, it becomes distorted like in these screenshots working working
Well maybe the flattening of the hills is normal, but what about that cuttoff problem? The only thing I can figure is that somehow the viewport isn’t being stretched right or projected correctly.
Here are some more screenshots of what I’m talking about.
I show what’s being rendered to texture as well as the actual scene in these 2 images so you can see how it must be something wrong with the projection. Or at least I think.
Well, when you ‘squash’ the reflected landscape, you’re doing so by tilting the quad onwhich the reflection is rendered. Normally that will expose skewed edges that are a bit too small.
I wouldn’t know how to fix this, other than stretching your quad along with its texture coordinates, based on the amount of ‘tilt’.
Well there is no quad that is being rendered to. Its simply the screen itself. If you look at the small window I’ve created, you see exactly what is being rendered to the texture. My problem is that the water plane does not ‘stretch’ the texture correctly when i zoom in too close, that’s the problem. Something is wrong with the projection.
Well now that I figured out what I was doing wrong, does anybody have any suggestions or links to sites that show how to do water distortion? Preferably a vertex shader technique or just plain old math on the cpu.