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

Some Terrain Issues

Started by Programmer101 Jan 6, 2007 at 8:23 PM 3 replies 400+ views
Original Post
Programmer101
Programmer101
I have put normals and water into a terrain program that I have been making as the basis for a game. I have problems with the normals and water though. My water has issues with z-buffering(I think thats what it is called). Here in this picture you can see what I mean: I'm not sure how to deal with this problem, so if anyone knows, I would be greatful for the knowledge. My second issue is with normal generation. They are kind of patchy and wierd. Here is a picture of what I mean. I am using a method that someone said would work, but maybe I put in in wrong or something. Does anyone have any good methods or suggestions? Thanks.
smr
smr
The z-buffering issue you're experiencing is called "z fighting." It occurs when you're drawing a polygon at nearly the exact distance as another polygon that was drawn there before. The simplest solution would be to make sure that the riverbank is steep enough that the terrain and the water won't be parallel to each other, unless there is a distance between them.

If you're using opengl, are you using floats "glVertex3f" or integers "glVertex3i"?
Programmer101
Programmer101
Cool, I was able to just move the water up a bit and it cancels all the z-fighting.

I'm using directx though. Do you think my normals look wrong?
smr
smr
Yeah, they do look a little bit off, but I wouldn't know how to tell you to fix them. Can you post the code for your normal calculation?
Programmer101
Programmer101
okay, here:

Verts.x = ((x - (columns/2)))*2;			Verts.y = Height/3;			Verts.z = ((z - (rows/2)))*2;			Verts.nx = heightmap[(x-1)+z*columns]-heightmap[(x+1)+z*columns];			Verts.ny = (Height)/3+1.0f;			Verts.nz = heightmap[x+(z-1)*columns]-heightmap[x+(z+1)*columns];			Verts.u = (((Verts.x))/256)*32.0f-0.5f;			Verts.v = (((Verts.z))/256)*32.0f-0.5f;						i++;			Verts.x = ((x - (columns/2)))*2;			Verts.y = nextHeight/3;			Verts.z = ((z - (rows/2) + 1))*2;			Verts.nx = heightmap[(x-1)+(z+1)*columns]-heightmap[(x+1)+(z+1)*columns];			Verts.ny = (nextHeight)/3+1.0f;			Verts.nz = heightmap[x+z*columns]-heightmap[x+(z+2)*columns];			Verts.u = (((Verts.x))/256)*32.0f-0.5f;			Verts.v = (((Verts.z))/256)*32.0f-0.5f;

Topic Locked

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

Sign in to reply to this topic.