surfgrad-bump-standalone-demo
surfgrad-bump-standalone-demo copied to clipboard
This demo shows how to use the surface gradient based framework to do compositing of bump maps in both simple and complex scenarios.
surfgrad-bump-standalone-demo
This demo serves as a reference implementation for how to use the Surface Gradient-Based Bump Mapping Framework in both simple and complex scenarios. The purpose of this framework is to provide a uniform approach to composite bump maps correctly and works for just about every imaginable type of bump mapping: Tangent space normal maps (incl. when using multiple sets of texture coordinates), Height Maps, object space normal maps, 3D bump maps such as triplanar projection, projective decals (box/cone/sphere), procedural 3D noise such as Perlin, Worley, ...
An additional feature of this framework is post-resolve bump mapping which allows us to bump map a surface which has already been bump mapped once. An example of this is shown here.
This example shows two parallax occlusion mapped (POM) surfaces. The new surface normal is evaluated directly from the height map itself, used with POM, which removes the need for the artist to have to guess the right scale factor between the height map and a corresponding normal map. The example on the left shows a detail bump map applied to the new virtual surface as post-resolve bump mapping where the correct mip level is determined analytically to account for displacement and 2x2 thread divergence. In the example on the right the post-resolve details are created with a procedural 3D bump map dented. In our implementation frequency clamping is used to alleviate aliasing since mip mapping isn't possible for a procedural texture.


As shown in this picture three different decal volume projectors are implemented in our demo (box/cone/sphere). In the case of a sphere the bump map is a cube normal map and represents the corresponding displacements mapped to the surface of an expanding sphere. In the pixel shader this normal is converted to a volume gradient for the 3D height field which next is converted to a surface gradient at the receiving surface.
Mip mapping is achieved by calculating the screen-space derivatives of the projected texture coordinate for each case analytically which works also when the receiving surface has POM applied to it. Correct compositing is achieved by generating the surface gradient which allows us to scale, accumulate and blend the same as for any other form of bump map.