Skip to main content
GameDev.net gamedev.net
🔒 Locked

terrain/water/depth fog - seeking advice, suggestions

Started by Vulcan Jun 28, 2004 at 5:34 PM 7 replies 1.8k views
Original Post
Vulcan
Vulcan
Hi, I've got this fairly decent terrain system with some water effects going on. I was wondering if anyone could suggest ways I should go about the following. 1. I'm using a skydome at the moment with a cube map. I want to change this into using the Skydome merely for atmospheric lighting, add a sly plane for the clouds. Does this sound like a good plan? If i do so, is there a simple way to convert such a scene composition into a cube map for placing on the water, or should I stick with a pre-generated one? 2. I want to add some sort of shoreline foam effect. I don't really have any ideas where to start with this, besides mapping out the shoreline with polygons and then scrolling them inland with an appropriate texture applied to them. 3. Does the 'depth fog' look correct (see img)? It fades off the terrain into the color of the water. A friend says that it should fade to black instead? I'm not sure why. It looks great to me. 4. Nighttime lighting. Eventually, granted the above things get working, I'd like to add nightime effects. Stars, the occasional meteor, etc. Any suggestions here? Thanks in advance for help, -Eric
ApochPiQ
ApochPiQ
1. This really isn't my area so I'll leave this one open. Just out of curiosity, why are you going to a skyplane instead of a skydome? In my experience a dome gives much more pleasing results near the horizon.

2. I'm not sure how to go about this because I'm not sure how you're storing your terrain, whether the water level changes, etc.; but for the foam itself I'd suggest a simple white, foamy-looking texture that gets billboarded onto specially created polys near the edge of the water. You can make several different textures and animate them as well, making the foam look like it is... "foaming."

3. From what I can see it looks nice. The color is a little bit too bright to be believable, but that really isn't a major problem. Dropping off to black IMO doesn't look as nice. Maybe darken the fog color by a few percent and it should be perfect.

4. At night, I'd suggest not doing the translucency in the water; make it fully reflective. A well-placed light (e.g. the moon) can provide very nice looking specular reflections on the water, which is what a lot of people think of when they think about water at night. Beyond that, just play with your lighting and shading, and try to keep the details from becoming too cluttered. A lot of "starry" backgrounds end up having too many bright stars and are very distracting to the eye. A very few bright stars, many dim ones, and a few hazy blurs should work nicely. Comets, meteors, etc. are all nice but they only "work" in certain atmospheres; this is really more of an artistic thing so it is rather subjective.
Vulcan
Vulcan
Well it wasnt going to be a completely flat plane, it was going to curve off towards the horizon, just wondering if this is what most other people did as well.

thanks for the advice.
_DarkWIng_
_DarkWIng_
Looks nice so far.

I would make water and terrain fade in the background (skydome/cube) and not in fog. This way you get no "pop in the view" errors at any view distance. It also dosn't need fog to be matched with sky color.

For clouds you could keep the skydome. Use vertex colors for gradient and map texture to it for clouds. Just project virtual skyplane to dome and you have virtualy infinite horizon. But it might be a bit difficult to get animation/shading working with this. (sample image)
You should never let your fears become the boundaries of your dreams.
Vulcan
Vulcan

There you go, looks kinda odd though with the bright skybox. I changed the water color as well.

Also, how do you make the terrain fade off into the skybox? Im not sure it will look correct however, as though even far off in the distance you can still usually make out the outline of the terrain on it. But anyway, you cant simply set the fog color to do that, right? I assume you'd have to write a shader for it.
Yann L
Yann L
Quote:
Original post by Vulcan
Also, how do you make the terrain fade off into the skybox? Im not sure it will look correct however, as though even far off in the distance you can still usually make out the outline of the terrain on it. But anyway, you cant simply set the fog color to do that, right? I assume you'd have to write a shader for it.

You have different options. An easy one works like this:

* Render the sky
* render the terrain only in the depth buffer, ie. disable colour updates
* enable blending, based on alpha
* render the terrain again, this time with full colours, using a depth compare function of EQUAL
* use the fogfactor to modulate the amount of blending with the background (the sky). Conceptually, you render your terrain translucent, with a transparency depending on the distance.

Another approach uses vertex shaders and an additional texture unit, but can do it in a single pass:

* prepare the pipeline for your terrain renderer
* bind a cubemap of your sky into a free texture unit (you can use a lower resolution)
* at each vertex, compute the vector pointing from the camera to the vertex position, normalize, and use as index into the cubemap (be careful that the coordinate frame used for the raycasting is consistent)
* also compute the fogfactor per vertex
* per pixel, blend your final terrain pixel colour with the cubemap based on the fogfactor

And many more alternative techniques (for example storing the fogfactor in the alpha component of the framebuffer, and blending over the sky as postprocess).
hplus0603
hplus0603
You should make the fog color be the same as the "primary color" of your skybox, or some color slightly darker than that. Usually, this is a cyan-blue, or blue-purple. At night, fog should fade to black, or very dark purple.

You don't need to put the sky plane into a cube map for the water; the water is flat (modulo bumps) so using a simple reflection of the flat sky texture will work fine.

Tricking out the shoreline (especially concave areas) with horizontal polygons, and scrolling textures on them, is a time-honored way of doing rolling waves. You can see it very clearly in games like Black & White, for example.
enum Bool { True, False, FileNotFound };
Vulcan
Vulcan
thanks for your help all!

working on the fog stuff, seems relatively straight forward.

-Eric

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.