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

Blending terrain...

Started by Marianne Dec 16, 2005 at 6:17 PM 6 replies 1.3k views
Original Post
Marianne
Marianne
Hi, i'm making a game with a terrain amde of height mapping. I have a sphere sky and objects fade away (become transparent) when they get too far (using glColor4f and GL_BLEND). However, i don't know how to achieve this with the terrain. Currently, i'm using display lists and vertex arrays, but to me it seems like none of these methods could do it within my knowledge of them. Of course direct drawing would do it but it creates a significant slowdown in the framerate. What's the best way? thanks
Marianne
Marianne
yeah, that's what i'm using now... it's just that sometimes the sky has many different colors so at many points the horizon doesn't look right
RaptorZero
RaptorZero
Ok, I've found this topic over here: Terrain -> Fog -> Sky - Gamedev.Net Discussion Forums

It's a bit old but it should have some usefull stuff.
Sorry, I can't give you any advice of mine because I have never tried to do anything about that.

Hope it helps.
error C2065: 'signature' : undeclared identifier
Trienco
Trienco
Can you use shaders? Just setting the alpha based on the distance for each fragment would work. If you don't mind it not being pixel perfect then setting it in the vertex shader would be fine, too. Also: how are you doing your terrain? Is it a small terrain you can draw as one big thing or is it subdivided into patches. Setting a transparency for a whole patch would be an option (but might look pretty unsmooth).
f@dzhttp://festini.device-zero.de
Marianne
Marianne
the topic seems pretty complex! anyway i guess i'll just stick to the fog... i didn't want any complex lighting thjing, just using blending without doing direct drawing
Kalidor
Kalidor
Quote:
Original post by Marianne
Hi, i'm making a game with a terrain amde of height mapping. I have a sphere sky and objects fade away (become transparent) when they get too far (using glColor4f and GL_BLEND). However, i don't know how to achieve this with the terrain. Currently, i'm using display lists and vertex arrays, but to me it seems like none of these methods could do it within my knowledge of them. Of course direct drawing would do it but it creates a significant slowdown in the framerate. What's the best way? thanks
If you're using vertex arrays for the terrain, then you can use color arrays (remember to enable and disable the GL_COLOR_ARRAY client state, exactly like other vertex array client state) with the same information you would pass in your glColor4f call. You would need to change this information whenever the camera moves so using display lists for this is not a good idea. Depending on the size of your terrain, this approach may be too inefficient anyway.

You may be able to use an alpha texture with a circular gradient and project it down on the terrain and use that, although getting that right may be a lot of unneeded work.

The best way is to just calculate the distance to each vertex in a vertex shader and set the alpha value accordingly. That is assuming you are targetting hardware that supports at least vertex shaders.

If you can't use shaders, fog is probably the best way to go.
IronFox
IronFox
Of course there's always the possibility to use dynamic objects instead.
This may decrease render-efficiency but it also gives you more control over certains aspects of your structure (i.e. for implementing dynamic detail).

Another approach would be to split your heightmap into sectors of each NxN faces (i.e. 16x16 quads). Then you can choose a different intensity for each sector and create an approximation of what you want to do.
Depending on the fading-range you are using, this might prove sufficient.

Topic Locked

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

Sign in to reply to this topic.