About This Project
An example implementation of mesh-based decals in Unity. The decal mesh is generated by clipping the triangles of any intersecting meshes against the decal volume. The result is a decal mesh which is much cheaper to render than a decal projected at runtime. The mesh-based approach also allows decals to use simple materials and receive lighting without reliance on GBuffers or reconstructed normals from depth.
Advantages
Decals become regular meshes utilizing simpler materials, making them cheaper at runtime, especially on weaker hardware. They don't rely on GBuffers or depth to project on a surface and receive lighting, both realtime and baked. The mesh representation also allows for further optimization such as clipping by a polygon hull of the image to reduce overdraw. Decals can be highly selective about which meshes they consider or exclude, removing the need for stencil masking.
Trade-offs
The approach requires integration into a build pipeline and additional editor tooling. There's a potential increase in draw calls since unique meshes cannot benefit from instancing. Package size and VRAM usage may also increase due to each decal requiring a unique mesh.
Status
This is an exploration of the various algorithms involved. The code has been kept relatively simple with decent documentation to serve as an example should you wish to build a similar system for your own projects.