Fairly simple water

Started by
17 comments, last by d000hg 19 years, 10 months ago
I don''t really want to invlove things like shaders or render-to-surface in my water, but I''d like it to move and look quite nice. The physics will be OK but I''m thinking about rendering. If I texture the water with a standard water texture, but set the transparency based on the vertical angle from viewpoint to each vertex, and use standard specularity - will this look ok? Obviously things under the water won''t ''ripple'' as they should but will it look horrible or just not as nice as environment-map-reflected water? But out of interest can you point me to tuts on how to make objects underwater ''move'' as surface moves and how to get reflections, transparency etc as well. If it could be done with vertex shaders I might consider it... [Edited by - d000hg on June 23, 2004 6:27:58 AM]
Advertisement
That depends on your definition of "horrible"

Seriously though, you can''t simulate realistic water without reflections and refractions, since those two components are the main properties of any transparent liquid.

But you can get something that a human observer will generally interprete as "watery", even without using reflections and/or refractions. Simple water as in Quake is easy, and doesn''t require any shader magic. Unfortunately, it''s not very attractive. You can get more or less acceptable water by using a simple transparent mesh displaced by your physics function. You''ll get a lot of sorting artifacts, but it''ll look like water. Specularity can help, but can quickly make your water look like a moving plastic plane.

I''d suggest you look at least into reflections. Even without refractions, water can look really good using reflections alone (either by a cubemap, or better by a projective render texture). You can perfectly do it on vertex level only, no pixel shaders are required to get a nice effect.
get a nice skydome, and reflect that, that alone will make it look very purty!
Thanks guys. Quake water is not good enough, QuakeII was quite nicely transparent but didn''t move. I presume the artifacts you refered to come from rendering transparent polys in the wrong order?
How exactly do you do a cubemap for a sea? Is it not different than for a body (like the DX teapot)? I quite like the idea of ''reflecting'' my sky ino the water, to get either transparent or sky image depending on viewing angle.

Something about rendering refraction has always puzzled me. When you look at a pixel/vertex you need to get the view-ray and bend it to a new angle and follow to see what it touches, right? But if the sea floor is not flat is it not very expensive to find the intersection of the ray and mesh? Or is this done totally differently?

Cheers.
quote:Original post by d000hg
I presume the artifacts you refered to come from rendering transparent polys in the wrong order?

Yes.

quote:Original post by d000hg
How exactly do you do a cubemap for a sea? Is it not different than for a body (like the DX teapot)?

It's the same. You'll use a cubemap representing a large scale environment around your water surface. It's important that you don't add local geometry or details into the cubemap, because that will lead to artifacts (if you want local reflections, for example a boat, terrain, or some vegetation, then you'll have to use the render-texture approach). When rendering the water surface, you do this:

* bind the cubemap
* for each vertex, compute the reflection vector taking into account vertex position, normal, and view vector.
* use that reflection vector to index the cubemap.

You might want to add some blending, so the water gets semi transparent, otherwise you'll have a liquid metal look.

Once you have that working, you can attempt to add the so called Fresnel effect: that's the ratio of reflection to refraction, depending on the view angle. Instead of true refraction, you can simply modulate the transparency.

quote:Original post by d000hg
Something about rendering refraction has always puzzled me. When you look at a pixel/vertex you need to get the view-ray and bend it to a new angle and follow to see what it touches, right? But if the sea floor is not flat is it not very expensive to find the intersection of the ray and mesh? Or is this done totally differently?

As many other things in realtime 3D, you use an approximation here. The ocean floor (or any other object below the surface) is assumed flat. That makes the intersection calculations very easy. Since refraction is a visually very complex effect, the human brain will not notice physically inaccurate refractions, as long as the general behaviour is reasonably well approximated and the refraction index difference between liquid and air is not too big.

Refractions are generally either done by projective render textures, or by vertex deformation of the geometry below the water plane. Since they are almost always local, a cubemap approximation doesn't work very well for refractions.


[edited by - Yann L on June 9, 2004 4:28:54 PM]
Many thanks. What exactly is projective render texture? And would both this and vertex translation work for underwater objects?
i know you're thinking simple, but id start thinking "good implementation" and pair down from there. since Yann is aprticipating in this thread it reminds me of the lecture he gave on water.

Here
is a link
to the lecture


Here is a link to Yann explaining some questions about it.


it's a good read, and is easily bastardized to an easier implementation if you decide that's too much

Dredd
________________________________________

"To die with your sword still in its sheath is most regrettable" -- Miyomoto Musashi






[edited by - Dreddnafious Maelstrom on June 10, 2004 8:48:10 PM]
"Let Us Now Try Liberty"-- Frederick Bastiat
Thanks for the links - most useful. I''m thinking good physical modelling and simple rendering. If it moves well and actually interacts (good splashing stuck on afterwards) with stuff then as long as there''s transparency close to you and sky reflections far away it should be nice. If the water is in a breeze you can''t see anything under the surface anyway unless just below when you get a blur of colour!
@YANN:

Just read the lecture mentioned above (well skimmed of rendering section some as only have 30min) and very impressed. One question about the lecture - how much was it cut''n''paste from a prepared lecture and how much on-the-spot writing? Off-topic but I also wondered if your simple NSE approximations would easily adapt to a large island (a mile across maybe) and if so would we se waves get steeper and taller in shallow water, would they break (I guess not in a heightmap!).

I took a course on NSE in final year of my degree so hopefully can implement this - I was particularly interested in the idea of melding it with a LOD system since otherwise it''s a huge waste of power for a land based game with water mainly as eye-candy! Although I would at sometime like to implement water interacting with things like slowing cars, physically modelled river flowing properly...
Hi d000hg

I'll suggest you'll just implement the render-to-tex approach. It's really not that difficult!

Take a look at these screenies:

Screenies

You're more than welcome to email me, if you have any questions.

Best regards
Roquqkie

EDIT: Hmmmm.... Try direct-linking instead

[edited by - Roquqkie on June 12, 2004 4:44:36 AM]

[edited by - Roquqkie on June 12, 2004 4:46:03 AM]

This topic is closed to new replies.

Advertisement