Terrain lighting seams?

Started by
12 comments, last by Carandiru 10 years, 8 months ago

Oh I should also mention all textures I use are made seamless.

Advertisement

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?

"Spending your life waiting for the messiah to come save the world is like waiting around for the straight piece to come in Tetris...even if it comes, by that time you've accumulated a mountain of shit so high that you're fucked no matter what you do. "
Haha a border so simple. Will implement and get back to you. Also will see if I can verify the normals. I added sobel calculation as it gives a noticeable enhancement with normal mapping. It is based purely off the height map. The tangent and binomial are calculated differently with the y axis now factored in with is important for surfaces that are not flat. The normal from this final calculation is then averaged with the sobel calc to give a good enough, visually, result.

Well I ran into some problems implementing the border vertices for sampling normals actually became quite complex. So I reverted it and now I'm back to where I was before. I'll have to tackle this bug again. I have to move onto some important features and mechanics.

This topic is closed to new replies.

Advertisement