• Advertisement
Sign in to follow this  

How is the spherical environment mappping theory?

This topic is 3494 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I was trying to implement an spherical environment mapping shader from scratch. The basic principle was to calculate the reflection vector and to use its x and y coordinates to index the reflection texture with this formula. coord.x = reflection.x * 0.5 + 0.5; coord.y = reflection.y * 0.5 + 0.5; * 0.5 because reflection.x is between -1 and 1 + 0.5 to center the texture. The problem was when z coordinate went negative, causing the reflection to be as reflecting an sphere with a planar projection instead of a cube map. Then, I followed this tutorial which worked great: http://www.ozone3d.net/tutorials/glsl_texturing_p04.php Which says you have to divide the coordinates by 'm' where 'm' is: float m = 2.0 * sqrt( r.x*r.x + r.y*r.y + (r.z+1.0)*(r.z+1.0) ); As I understand, m is the double of the module of the vector from the origin to the reflected point by translating the reflection sphere to (0,0,1). I suppose that the "2.0*" is the same than my "*0.5". But I don't know what the rest of the formula is based on. Is there any documentation available? Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement