Sampling Heightmap Edges for Normal map
Posted
by
pl12
on Game Development
See other posts from Game Development
or by pl12
Published on 2014-03-31T07:19:02Z
Indexed on
2014/05/31
16:07 UTC
Read the original article
Hit count: 265
normal-mapping
I use a Sobel filter to generate normal maps from procedural height maps. The heightmaps are 258x258 pixels. I scale my texture coordinates like so:
texCoord = (texCoord * (256/258)) + (1/258)
Yet even with this I am left with the following problem:
As you can see the edges of the normal map still proves to be problematic. Putting the texture wrap mode to "clamp" also proved no help. EDIT: The Sobel Filter function by sampling the 8 surrounding pixels around a given pixel so that a derivative can be calculated in order to find the "normal" of the given pixel.
The texture coordinates are instanced once per quad (for the quadtree that makes up the world) and are created as follows (it is quite possible that the problem results from the way I scale and offset the texCoords as seen above):
Java:
for(int i = 0; i<vertices.length; i++){
Vector2f coord = new Vector2f((vertices[i].x)/(worldSize), (vertices[i].z)/( worldSize));
texCoords[i] = coord;
}
the quad used for input here rests on the X0Z plane. 'worldSize' is the diameter of the planet. No negative texCoords are seen as the quad used for input for this method is not centered around the origin.
Is there something I am missing here? Thanks.
© Game Development or respective owner