/surfgrad-bump-standalone-demo

This demo shows how to use the surface gradient based framework to do compositing of bump maps in both simple and complex scenarios.

Primary LanguageC++MIT LicenseMIT

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. Detail Map on POM surface

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.

multiple sets of UV

This example shows a low polygonal mesh with a baked normal map assigned to the primary set of texture coordinates. A separate normal map of generic tileable detail is added on top. In the image on the left the detail normal map is assigned to the primary set of texture coordinates which appears wrong. For the image on the right the details are assigned to the secondary set of texture coordinates which allows the tiling direction to align with the shoulder strap. Note that there is no precomputed vertex tangent space for the secondary set of texture coordinates. Furthermore, we are able to composite bump contributions correctly when using multiple sets of texture coordinates including the ability to composite with object space normal maps.

Decal Projectors

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.