Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 9 of 9

Thread: Terrain + water

  1. #1
    Junior Member Regular Contributor
    Join Date
    Dec 2000
    Location
    Florence, Italy
    Posts
    219

    Terrain + water

    ok, thanks to all your advises now i have a large terrain with lakes and rivers. Both terrain and water is build with gl_triangle_strip, and since triangles are quite large, borders between land and water dont look very nice ...
    so i think i should use tessellation to subdivide land and water bordering triangles and then texturing properly in order to have a better looking "bordering area" ? perhaps with a new texture which contains a piece of land smoothly turning to sea ?

    if this is not clear i can make a html page to explain me better .

    thanks

  2. #2
    Senior Member OpenGL Guru zed's Avatar
    Join Date
    Jul 2000
    Location
    S41.16.25 E173.16.21
    Posts
    2,609

    Re: Terrain + water

    perhaps i dont understand
    but normally in 3d you'ld draw the water over the land

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Mar 2001
    Posts
    2,704

    Re: Terrain + water

    I believe a screen shot is the only way we're going to understand what's wrong with your current approach. That, and maybe you letting us know what you would want it to look like when you're done :-)
    "If you can't afford to do something right,
    you'd better make sure you can afford to do it wrong!"

  4. #4
    Junior Member Regular Contributor
    Join Date
    Dec 2000
    Location
    Florence, Italy
    Posts
    219

    Re: Terrain + water

    ok , in the simple terrain engine i'm building, i use one unique texture for both land and water: when the terrain height goes to zero, i simply glcolor to blue: of course this look quite bad, so now i should build another separate triangle strip for the water (still have to find the algorithm). But even in that case, when land finish and water start, i'd go suddenly (and not gradually) from a texture to another (lets say from a brown texture to a blu one). If what is up is not understandable, pls check this page:
    http://www.web-discovery.net/test.htm

  5. #5
    Junior Member Newbie
    Join Date
    Sep 2000
    Location
    UK
    Posts
    13

    Re: Terrain + water

    Hi,

    If you're currently using one colour per face, you sould change that to one colour per vertex. That way you should get a smooth transition. It's hard to tell from your screenshots which approach you are using.

    Iainr

  6. #6
    Junior Member Newbie
    Join Date
    Nov 2000
    Location
    Austin, TX
    Posts
    14

    Re: Terrain + water

    In your second approach, where the water is a separate set of polys, you could blend the water into the land. Your water would look a little transparent so the land texture would show through and you wouldn't get such a sudden change from one texture to the next.

  7. #7
    Member Regular Contributor
    Join Date
    Nov 2000
    Location
    Dunblane, Scotland
    Posts
    353

    Re: Terrain + water

    Do you mean that at the edge of the water (especialy in the second shot where there isn't a smooth transition) that the edge is very "grainy" or "blocky" and looks like low resolution poly count? If so then to get rid of this I think the only way is to use some form of tesselation, but I don't know how. You didn't ask a specific question so I can't really answer your post, I don't think I need to say this but look on the web and you will find some tesselation tutorials.

    I added a simple LOD system to my terrain engine becuase it previously ran at 10FPS!!! framerates are about 40 fps without any optermisations but the trouble is it looks crap at the transition zones with blank parts that arn't drawn and bad popping. I alo don't want to use ROAM becuase of the overhead which would slow down fast TNL pcs which could easily render a large amount of terrain with a very simple LOD system. I guess you can't have your cake and eat it!!!
    Reality is for idiots only the best over come it!

  8. #8
    Junior Member Regular Contributor
    Join Date
    Dec 2000
    Location
    Florence, Italy
    Posts
    219

    Re: Terrain + water

    Stetcher, pls tell me an example (few lines of code) on how to blend water into land ...

  9. #9
    Junior Member Newbie
    Join Date
    Nov 2000
    Location
    Austin, TX
    Posts
    14

    Re: Terrain + water

    If you look around I'm sure there are some good tutorials on blending. The opengl programming guide has a good section on it.

    Here are the basic steps you'll have to do when you draw your water (you'll have to draw your terrain first):

    glEnable(GL_BLEND);
    glDepthMask(GL_FALSE);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE);

    specify the color of the water vertices with RGBA components:
    glColor4d(r, g, b, 0.5); // 0.5 is just an example, the water will be 50% transparent

    draw your water

    if you texture map the water you might have to use
    glTexEnvf(GL_TEXUTRE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    so the texture alpha value doesn't replace the alpha values you specify, with glColor4d.

    disable blend and set depth mask back to true.

    I think that's the basics. You should search around and find some sample code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •