Water reflections

Hi

On my landscape engine i made some water reflections with the use of a clip plane and inverting the landscape, something like this:

push matrix
Enable clip plane;
scale(1,-1,1);
draw landscape;
disable clip plane;
pop matrix

push matrix
enable clip plane
draw landscape;
disable clip plane
pop matrix

I have seen that drawing the landscape 2 times without the clip plane is faster than rendering them with a clip plane.,
my performance was this:

rendering 2 landscapes : 90 fps
rendering 2 landscape/with a 2 clip planes : 44 fps
A friend of mine told me that we loose hardware clip planes when using more than 2 texture stages, and as i’am rendering with multitexture…, maybe the clipplane is working in software mode…, any ideia on this ?

So, now i wanna try to render the reflection to a texture(using the clip plane only once), and i have tried it, but i have some problems…

what i do is this:

push matrix
glViewPort(256,256);
Enable clip plane;
scale(1,-1,1);
draw landscape;
glBindTexture(GL_TEXTURE_2D,land.water_texture);
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 256, 256);
disable clip plane;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glViewPort(800,600);
pop matrix

Now my problem is mapping the texture correctly to the water…,
How do i do it ?
My water has several strips, and my coordinates are generated in a way that i can map an 256x256 texture to entire water, but when i map the texture i get, she is strange, streched along the water…,
I was told that i must use automatic texture generation with GL_TEXTURE_GEN_S and GL_TEXTURE_GEN_T…, but not working, and honestly it doens’t make much sense to me.

What’s the trick? if any

thanks,

Bruno

I can’t help you but I have a question what is your 3D card because 90fps for 2 landscape !! it is very very very very fast
thanks

[This message has been edited by IronRaph (edited 06-20-2002).]

The user clip plane uses one texture unit, so if you don’t have a texture unit left, it is done in software.

You could do it with the stencil buffer:
render the landscape normally
render the water plane and set a stencil bit when depth test passes
render the inverted landscape only to the pixels marked in the stencil buffer

I hope that helps
Overmind

Bruno: Search for “Water reflection” on this forum. There is a topic about how to do relfections far more effective using pbuffer and texture reflection. I am developing a new landscape engine for my firm at the moment too and I was curious about the best solution for this and I think that it is. Clipping planes are a solution, but to use a texture is the far more senseful way:
-bump mapped water with ribbling, reflecting and still showing the water world below without getting limitation problems and so on.

IronRaph: 90fps, so 180 fps for a single drawn landscape is not so much. My actual one is running at 280 fps with shadows and some hundred trees in it and it is still unoptimized. And my Athlon 600 is all then what’s up to date. Ok, my GeForce 3 relative still is… also if I hope NVidia will sponsor us some of the new GeForce 4s again soon at ECTS in London coming autumn like last year the 3s. The problem is simply… look: You are at 280 fps. Then still all the non-landscape objects, houses, vehicles, monsters, what game ever you are programming. The landscape shall look good, yeap, but it’s unfortunately not the only thing you have to get done within a frame. And anything like the 180 fps of him are really at the lowest edge for the pure landscape, 90 already far too low. But well, this is always depending on where for it shall be used. In our case… a 3D strategy game… the AI costs more than a bunch because of the complex calculations it has to do. Imagine I would already be now down at 100 fps with my landscape. With the AI at 50 then and with all the other objects at 10? This would be unplayable and nobody would ever buy nor publish it, so I think you know, what I try to say. There are many ways to get speed and win FPS. My first landscape was also at 40, hehe, but well, anytime you learn how to get things faster .

Michael

Here’s a link to a screenshot of a water demo i’m working on at the moment:
http://3ddev.9f.com/water/water.html

Still a lot to do, but as you see, it’s possible to make pretty realistic water with pixel shaders :slight_smile:

Y.

Could you show a wireframe of that image for us?
Also, how does your lod work as your viewpoint goes higher? You’re rendering the water to the horizon, I assume?

Ok, i posted a wireframe shot on the site. Not much to say, it’s tesselated to less than 3000 triangles.

The LOD scheme is only based on the distance to the viewer. The interesting thing is that it’s not based on a grid: i generate a lot of circular segments (the distance between each segment increasing with the distance to the viewer), and then triangulate the whole thing. This is done at load time. Then i just need to deform vertically each vertex based on the position into the water heightmap, and update the normals and stuff. Performance is not very good because there’s very little optimizations in that area. I’m now going to use a vertex shader to do all these calculations.

The LOD doesn’t work with the viewpoint height, but it would be pretty easy to modify to do so (scale the water mesh based on the viewpoint height). For now, the view distance is around 1.5 Km.

Y.

hmmmm…, my question is one year old
How the hell you guys digged it up ?
I fixed it already, don’t remember how…, this has 1 year

Bruno

Originally posted by Ysaneya:
[b]Ok, i posted a wireframe shot on the site. Not much to say, it’s tesselated to less than 3000 triangles.

The LOD scheme is only based on the distance to the viewer. The interesting thing is that it’s not based on a grid: i generate a lot of circular segments (the distance between each segment increasing with the distance to the viewer), and then triangulate the whole thing. This is done at load time. Then i just need to deform vertically each vertex based on the position into the water heightmap, and update the normals and stuff. Performance is not very good because there’s very little optimizations in that area. I’m now going to use a vertex shader to do all these calculations.

The LOD doesn’t work with the viewpoint height, but it would be pretty easy to modify to do so (scale the water mesh based on the viewpoint height). For now, the view distance is around 1.5 Km.

Y.[/b]

I noticed on your webpage that you are uploading a bump map every frame? For a lot of our water effects we usually scroll two copies of the same bump map in different directions, sum and average their vectors per pixel and use this to index the environment map and fresnel map. This might give you better performance (and it looks really cool). You can see this in action in the ATI Ocean Water Screen Saver: http://www.ati.com/developer/screensavers.html

[This message has been edited by chrisATI (edited 06-21-2002).]

Mmm, I experimented with that technique to do terrain (circular mesh). So the radius increment gets larger the larger the radius…and you add an offset onto the translation of the mesh, modulating this offset with the maximum radius step? Sort of like circular tiling…
I could never get good results moving through the terrain (the terrain would undulate too much with the perlin noise function).

Yep, i’m uploading the bump map every frame. Actually i convert the noise heightmap to a bumpmap on the CPU each frame, then i upload it to the GPU. It’s not that slow, because i’m using pretty low-res textures (128x128 at the moment). This probably explains why i get very visible repeating patterns on the look of the surface, when flying at more than a few meters. Did your ocean screensaver suffer from the same thing ? Your bumpmap technic sounds interesting, i might try it when i’ll increase my bump resolution. I did a few benchmarks, and to my great surprise, it looks like sending the vertices to the card is the main bottleneck. I must admit cough that i’m using immediate mode so…

About the ocean screensaver: true that it looks very cool, and pretty fast too. I never saw it before, but it looks pretty similar to my demo (even the skybox has the same “ambiance”, or the waves have the same animation). The reflections look a bit strange though… is it a true per-pixel reflection (2*(N.E)*N-E) or just a trick?

Knackered: you’re right for the radius increment. And i don’t know for the terrain, but i’d say ondulation onto water is much less a problem than for a landscape :slight_smile:

Y.