Interactive OpenGL program implementing Xshade by Szymon Rusinkiewicz, Michael Burns, and Doug DeCarlo. Exaggerated Shading for Depicting Shape and Detail. ACM Transactions on Graphics (Proc. SIGGRAPH) 25(3), July 2006.
Diffuse Shading | Exaggerated Shading |
---|---|
Rendering of the 3D object with exaggerated details independent of light orientation can be seen.
In a directionally lighted scene, surfaces on a 3D mesh that are alligned to or perpendicular to the light direction have a tendency of losing detail and contrast when rendered. This paper provides a shading method that reveals details at all scales.
Exaggerated Shading for Depicting Shape and Detail proposes an original shading technique for revealing details at all frequencies, independent of light position and surface orientation.
This shading method is introduced as a form of "Multiscale local toon shading", and is based off of principle techniques used in cartographic terrain relief.
-
Lighting is clamped as a cel shader to emphasize large bends, oppposeed to gradually lighted rendering. In practice we use a "smooth clamp".
-
Lighting is computed at multiple scales using surface normals smoothed by different amounts to convey overall shape and details at different frequencies.
-
Light direction varies as if it is always at a grazing position with respect to the overall orientation of that part of the object, bringing out detail of the object.
- Shadows and specular reflections are omiited.
- Lighting should broadly seem to appear to originate from the top of the image. (Usually the upper left direction.)
- The origin direction of light can be locally adjusted. If a mountain curves on the map, one side of the map should be uniformly light and the other uniformly dark, regardless of the orientation to the light source.
- Height should be exaggerated, and ridges and valleys should have sharp transitions in brightness.
- The shaded image should be a blend between the original rendering and the smoothed version.
The shading method proposed in the paper requires several levels of smoothed normals to be preprocessed, each using a progressively larger Gaussian filter for smoothing of the normals.
For each smoothing scale, the standard deviation of the Gaussian filter is increased exponentially by a constant scalar coefficient. The paper suggests
As an implementation I've made a seperate repository for preprocessing and saving the smoothed normals of a 3D object at each scale using Gaussian fallout as weights.
With theses smoothed normals, the light direction is adjusted per vertex and per scale to attenuate detail at all frequencies.
The adjusted light intensity for exaggerated shading of details is implemented as below.
The clamp() function is used for "smooth cel shading". Used with coefficient
Then
The basic rendering model simply projects the light source at each point into the tangent plane perpendicular to the smoothed normal. Instead with a formulization of "contrast" proposed in the paper as :
This is intuitively understandable as the gradient
The paper references identities by do Carmo, 1976 that show an equivalence of this norm of gradient to :
where
Therefore, we come to the conclusion that maximum contrast, by our definition, is achieved when the light sourse is positioned along the first principal direction at each point.
The paper, published in 2006, renders these exaggerated shadings of 3D objects as images. Currently this method can be easily rendered in realtime with interactive controls for the user controlled hyperparameters provided in the paper.
- Switch between standard cosine shading and our exaggerated shading method.
- Model rotation and size.
- Rotation of "global" light direction.
- Number of Smoothing Scales to use in rendering.
- Exponent to
$\sigma$ of the contribution factor for each scale. A low factor will make the contribution of lower frequencies larger, emphasizing small details in the image. Vice versa a higher factor will make the contribution of larger frequencies higher, emphasizing large details and making the shading more smooth and less detailed. Optimal visuals usually lie between -0.5 and -1.0.
- Clamp Coefficient
$a$ for the "soft cel shading" implemented with clamp(). A factor of 20~50 reveals details well in most cases.
- Ambient factor added to all lighting. Default set as 0.5 in the methods proposed in the paper.
Written in C++ using OpenGL4 and GLFW3.
Used ImGui for interface purposes.
Used Assimp for loading 3D models.
Built using vcpkg on Windows.