Sign in to follow this  

Blending terrain...

This topic is 4379 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I have no idea wether what you want is possible (viable) but you could possibly make the fog's color match the skydome's color in the horizon. I've seen that in quite a few places.

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 4379 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this