1y ago · Oct 15, 2024 2:20 PM
Unlike flat solid Chams, Stencil Glow Outlines render a crisp colored border around player silhouettes while preserving original character textures inside.
How Stencil Outlines work in Unity Graphics Pipeline:
1. Mask Pass: Render character mesh into the Stencil Buffer with a constant reference value (e.g.).
2. Outline Pass: Invert or extrude mesh vertices along normal vectors by a small thickness (), and only draw pixels where (preventing the outline from rendering over the player's body).
How Stencil Outlines work in Unity Graphics Pipeline:
1. Mask Pass: Render character mesh into the Stencil Buffer with a constant reference value (e.g.
CODE
Ref 1, Comp Always, Pass Replace2. Outline Pass: Invert or extrude mesh vertices along normal vectors by a small thickness (
CODE
1.03x CODE
Stencil Comp NotEqual CSHARP
using UnityEngine;
public static class OutlineHelper
{
public static void AddOutlineComponent(GameObject playerObject, Color outlineColor, float width = 4f)
{
// Many Unity games include QuickOutline or built-in Outline scripts
// Or you can instantiate a CommandBuffer outline pass attached to Camera.main
var outline = playerObject.GetComponent<Outline>();
if (outline == null)
{
outline = playerObject.AddComponent<Outline>();
}
outline.OutlineMode = Outline.Mode.OutlineAll;
outline.OutlineColor = outlineColor;
outline.OutlineWidth = width;
outline.enabled = true;
}
}
RenderMaster | Clean UI Design & Dear ImGui widgets
The following users thanked RenderMaster for this post: