Sign in to follow this  
Mr Furious

HDR Angular Maps

Recommended Posts

I've been playing with hdr images alot lately and have found that most "light probe" images are in the mirror ball format, aka "angular map". I've been searching around trying to get information on the math so that i could decode them into a cube map but all i could find was this: rendering with natural light which contains: { angmap.cal Convert from directions in the world to coordinates on the angular sphere image -z is forward (outer edge of sphere) +z is backward (center of sphere) +y is up (toward top of sphere) } sb_u = 0.5 + DDx * r; sb_v = 0.5 + DDy * r; r = 0.159154943*acos(DDz)/sqrt(DDx*DDx + DDy*DDy); DDy = Py*norm; DDx = Px*norm; DDz = Pz*norm; norm = 1/sqrt(Py*Py + Px*Px + Pz*Pz); Any explanation of this would be appreciated.

Share this post


Link to post
Share on other sites
Hi,

If you just need to convert the angular map to a cubemap you can use HDRShop (version 1 is free) to convert to it to a vertical cross style cubemap. CubeMapGen from ATI can load this format and convert it to DDS or separate images for each face.

The calculations you posted should be read bottom up. (Px,Py,Pz) is a direction in the world and (DDx,DDy,DDz) is the normalized world direction. (sb_u, sb_v) is resulting angular texture coodinates.

acos(DDz) maps DDz from [-1..1] to [-Pi..Pi] which is then divided by 2*Pi ( 0.159154943) which scales it to [-1/2..1/2]. r (the radius, or scale factor) is then divided by the lenght of the 2D vector (DDx,DDy) to compensate for it not being a unit vector. (DDx*r) and (DDy*r) will now both be in the interval [-1/2..1/2] so (sb_u,_sb_v) is the angular texture coordinates ranging from [0..1].

The angular map is also the type of environment map that OpenGL expects when you want to use sphere mapping (glTexGen = GL_SPHERE_MAP).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this