Shading Normals
24-Dec-08
Milton supports the useful distinction between geometric and shading normals. Though not physically realistic, modeling fine geometry and corresponding materials is often very difficult to do. By allowing the surface normal to vary as a function of position, independent of the geometric normal defined at a point, a modeler is able to instead fake higher resolution geometry by using what’s known as a shading normal. It is important to note that shading normals have no physical basis whatsoever. They are generally interpolated in some manner over the surface of a shape; here is a summary of common shading normal techniques:
- Phong shading — interpolates vertex normals across the surface of a polygon
- Bump mapping — perturbs geometric normal by an amount proportional to the discrete partial derivatives defined in a B&W “heightmap” texture at the current sample point’s UV coordinates
- Normal mapping — replaces geometric normal by an RGB -> XYZ normal found in a texture map (almost identical to bump mapping)
- Displacement mapping — procedurally replaces simplified geometry at run-time with estimate of higher-resolution geometry via a “heightmap” texture (generally very expensive in terms of storage and computation overhead)
- Parallax mapping — displaces texture coordinates of a surface point by a function of the view angle relative to the geometric surface normal and the local value of a “heightmap” at that point
- Steep parallax mapping — utilizes local ray tracing to displace texture coordinates of a surface point similar to parallax mapping, but supporting self-occlusion and a greater sense of depth at grazing angles
None of these techniques are physically “correct”. They are hacks; very, very cool hacks. Why then, do several of them appear in Milton? They seem to go against two of the core principles that Milton is based upon, namely physical realism and being unbiased. These techniques do, however, have their place in terms of both current utility and precedent. They are heavily ingrained in both industry and academia, and for the majority of non-academic settings, the drawbacks of unrealism and bias don’t really matter. That being said, Milton still aims to uphold these principles, and it is this duality which prompted us towards a pretty cool idea that allows us to support both physically “incorrect” phenomena such as shading normals while at the same time retaining our drive for theoretically unbiased realism.
To this end, Milton supports a physicallyValid flag (specified either via the commandline or in the scenefile itself), which when enabled, enforces physical realism throughout Milton (eg, by disabling the usage of shading normals), and when disabled (default), allows the use of physically invalid, albeit useful techniques such as shading normals. Another post will explain our scenefile format in-depth and the reasons for the design choices we made, but one core concept that’s relevant here is that Milton scenefiles may override any built-in Milton type with an external plugin adhering to a well-defined interface to replace built-in types dynamically at run-time (via DSO libs of DLLs, respectively). The details of this aren’t important to this post, but one consideration is that this ‘physicallyValid’ contract could be violated if an external plugin were to use shading normals, for instance, without Milton’s explicit knowledge. We can, however, still ensure physical realism to a high degree of confidence even in the face of external plugins, by stochastically testing the behavior of plugins once at loadtime to ensure, in the case of external BSDFs, that they are symmetric (reciprocal) and energy conserving.
Here are a few test renders which use bump mapping to achieve an effect of more detailed geometry (all scenes contain one ground plane a point light). For more information on bump mapping, see Blinn’s original 1978 paper in which the technique was invented, Simulation of Wrinkled Surfaces.
- stone wall texture map
- stone wall bump map
- textured only
- textured and bump-mapped





































