Tuesday, March 25, 2008

Some specifics

My esteemed Cordelia,

Parallax mapping, in its essentials, may be quite simply described. One considers two surfaces: the polygonal surface described by the actual triangles sent to the renderer, and a virtual surface at some depth below the polygonal surface. This virtual surface may be of much higher resolution, as it is described by a texture rather than by geometry and thus fine details are a matter of texture memory rather than vertex transformation and triangle rasterization. It is this surface which is portrayed in the rendering.

But how, you may ask? How is this gallant Feat accomplished?

Why, by means of ray-tracing, Cordelia! When it comes time to render a Fragment of a triangle thus blessed with an underlying virtual surface, a complicated set of steps begins. The details of these machinations are the subject for another letter, but the geometrickal meaning is clear. Pray examine, Cordelia, the drawing below.




In this drawing, the green line represents the polygonal surface, and the black line the virtual surface. (Note that the green line is utterly flat-- this is the first murmur of the weakness of this Technique!) The yellow line represents a view ray which, under normal circumstances, would intersect the surface at the blue point and produce the image of a flat plane. Instead, the fragment program searches forwards in the bump map, in order to find not an intersection with the polygon surface, but one with the virtual surface. In this case, this is found at the red point. The program then renders the fragment as though it were at the red point, giving the illusion of depth where none exists.

I say "illusion", Cordelia, for such it is! In the published descriptions of Parallax mapping (see N. Tatarchuk's "Practical Dynamic Parallax Occlusion Mapping", &c.) a dreadful deception has been perpetrated upon the good people of Graphics! Virtually all examples in such publications show the technique applied only to large, flat planes, and then only to bump maps which tile seamlessly. Why? Because this technique fails in precisely the point where the surface bends. Witness the revised example below:



Here, the surface bends, avoiding any intersection with the viewing ray whatsoever. One would imagine the ray, therefore, to extend into blessed Oblivion, and produce no color or depth. Not so! Because the lookup is performed in texture space, rather than object space, the test proceeds as follows:


You see? It is as though a bend never occurred. The fragment shader has no way of discarding a fragment due to lack of intersection, because in the simplified geometry of parallax mapping, there will always be an intersection. Hence the only silhouette of a parallax mapped object is that of its accursed polygonal surface. This, then, is the weakness of the otherwise miraculous Parallax Mapping.

With hopes of a happy Feast of St. Agnes,

Ben

No comments: