Also on my website.
First I'll describe the sky technique I was taught in college for the sake of comparison, then I'll go into my own technique.
Old and Busted
The following technique is the one I was taught in college.
We take a spherical mesh, invert the normals, and planar map each hemisphere from the top and bottom. The 360 sky image is squashed into a square, and then, in Photoshop, the Polar Coordinates filter is applied. In UDK, we need only plug the new sky texture into the emissive of the sphere's material.
This technique has a few glaring flaws:- The sky texture loses half of its resolution in the squash alone, and once polarized stretches the pixels along the horizon and compresses the pixels around the zenith, all while wasting more than 20% of the space it takes up.
- Once the texture is applied to the mesh, stretching can be seen along the vertical edges of the mesh, creating an uneven horizon. This can be mitigated by adding more subdivisions to the mesh, but becomes unreasonably expensive very quickly.
- The mesh has to be enormous in order to keep it from parallaxing, which makes it vulnerable to floating point errors and makes the whole thing more cumbersome in general. This can be avoided by later scripting the mesh to follow the player.
- The sky is limited to one hemisphere of texture data, the bottom half mirroring the top. A second hemisphere would require a second material.
The first issue of resolution can be resolved by polarizing the texture live in the material, rather than baking it in Photoshop.
NEW HOTNESS
The other issues require going a bit deeper. I developed this technique after happening upon a simple formula for projecting spherical normals. Instead of utilizing the UVs of the mesh, this technique projects its own UVs onto the mesh. The result is a sky with
no stretching, no parallaxing, no UVs and barely any polygons, that can be expanded to include use both hemispheres.
Since the result is projected from the camera, we can save a load of polygons by using a simple cube with its normals reversed. Mesh UVs are entirely irrelevant.
It's as simple as that!
I wasn't able to get the vertical scale to perfectly match that of the other technique, but I think this is close enough.
Replies