Outline

Shader-based mesh outline rendering system. Adds configurable color and width outlines to GameObjects by dynamically appending outline mask and fill materials to renderers. Uses pre-baked smooth normals (stored in UV3) to eliminate hard-edge artifacts on outlined meshes.

Architecture

spinner

Data Flow

spinner

Key Concepts

Concept
Description

Outline

MonoBehaviour that manages outline rendering. Dynamically adds/removes mask and fill materials from renderers on enable/disable.

SmoothNormals

Static utility that pre-computes averaged normals for shared vertices and stores them in UV3. Prevents hard edges in outlines at mesh seams.

Outline Mask

Shared material using Outline/Mask shader. Writes to stencil buffer to define the outline silhouette.

Outline Fill

Per-instance material using Outline/Fill shader. Renders the colored outline at the configured width.

Rendering Layer Filter

Renderers on the "Ignore Outline Layer" are excluded from outline rendering.

Smooth Normal Cache

SmoothNormals caches computed normals per Mesh instance to avoid redundant computation across GameObjects sharing the same mesh.

Quick Start

1. Add an outline to a GameObject

2. Toggle outline visibility

3. Exclude renderers from outlining

Set the renderer's rendering layer mask to include the "Ignore Outline Layer" in the Inspector. The outline system will skip those renderers during Bake().

Classes

Class
Description

MonoBehaviour — outline rendering with color and width control

Static utility — smooth normal baking and caching

Editor

Class
Description

Custom Inspector with live preview

See Also

Last updated