Advanced Outline System

Offline Documentation & Setup Guide

Table of Contents

  1. 1. Overview
  2. 2. Quick Start Setup Guide
  3. 3. Component Properties Reference
  4. 4. Script Reference (API)
  5. 5. Shader Details & Rendering Pipeline
  6. 6. Troubleshooting & FAQ

1. Overview

The Advanced Outline System is a high-performance, feature-rich screen-space outline solution for Unity. It uses the stencil buffer to render crisp, pixel-perfect outlines around meshes, including static meshes and skinned mesh hierarchies. The system dynamically creates temporary mesh clones at runtime to compute and assign smooth normals, resolving ugly outlines on hard-edged shapes without altering original asset files on disk.

Pipeline Compatibility: The system natively supports both the Built-in Render Pipeline (Standard) and the Universal Render Pipeline (URP) out of the box. It automatically detects the active render pipeline at runtime and loads the appropriate shaders dynamically.

2. Quick Start Setup Guide

Follow these steps to apply outlines to any object in your scene:

  1. Add the Component: Select the GameObject you want to outline. In the Inspector, click Add Component, search for Advanced Outline, and add it.
  2. Shader Assignment: The component automatically finds and instantiates the necessary shaders (switching automatically between the standard shaders for Built-in and URP-specific shaders for Universal Render Pipeline projects).
  3. Configure Visuals: Choose the preferred Outline Mode (e.g., OutlineVisible, OutlineAll), select an **Outline Color**, and adjust the **Outline Width** in the Inspector.

3. Component Properties Reference

3.1. General Settings

3.2. Aesthetic Effects (Blendable)

3.3. Performance & Baking

4. Script Reference (API)

Access and control the system dynamically through code using the following interface:

Property / Method Type Description
OutlineMode AdvancedOutline.Mode Gets or sets the current active outline depth mode.
OutlineColor Color Gets or sets the base outline color.
OutlineWidth float Gets or sets the outline thickness (0 to 10).
PulseWidth bool Enables or disables outline width pulsing.
RainbowColor bool Enables or disables color cycling.
DashedPattern bool Enables or disables the dashed crawling-ants pattern.
RefreshRenderers() void Forces the component to rebuild renderer caches and recalculate mesh copies. Call this if hierarchy changes at runtime.

4.3. Code Example: Controlling Outlines via Script

To control outline settings dynamically at runtime from other scripts, import the ITISKIRUHERE namespace and modify the component properties as shown in the example below:

using UnityEngine;
using ITISKIRUHERE; // Namespace for the Advanced Outline component

public class OutlineController : MonoBehaviour
{
    [Header("Outline Reference")]
    [SerializeField] private AdvancedOutline _outline;

    private void Start()
    {
        // Automatically find component if not set in Inspector
        if (_outline == null)
        {
            _outline = GetComponent<AdvancedOutline>();
        }
    }

    // Example 1: Activate a pulsing red outline
    public void EnableDangerOutline()
    {
        if (_outline == null) return;

        // Ensure the component is active
        _outline.enabled = true;

        // Configure properties
        _outline.OutlineMode = AdvancedOutline.Mode.OutlineAll;
        _outline.OutlineColor = Color.red;
        _outline.OutlineWidth = 6f;

        // Enable pulsing width animation
        _outline.PulseWidth = true;
        _outline.PulseSpeed = 4f;
        _outline.PulseMinWidth = 2f;
        _outline.PulseMaxWidth = 8f;

        // Disable other conflicting effects
        _outline.RainbowColor = false;
        _outline.DashedPattern = false;
    }

    // Example 2: Activate a crawling dashed cyber outline
    public void EnableCyberOutline()
    {
        if (_outline == null) return;

        _outline.enabled = true;

        // Configure properties
        _outline.OutlineMode = AdvancedOutline.Mode.OutlineVisible;
        _outline.OutlineColor = Color.cyan;
        _outline.OutlineWidth = 4f;

        // Turn off pulsing and turn on dashed crawling pattern
        _outline.PulseWidth = false;
        _outline.RainbowColor = false;
        _outline.DashedPattern = true;
    }

    // Example 3: Completely disable the outline effect
    public void DisableOutline()
    {
        if (_outline != null)
        {
            _outline.enabled = false;
        }
    }
}

5. Shader Details & Rendering Pipeline

The system utilizes two passes for clean composition:

  1. Mask Pass: Draws first, writing a value of 1 to the stencil buffer where the object is rendered. It does not write to the color channel (ColorMask 0).
  2. Fill Pass: Extrudes mesh vertices outward along the precalculated smooth normals. It compares the stencil buffer and discards fragments where the value is 1, ensuring the outline only renders around the outer boundary of the object.

6. Troubleshooting & FAQ

Q: Why does the outline look jagged on my low-poly mesh?
A: Ensure Precompute Outline is checked or that smooth normals have finished baking. The script requires averaged normals to align vertex extrusion correctly across sharp polygon seams.

Q: Does this component support Skinned Mesh Renderers?
A: Yes, the component automatically detects and supports skinned meshes. They are cloned and updated dynamically in memory, restoring the original mesh configurations cleanly upon script disable/destruction.

Q: Why did my mesh disappear when disabling the script in older versions?
A: In version 1.0, the script destroyed instantiated mesh copies without restoring the original mesh references to the MeshFilter/SkinnedMeshRenderer. This has been fully corrected in version 1.1+.