2024
Unity Shaders Vertex Colors

Terrain Debris Matcher

Shape-Preserving Height Matching • Vertex Color Technique • HLSL Shader

02

The Innovation

Vertex color-based approach: Pre-compute the center of each mesh part and store it in vertex colors. Shader samples terrain height at the center, not per-vertex.

Vertex color visualization
03

Pre-Computation Tool

Editor tool analyzes mesh loose parts (like individual rocks in a pile), calculates their centers, and bakes the data into vertex colors.

Editor tool interface
04

Shader Implementation

Shader reads vertex color to get part center position, samples terrain height at that point, then moves all vertices of that part up/down together.

Shader graph
05

Shape Preservation

Unlike traditional methods, each rock maintains its original shape. Only the group's position adjusts to match terrain elevation.

Before and after comparison