Aug 8, 2010

Best Fit Normals: playing with the bias vector

Yesterday night, I have first implemented the Amantide ray marching method to compute the best fit normal (BFN) cube map. The gain in performance is, as expected, major. I can now generate a large cube map in few minutes (instead of hours).

Second, I was thinking about changing the bias vector in order to get precision where it matter, similarly to the quantization approach presented by Crytek in this old presentation slide 13. This, in order to get more precision (more direction) in the usual normal direction: along the Z axis. I found that it is hard to choose a good bias value. In the case where negative Z value are ignored (there is some games engine in this case but I can't remember which), choosing a bias of 0.0 would be just perfect. Then, I suppose one could choose the bias value visually, or image difference error from key view points. Also, encoding objects normal map using such a bias should be of higher quality because normal maps rarely contain normals with negative Z.

Enough talking, here are some screenshot:


A view of the BFN cube map face (positive Z)
with a bias factor of 16 on the Z axis.


Bias modification example. Left: BFN with usual bias,
Right: BFN with Bias of 2 on the Z axis
(poor precision for normal with negative Z).
(32*32 cube map)


Visualization of the reconstruction error (multiplied here by 70)
as compared to the true direction.
Front box: BFN with Bias of 16 on the Z axis
(poor precision for normal with negative Z),
Far box
: BFN with usual bias. (256*256 cube map)

Visualization of the reconstruction error on the positive Z face.
Left: BFN with Bias of 16 on the Z axis,
Right: BFN with usual bias. (256*256 cube map)

A you can see on the last figure, you can get more precision on a simple 256 BFN cube map by simply changing the bias on the Z axis.

The presentation of Anton about this is now available on the course website. I will have a deeper look at the details (I was implementing this methods based only on my memory and ideas since SIGGRAPH). Interestingly, it seems that they do not use a cubemap but a 2D texture...

As always, feel free to discuss and to ask me for the BFN cubemap textures (at any resolution now :D) if you want to try this in your engine (some developers from video game studios requested these textures last time).

2 comments:

  1. Hi Sebh.

    would it be possible for you to provide me with a 512 cubemap of the BNF data?
    Do you calculate the best fit scales based on the normal divided by max component?

    many thanks.

    ReplyDelete
  2. Hi dummy!

    Currently, I have only tested the cubemap, but generating the single 2d texture with the best fit length stored for the normal divided by its max component is not a big deal. And, this texture can be extracted from Crytek's presentation! :)

    However, I can still send you the cubemap faces: just mail me. Also, I plan to release my code soon because I receive a lot of request for these cube map faces.

    PS: my mail address is visible at http://sebastien.hillaire.free.fr/

    ReplyDelete