Surface warpage can be a key to photorealism when digitally rendering a model, but is surprisingly rare in real-time graphics. To solve this issue, I created a custom generator for Substance Designer/Painter that allows artists to procedurally apply surface warpage to the normals of a model.
For the best results, a high-quality, watertight mesh is created prior to baking. This process can be easily automated in programs such as Maya or ZBrush. For this example, after creating a low-poly mesh for baking to, I used the following code-snippet to quickly apply bevels based on edge shading method, in order to create a high-poly version.
import maya.cmds as cmds
cmds.polySoftEdge(a=50) # Select edges based on angle
cmds.polyMergeVertex(d=0.001) # Merge any overlapping vertices
cmds.polySelectConstraint(m=3, t=0x8000, sm=1) # Smooth all faces
cmds.polyBevel3(o=0.025, sg=3, fn=True, sa=360, m=0) # Add a bevel to the the selected edges
With the mesh complete, it is imported into Substance Painter. Position, Curvature, Normal, and Thickness maps are baked from the high-poly mesh, and fed into the warpage generator, which generates a new normal map influenced by the curvature and thickness of the mesh. This has the end result of providing the illusion of physically-based surface warpage.