What is Cavifree?
Cavifree is a screen space post-processing effect for Unity, mimicking Blender’s cavity effect. By highlighting the edges and crevices of objects in a scene, it enhances their depth, making them look more detailed.
The shader works by calculating the curvature of surfaces, sampling normals from the normal buffer in each pixel, and analyzing how these normals change in the X and Y directions.
Practical information
Integrating Cavifree into your Unity project is straightforward and only takes one minute, with support for both the Universal Render Pipeline (URP) and the High Definition Render Pipeline (HDRP). The shader has been tested and confirmed to work on Unity 2022 LTS and Unity 2023.
Motivation
The idea for this shader came from screenshots sent to me by a talented 3D artist working on our game “Break, Enter, Repeat”. Seeing how good this visual effect looked in Blender, I was inspired to bring a similar aesthetic to Unity. The low-poly style of our game was a perfect fit for the depth-enhancing “cavity” effect, inspiring me to start working on the development of this shader.
Get started
Check out the source code and detailed setup instructions on GitHub to get started!