As there are no "natural" mappings between the sphere of directions and the square, so there is no standard way to parametrize your environment map. In the Original paper by Blinn and Newell, a cylindrical map was used. There are many such cylindrical maps out there and have been used for map projection . For software renderers these are more intuitive than cube maps or the Disk on square paramerterization. In a physically based renderer, you would like to importance sample the environment map. This is easiest if each texel in the map subtends the same solid angle as every other texel. There is one cylindrical map that does this for a given rectangle. A well-known version of this projection is the Peters Projection.

Here's an example projection. The rectangle has parameters [0.1]^2. Let's take u to the angle phi (longitude): u = phi/(2*pi) = atan2(y,x)/(2*pi) assuming your direction (x,y,z) is a unit vector and z is "up". Now we have v = f(z). The simplest such mapping is v = (z+1)/2. Is there area distortion there? What is the area of a given pixel in the texture map. How about the differential area? Let's say that we have a differential square du*dv in the texture map. The area on the sphere of that will be sin(theta) * dtheta(v) * dphi(u).

dphi(u) = 2*pi*du = constant so we can ignore it.

Since z = cos(theta), the other mapping is

(cos(theta) + 1)/2 = v

so differentiating both sides:

-sin(theta)*dtheta/2 = dv

As the differential area is proportional to sign theta, each pixel does have the same solid angle. So this most simple mapping is also a good one! I am not sure why anybody uses any other in a software renderer.

## 1 comment:

Thomas has pointed me to this blog, and I'm glad he did. It's an interesting read.

I'm a huge fan of Peter's projection as well (though I didn't know it was called like that until now). It's easy, it's elegant and has a uniform distribution.

The first time I saw this distribution was on flipCode (RIP), and I couldn't quite believe it myself it actually worked. But I'm a advocator ever since. Many people still use the rejection method instead, god knows why.

It's also very nice if you need to generate directions in a cone (think spotlight). You simply pick your z coordinate between cos theta and one, and you're done.

Post a Comment