water question

so, I got it… for sure not the best looking water ever rendered by a computer, but for a start (and my first program EVER with anything above OpenGL 1.2 ), it is quite ok (it’s animated, looks great, at least so do I think g)… what do you think? I would appreciate any comments… please be honest .
http://de.geocities.com/westphj2003/water.html

Jan

You want an honnest answer? Ok :slight_smile:

To me it looks like a simple texture mapped plane with a kind of “glow” effect. Maybe it’s better animated, but it certainly does not look like water at the moment. It does not even look reflective.

Y.

hm. I really think it looks (at least a little bit ) like water in an ocean viewed from a certain distance, like flying over it in a helicopter. It is not texture mapped at all and is bump mapped with specular hightlights, I don’t know if one would call that “reflective”, and the waves are moving (perlin noise). I really think it looks quite like water

Jan

at the first view i thought the same as ysanyena; but the other screenshots looked more real, if you ask for my opinion.
but i think a video or executable for everyone here wouzld be the best way to make a real pic of your algorithm.

posting an executable is impossible as it is part of a copyright protected piece of software, and it would be a lot of megabytes, too . But I would like to capture a video if only I knew how? Is there a program that captures what’s going on on the screen and stores is as an mpeg file, and does all this under linux?

The algorithm is extremely simple, it’s a 2D Perlin noise function generating a heightmap, which is turned into a normal map, which is rendered in two passes (diffuse and specular), using tex_env_combine_arb (or whatever it is called ), no nv register combiners, no vertex or fragment programs, only me learning to do bump mapping . And then, there’s not one but 100 normal maps, generated from 100 heightmaps (kind of an animated perlin noise function) which are cycled, so it looks really moved, like an ocean with heavy weather and strong rain… If it’s possible I would really like to capture a video and post it.

Jan

I did not read the whole thread, but I wanted to reply to some of the things I saw in the first few posts, and give some advice based on my experience with implementing water rendering.

First of all, fresnel refractions are only applicable to shallow water in which you can see through to the bottom, and therefore are not used in oceans at all. Plus, the technique used to achieve them is best suited to man-made geometry like a swimming pool, and not for things like shallow ponds. Fresnel refractions arent what make the water look less plastic. In actuality, water looks plastic if the intensity of the cube map (cube maps are used for reflections and other coloration effects - see Jensen’s article) is too high. This can be reduced by using alpha transparency and fiddling with texture combine settings with GL_ARB_texture_env_combine.

As for real-time generated bump maps (or precalculated ones, for that matter), what Jensen is referring to is EMBM using a bump map and a cube map. I have not been able to implement the EMBM technique because my video card does not support the neccessary extensions, but this will give you a huge improvement over a cube map with normals specified per vertex.

A note on calculating bump maps, waves, etc. I would not suggest trying to calculate this stuff in real time. I found an open source demo that implements many of the techniques described in Jensen’s paper. I hacked it to do two things: create an animation that will repeat after a certain amount of frames, and write this animation (wave geometry and bump map) out to a binary file which is then loaded by my program. If anyone is interested, I will make my hack available on my website. Using the precalculated animation is much easier to implement, and runs much faster, but it requires a significant amount of memory.

I would say that you can count on at least using one texture unit for a cube map. The cube map should be taken from your skybox, and modified in an image program to add a transparent gradient over the skybox image which will give you different colors based on the viewing angle. After you do this, the cube map for the water will be darker/bluer/greener than your actual skybox image. You can then “re-burn” in the image of the sun to get highlights from the sun.

Btw, here are the latest screenshots of my water engine (top 3 are newest) http://users.ms11.net/~ioquan/j2.html .

I was going to write a tutorial on water rendering, but I was never satisfied with the results I achieved. This is mainly because I couldnt do the EMBM effect with my video card.

just looked over the rest of the thread…

A couple of you guys have some realllly nice screenshots. They kind of put mine to shame.

Just wait til I get a hold of hardware that can do vertex, texture, and fragment programs though

loquan i almost did the same as you, I just don’t have a reflection but simple blue color and bump mapping with white specular hightlist, but the water surface (=normal maps) are precalcuiated and simply cycled. I agree that an ocean is not translucent at all if it’s not very shallow, so if you think of the sky being simply blue, a simple blue bumpmapped plane is not so wrong .

what is your water animation based on? I implemented some kind of “animated perlin noise”.

Jan

ioquan:
you misunderstood what the fresnel-reflectance is. It gives the relation between how much light is reflected and how much light is refracted in a point of the surface, depending on the normal and view-vectors.

If you don’t want to use refraction because of the reasons you mentioned, then just set the refracted part to a constant colour (which will be the colour of your water).

You say one should fiddle with the intensity of the cubemap. Fresnel is the physically correct way to calculate this. If done right, it will look flawless.

do you have any links regarding fresnel? I couldn’t find anything I understood .

Jan

vember, doesnt the Fresnel term also determine the direction of the reflection or refraction vector?

In my case, since I dont have access to fragment programs, texture programs, or vertex programs, I simply use a cube map with GL_REFLECTION_MAP to do reflections of the sky. The amount of reflection or refraction (refraction is simulated with an animated texture) in my demo comes from the alpha channel encoded into my cube map which is used in texture combining operations.

yes, I mistakenly supposed it was covered by another formula, but both the reflectivity and refraction angle/vector can be derived from it. (the reflection angle is trivial because it doesn’t depend on the IRO, aka ‘index of refraction’)

I didn’t find any nice url to explain it all but you can have a look at my matlab-code that I use to generate tables for this use.

This will build a table of 256 values that represent the range [0…1]. It should be fed with the dot-product of the normal and the vector between the camera and the point on the surface being rendered. If used as a 1-D texture, it should be clamped to the [0…1] range.

% fresnel reflection
n = 1.33; %IOR of water

for a=0:254
alfa = acos(a./255);
theta = alfa./n;
F(a+1) = 0.5.*( (sin(alfa-theta)./sin(alfa+theta)).^2 + (tan(alfa-theta)./tan(alfa+theta)).^2);
end
F(256) = F(255); % will go crazy otherwise

Originally posted by JanHH:
do you have any links regarding fresnel? I couldn’t find anything I understood .

Seen the NVidia paper? http://developer.nvidia.com/object/fresnel_wp.html

– Tom

thx but what is the difference in the screenshots in the paper? to me they all look the same

Jan

Yeah, the shots don’t really highlight the effect. What you’ll get if you implement fresnel is that the water will look translucent if you look straight down at it, and reflective if you look at it from a grazing angle.

– Tom

For more on the Fresnel Equation, you could also try to read this article (assuming you have access to ACM or a library with old Siggraph’s):

@Article{Cook82,
author = {Robert L. Cook and Kenneth E. Torrance},
title = {A Reflectance Model for Computer Graphics},
journal = {Transactions on Computer Graphics, ACM Press},
year = 1982,
volume = 1,
number = 1,
month = {January},
}

Or try to find one of these books, where the topic is also discussed:

@Book{watt92,
author = {Alan Watt and Mark Watt},
title = {Advanced Animation and Rendering Techniques: Theory and Practice},
publisher = {Addison Wesley},
year = 1992,
}

@Book{Foley96,
author = {Foley and van Dam and Feiner and Hughes},
title = {Computer Graphics: Principles and Practice},
publisher = {Addison Wesley},
year = 1996,
edition = {2nd},
}

/Henrik