The BFN generator is finally here! I have found time for this tonight.
So, this small application allows you to generate each face of a BFN cube-map. If you want to encode the BFN only as the length of the best fit normal or transform it to a 2D texture (as suggested in Crytek's presentation), you will have a little bit of work to do but it should not be such a big deal. You can select the resolution of the cube-map as well as the bias vector at compilation time.
Some screen-shots for 256x256x6 cube-maps:
So, this small application allows you to generate each face of a BFN cube-map. If you want to encode the BFN only as the length of the best fit normal or transform it to a 2D texture (as suggested in Crytek's presentation), you will have a little bit of work to do but it should not be such a big deal. You can select the resolution of the cube-map as well as the bias vector at compilation time.
Some screen-shots for 256x256x6 cube-maps:
At the origin: the BFN cube-map with a bias vector=vec3(0.5,0.5,0.5).
in the +X direction: the regular normalization cube-map.
In the +X+Y direction: a BFN cubemap with a bias vector=vec3(0.5,0.5,8.0/255.0). It results in less precision for normals having negative Z value and more precision for normals having positive Z value.
in the +X direction: the regular normalization cube-map.
In the +X+Y direction: a BFN cubemap with a bias vector=vec3(0.5,0.5,8.0/255.0). It results in less precision for normals having negative Z value and more precision for normals having positive Z value.
The reconstruction error of the regular normalization cube-map as compared to the ground-truth normal map. (scale factor of 50)
The reconstruction error of the BFN cube-map with bias a vector=vec3(0.5,0.5,0.5).
Some reconstruction errors are still visible. (scale factor of 50)
Some reconstruction errors are still visible. (scale factor of 50)
The reconstruction error of the BFN cube-map with bias a vector=vec3(0.5,0.5,8.0/255.0).
No more error patterns are visible. (scale factor of 50)
No more error patterns are visible. (scale factor of 50)
Reconstruction error on the back faces (scale factor of 50). There is a large error when using a bias vector of (0.5,0.5,8.0/255.0). However, it is not important since only the positive Z values are important when storing normals for a light pre-pass or deferred renderer.
Error when computing a specular lob with the regular normalization cube-map. The specular exponent is 64.
No noticeable difference when changing the bias vector of the BFN.
You can download the source here!
And finally, the important references :
- Amantide ray marching paper.
- Crytek's presentation from SIGGRAPH 2010 as well as their 2D BFN texture (which I recommend) can be downloaded here.