[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);
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_sub(wpos2,wpos);
vec_cross(wpos,wpos1,wpos2);
vec_normalize(wpos,1);
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?