Table of Contents

πŸ”³ CosterGraphics.Systems.OutlineSystem


🧩 OutlineSystem Components Overview

🧠 MonoBehaviours

πŸ”³Outline3D : MonoBehaviour


Description: The Outline3D MonoBehaviour component marks a GameObject as outline-eligible/receiver and is used by the Renderer Features to filter out the objects that need to be rendered by it into the mask textures that are then used by the composite outline shaders.

Instead of filtering objects by GameObject layers or by Renderer Layers, which are project specific and probably already in use by you, I have chosen to filter by component instead for this system which is possible trough the use of Command Buffers and the RasterCommandBuffer.DrawMesh() and DrawRenderer() methods.

Using a component to filter also has the advantage that outlines can simply be enabled or disabled by enabling and disabling the Outline3D component on a GameObject which makes this system very easy to use espescially for per-object selection outlines.

Outline3D Component Responsibilities:

  • Registers itself with the renderer feature via static Outline3D.AllActiveOutlines list
  • Provides access to its Mesh or Skinned Mesh Renderers
  • Stores per-object data (FeatureID, ObjectID)

Read more about the πŸ”³Outline3D component on the component pages:



πŸ“œ Scriptable Renderer Features

πŸ§‘β€πŸŽ¨Outline3DRendererFeature : ScriptableRendererFeature


Description: Handles all rendering and compositing work.

Typical passes:

1. 🎭 Mask Pass

  • Draws all πŸ”³Outline3D objects into a dedicated mask texture
  • Produces a binary black or white silhouette
  • Optional: also capture depth or normals for contours

2. πŸ–ΌοΈ Composite Pass

  • Full-screen pass
  • Samples masks
  • Dilates / colors / blends
  • Performs Edge Detection
  • Writes result onto camera color buffer

Read more about what each πŸ§‘β€πŸŽ¨Outline3DRenderFeature does on the Renderer Features pages:



πŸ•ΆοΈ Shaders

🎭 Mask Shaders

πŸ” Intermediate Buffer Shaders

πŸ–ΌοΈ Full-Screen Composite Shaders


Description:

The Full-Screen Shader Graph Composite shaders that come with the OutlineSystem are like the 'meat' of the whole system. The OutlineSystem is designed for easily swapping between different outline Composite shader materials, to render different types of outlines dishes that require completely different types of raw or prepped ingredients.

Because there are so many possible combinations and types of Composite outlines that can be created the system splits them up into main categories for Silhouette outlines, Contour outlines and Hybrid outlines.

Silhouette outlines are for lines that only go around the perimiter of the masked shapes (think thick sticker like outer edges and basic selection type outlines.)

Contour outlines are for more stylistic/hand drawn type of outlines that can look like actual pen and ink drawings and that can go 'over' the shapes and edges of objects inside of the masks.

Hybrid outlines are for combinations of Silhouette, Contour and Overlay outlines. For instance for combinations of transparent colored overlays and a silhouette outlines look in the Hybrid shader folders.

The system also comes with a lot of extra composite Overlay shaders aren't technically outlines on their own but they're often used in combination with an outline to visualize a selection of some sorts. (The Unity Scene View selection outlines always show a quickly fading orange overlay as well as an orange outline when selecting a GameObject to make it extra clear what you just clicked on.)

Finally the OutlineSystem comes with a bunch of FullScreen composite shaders that are full-screen effects that don't filter out objects based on if they have the Outline3D component, but instead apply a post-processing effect that affects all objects in the entire scene equally. Some of the FullScreen shaders also perform edge detection just like the Silhouette and Contour outlines do but instead of performing the edge detection on the outline geometry masks it performs it on color, depth or normals of the entire scene, for instance via the URP camera opaque color texture buffer and via the Scene Depth buffer. Use the FullScreen composite shaders for complete stylized NPR effects and for non-selection based outlines.

The diagram below shows the OutlineSystem Shaders folder structure and how the Composite outline shaders are organized :

πŸ§œβ€β™‚οΈ

---
config:
  theme: neo-dark
---

flowchart LR

    Shaders["πŸ“ OutlineSystem/Shaders"]
    
    Simple["πŸ“ /10_Simple"] 
    Basic["πŸ“ /20_Basic"]
    Adv["πŸ“ /30_Adv"]
    Pro["πŸ“ /40_Pro"]

    Mask["πŸ“ /10_Mask"]
    Intermediate["πŸ“ /20_Intermediate"] 
    Composite["πŸ“ /30_Composite"]

    Overlay["πŸ“ /00_Overlay"]
    Silhouette["πŸ“ /10_Silhouette"]
    Contour["πŸ“ /20_Contour"]
    FullScreen["πŸ“ /30_FullScreen"]
    Hybrid["πŸ“ /40_Hybrid"]

    file["πŸ“„ Outline3DAdv-Cmp-Contour-SobelXY-DepthNormals&Color.shadergraph"]

    Shaders   --- Simple & Basic & Adv & Pro
    Adv       --- Mask & Intermediate & Composite
    Composite --- Overlay & Silhouette & Contour & FullScreen & Hybrid
    Contour --- file

A typical full-screen Composite shader has properties for:

  • πŸ‘οΈ Outline Visibility - To show or hide outlines behind other non-outlined geometry
  • 🎨 Outline Colors
  • πŸ”³ Outline Thickness
  • 🌠 Outline Thickness Space - To toggle between thickness in πŸ–₯️Screen Space or in πŸŽ₯View Space.
  • πŸ” Outline Edge Detection - Thresholds for Depth, Normals and Color edges.

At the bottom of the Composite shaders the properties of the masks that are used ⚠️ Internal by the Composite shaders are visibly shown for clarity but are automatically created and assigned by the Outline3DRenderFeatures.

Read more about the different types of shaders that come with the OutlineSystem: