View Full Version : terrain & water
Macerlask
04-20-2006, 08:01 PM
Ok, I create my terrain width HeightMaps and now I want to add a lake, I created a grid for the lake surface, but the lake's borders don't look very well...
Is there an algorithm or method to do thise?
Can you give me any advice?
Reedbeta
04-20-2006, 09:34 PM
A screenshot would help - saying the borders "don't look very well" doesn't tell us much ;)
Mjolnir
04-21-2006, 12:32 AM
Jagged/torn edges? How about blending the water texture and/or increasing its polycount a bit (if you plan to add ripple fx and such)?
Macerlask
04-21-2006, 07:27 AM
Ok, there are my screenshots, and the problem that I'm having is the ugly borders from the lake, when I'm close to them or when I take the camera up to have a aerial view of the map...
http://macerlask.onesite.com/images/ranchito1.jpg
http://macerlask.onesite.com/images/ranchito2.jpg
http://macerlask.onesite.com/images/ranchito3.jpg
Reedbeta
04-21-2006, 08:21 AM
I see. That problem is known as z-fighting and it happens because the z-buffer has limited precision, so when you try to draw intersecting polygons (e.g. the edge of the water intersecting the land) then you get those artifacts. To solve the problem, try clipping the water polygon to precisely the boundaries of the pond (to do this, the heightmap needs to have a ring of points that are precisely the height of the water, so you can exactly match the vertices). You can also try increasing the precision of the z-buffer; it looks like you're only using 16 bits there, try going to 24 or 32.
Macerlask
04-21-2006, 12:54 PM
Ok, I have solved the problem when I'm to close to the border, using a big quad instead of a grid, however I still having the problem width the aerial view, but how can i switch from 16 bits z-buffer to a 24 bits z-buffer, I don't find how to do this with GLUT... :unsure:.
Mjolnir
04-22-2006, 02:32 AM
glutInitDisplayString("rgb double depth>=24"), maybe :glare: ?
Macerlask
04-22-2006, 08:08 AM
ha ha, what else? :no:
Reedbeta
04-22-2006, 10:26 AM
Oh, and you can also try increasing the near plane distance; if it's too close it'll also cause precision problems.
Macerlask
04-29-2006, 02:58 PM
Ok, I solved the problem... you can not chose the buffer size with glut, glut just takes the best one that your graphic card has, so I checked the configuration of my card (an Intel integrated video card) and the option of 24 z-buffer was disable... and I just changed that to enable and it worked :happy:
Anyway thanks a lot for the help...
Spudman
05-05-2006, 06:32 AM
Suggest you use a stencil buffer (assuming your hardware supports it). Render the lake without rendering any pixels to the display surface BUT updating the stencil buffer accordingly, and then render the lake directly to the display using the stencil buffer as a mask. This will produce nice edges.
Reedbeta
05-05-2006, 10:41 AM
Spudman, how would that solve the z-buffer problem? It doesn't matter whether you draw the pixels to the stencil or directly to the display; they have to be z-tested if you want correct occlusion.
vBulletin, Copyright ©2000-2010, Jelsoft Enterprises Ltd.