LWJGL Forum

Programming => OpenGL => Topic started by: elias4444 on November 11, 2005, 23:03:08

Title: Wave distortions
Post by: elias4444 on November 11, 2005, 23:03:08
Ok, I've been trying to do something like this for a while... I want to take the generated 3D scene and then add a distortion to it (like a rippling effect, or a glass lense effect). Cas, I know you do that in your Super Dudester game somehow whenever you finish a level. How do you do it?

Any help would be greatly appreciated.
Title: Wave distortions
Post by: Orangy Tang on November 12, 2005, 15:35:06
glCopyTexSubImage will copy a section of the framebuffer into a texture for you. You can then re-render this back to the screen with some kind of deformation applied.

Per-pixel deformation looks rather nice, but unfortunalty you can only do that cross-vendor with GLSL. If you want something that'll work everywhere you'll need to do the distortion per-vertex by tinkering with the texture coords.
Title: Wave distortions
Post by: darkprophet on November 13, 2005, 02:11:14
if you are refering to the distorsion effect I think your referring to, heres a way to do it:

glCopyTexSubImage to a texture
Load a square grid and set each texture coordinate of that vertex to be its position relative to width/height of grid (i.e., middle = 0.5, 0.5)
Use sin (or cos) waves to move the vertices up/down, giving you that effect. The higher tesselated the grid is, the better the effect.

Simple really :)