Precision errors when calculating normal map for planet

Started by
1 comment, last by Matt_Aufderheide 7 years, 7 months ago
[sharedmedia=gallery:images:7707]
You can see I'm calculating a normal map for a sphere (planet) in world space.. all looks good, except towards the poles there are some grey pixels caused by I assume lack of precision or something... I'm doing this on CPU using floats
given three points on an ideal sphere, I normalize to a given radius and add the appropriate precalulated heightmap value...
normalize(wpos1)*(1000.0+vx);
normalize(wpos2)*(1000.0+vy);
normalize(wpos)*(1000.0+vz);
where the points represent an arbitrary point wpos and its two neighbors... vx, vy, vz are the heightmap values for those points..I multiply by 1000 and then add the heightmap value to lower the overall difference between the heightmap values... and thus making the normal less strong;
then simply:
vec_sub(wpos1,wpos);
vec_sub(wpos2,wpos);
vec_cross(wpos,wpos1,wpos2);
vec_normalize(wpos,1);
As you can see in the picture, all seems to work fine except for the poles... seems there isn't enough precision (or something) to handle this area... any suggestions?

Advertisement
With the parametrization you have used, the samples at the poles are very close together. Try using doubles for the computation, but even that might not fix the very last line, because all those points map to the same point on the pole and you are then looking at degenerate triangles.

A clean solution would be to use a cubemap instead of spherical coordinates.

You are right about the sampling distance being too close.. when I tried increasing the sampling distance near the poles it looks better.. though its hard to get it exactly right...

Yes a cubemap is probably better..although the poles aren't so important as they will be flatter... I can fix the normal in the pixel shaders...

Still I will think about a cubemap...

thanks

This topic is closed to new replies.

Advertisement