Advertisement

Terrain + Water suggestion needed !

Started by April 04, 2001 04:09 AM
6 comments, last by penetrator 23 years, 7 months ago
hi, i''ve a quad strip terrain generated engine, and now i''d like to add some water. Can you suggest me some methods to do it ?
if polygon height is less than X threshold
color(blue)
enable transparency


this works okay when using fractal generated terrain of sorts.. only problem is, there is nothing underneath it...

or you could just make one big blue transparent plane across the map, and have that be your waterlevel...

Im sure someone has something better ideas though...

Edited by - caffeine on April 4, 2001 9:52:20 AM
Advertisement
Those are some good ideas, but it wont look too pretty. Here is a [lengthy] idea:

first make a file format, say, .lvl, which the format might be like:
,


[height x0,y0,height x1,y0,height x2,y0...][height y_final]
[height x0,y1,height x1,y1,height x2,y1...][height y_final]
[height x0,y2,height x1,y2>,...][height y_final]
[height x_final][height x_final][height x_final]...

So an example map (1x1 tiles in a 3x3 map, that slopes upwards):
3,3
1

[0,1,2][3] // ____----====
[1,2,3][4] // ----====****
[2,3,4][5] // ====****^^^^
[3][4][5]

This is how it would work. The first 2 numbers tell you that you want an x*y grid of polygons. If you say 3x3, you will have a total of nine tiles. The 3rd number tells how large each tile is. If you say 1, then each tile with be 1x1 in gl units.

Then you specify the height for x+1*y*1. I know that is complicated, but that makes it so that you can specify the height of the outer edge of the last tile.

Now, when rendering, tile nx,ny is determined by what , , , and are, because the tile is in relation to the next tile. So if those values are 0, 1, 1, and 2, then the points of tile nx, ny would be:

topleft y-
topright y-
bottomleft y-
bottom right y-

-or-

topleft y- 0
topright y- 1
bottomleft y- 1
bottom right y- 2

Simple, right? Of course, you will have to expand with texture support, possibly deformation support, and water support.

The plane of water is a good idea, but too static. Instead, of rendering a simple transparent&textured plane, I would render a mesh of polygons exactly the same size (or with more polys) as the terrain. This way, you could have very dynamic water surface for ripples, or whatever. I would have 1 universal water height to work with though, because when you go under water, you are going to want to know for physics. I recommend that when underwater you turn on a blue fog- very nifty feature.

Well, I suppose that's all. Hope you were as lost as I assumed you were!

L8r,
The Solar Engine's Father,
And Lead Coder Of Destiny Interactive,
The Rainmaker

Edited by - Rainmaker on April 4, 2001 4:35:15 PM
Be careful with those QUADs...
If not all vertices of a qaud are in one plane --which they won''t in all but the simplest terrains--, it is possible to view it from such an angle that you get a non-convex polygon...
better use TRIANGEL_STRIP...
First of all THANK YOU VERY MUCH for answering: i just converted the quads in a triangle strip, and I made a big blue transparent plane across the map, but the problem is that blending is messed up: where surface and water intersect i get nasty artifacts (blending problem i guess): this is my code from the DrawGLScene()

glDepthFunc(GL_LEQUAL);
glEnable(GL_DEPTH_TEST);

glDepthMask(1);
glDisable(GL_BLEND);
draw_surface();

glDetphMask(0);
glEnable(GL_BLEND);
draw_water();
}

what am i doing wrong ?




theres been a couple of simular posts here rencently, it concerns depth buffer inprecision, have look at the posts from the last 1-2 weeks

http://members.xoom.com/myBollux
Advertisement
couldnt find anything

eg just below "flickering textures"

http://members.xoom.com/myBollux

This topic is closed to new replies.

Advertisement