• Create Account

We're offering banner ads on our site from just \$5!

### #ActualWaaayoff

Posted 17 August 2013 - 03:25 AM

If your terrain is flat, there shouldn't be any seams even if you aren't using neighbour patches. Are you sure you're calculating your normals correctly? (i have no experience with the sobel operator). Try visualizing the normals with the pixel or geometry shader.

Also, i think you're overcomplicating your calculations. The way i do it is to simply store the neighbour vertices with the patches. So if my chunk is 65x65, i store a border around it so that it's 67x67 and use the extra vertices to calculate the normals. This way you won't have to consider each case (top, left, etc..) explicitly. Here's how the final code turns out:

for (int y = 1; y <= mChunkSamples; y++)
{
for (int x = 1; x <= mChunkSamples; x++)
{
float sx = pHeights[(x + 1) + mHeightSamples*y] - pHeights[(x - 1) + mHeightSamples*y];
float sy = pHeights[x + mHeightSamples*(y+1)] - pHeights[x + mHeightSamples*(y-1)];

nor.x = -sx * mVerticalScale;
nor.y = 2 * pChunk->mScale;
nor.z = -sy * mVerticalScale;
D3DXVec3Normalize(&nor, &nor);

// ... store
}



Edit: I just realized that you are hardcoding your normal to (0, 1, 0). This only leaves the texture... Did you try rendering with lighting only?

### #1Waaayoff

Posted 17 August 2013 - 03:14 AM

If your terrain is flat, there shouldn't be any seams even if you aren't using neighbour patches. Are you sure you're calculating your normals correctly? (i have no experience with the sobel operator). Try visualizing the normals with the pixel or geometry shader.

Also, i think you're overcomplicating your calculations. The way i do it is to simply store the neighbour vertices with the patches. So if my chunk is 65x65, i store a border around it so that it's 67x67 and use the extra vertices to calculate the normals. This way you won't have to consider each case (top, left, etc..) explicitly. Here's how the final code turns out:

for (int y = 1; y <= mChunkSamples; y++)
{
for (int x = 1; x <= mChunkSamples; x++)
{
float sx = pHeights[(x + 1) + mHeightSamples*y] - pHeights[(x - 1) + mHeightSamples*y];
float sy = pHeights[x + mHeightSamples*(y+1)] - pHeights[x + mHeightSamples*(y-1)];

nor.x = -sx * mVerticalScale;
nor.y = 2 * pChunk->mScale;
nor.z = -sy * mVerticalScale;
D3DXVec3Normalize(&nor, &nor);

// ... store
}
}


PARTNERS