Hi
I am looking for a mapping (and its inverse) between a square and a hemisphere. I need it to store samples of a hemispherical function (the sky colour) in a 2D texture, which I can then fetch in shaders. The requirements are:
- shader-efficient inverse mapping from the hemisphere to the square (in other words, conversion of a 3D direction to U,V coordinates)
- the mapping should allow some control on the sample distribution. In my case I need more samples near the horizon where the sky colour changes quickly
I've done some research these days but could not find anything suitable yet. Most projections use polar coordinates and have costly inverse mappings in terms of ALU (due to atan2, acos functions). I have code for mapping normal vectors to two coordinates for deferred rendering but in that case I cannot control the sample distribution.
Perhaps I could use a cylindrical projection with a cheap approximation to atan2 if one exists ?! Any ideas are much appreciated.
Thanks,
Stefano