Scripting Support (C#)

advanced scripting

Edge Fusion (HDRP) · Scripting Support (C#)

Namespace: EdgeFusion. The main component is EdgeFusionPass (a CustomPass added to a Custom Pass Volume). Per-object overrides use EdgeFusionObject (MonoBehaviour).

Getting Started

Add using EdgeFusion; at the top of your script. Edge Fusion uses the HDRP Custom Pass system:

using EdgeFusion;
using UnityEngine.Rendering.HighDefinition;

CustomPassVolume cpv = FindObjectOfType<CustomPassVolume>();
foreach (var pass in cpv.customPasses) {
    if (pass is EdgeFusionPass ef) {
        ef.intensity = 0.8f;
        ef.radius = 0.02f;
        break;
    }
}

EdgeFusionPass (Custom Pass)

Layer Selection

LayerMask blendLayers

Default layers that participate in edge fusion blending.

RenderingLayerMask renderingLayerFilter

Rendering layer filter for single-sided objects selected by Blend Layers.

bool blendWithOthers

When enabled, geometry not selected by any layer setting also blends with marked objects (default true).

LayerMask doubleSidedLayers

Layers rendered double-sided in the ObjectID pass.

RenderingLayerMask doubleSidedRenderingLayerFilter

Rendering layer filter for double-sided selection.

LayerMask specialGroupLayers

Layers for GameObjects with special vertex shaders that should also blend.

RenderingLayerMask specialGroupRenderingLayerFilter

Rendering layer filter for special group selection.

Effect Settings

float intensity

Overall intensity of the edge fusion effect (0–1, default 1).

float radius

Default blur radius in world units / meters (0.0001–0.5, default 0.035).

bool enableIntraObjectFusion

Enable fusion of edges within the same object based on normal/depth discontinuities.

bool intraObjectFusionPerObject

When enabled, intra-object fusion only runs on renderers with an EdgeFusionObject component that allows it.

bool concavityTest

When enabled, only fuse concave edges. When disabled, both concave and convex edges are fused.

float normalThreshold

Normal threshold for detecting edges within the same object (0.001–0.95, default 0.6).

float shadowProtection

Threshold for shadow detection and blending adjustment (0–0.01, default 0.0002).

Quality

int sampleCount

Number of samples for edge detection (4–32, default 24).

bool jitter

Enables temporal jitter to reduce banding artifacts.

float maxBlendDistance

Maximum distance for edge blending (default 50).

int binarySearchSteps

Number of binary search refinement steps when locating the nearest edge (1–10, default 7).

int earlyExitHits

Max number of edge hits before early exit (1–32, default 5).

float maxScreenRadius

Maximum screen-space search radius (0.01–0.5, default 0.1).

float msaaEdgeFixPower

Adjusts color sampling to reduce MSAA edge artifacts. Only applicable with MSAA enabled.

Noise

float noiseIntensity

Intensity of the 3D noise texture applied to blending (0–1).

float noiseScale

Scale of the 3D noise texture sampling (0.1–10, default 5).

float noiseContrast

Contrast of the noise applied to edge positions (0–1, default 0.75).

ID Exclusions

IdExclusionPair[] idExclusionPairs

Pairs of custom Object IDs that should not blend with each other. IDs 1–30 are user-assignable, 31 = terrain/non-blend-layer objects, 32 = special group.

Debug & Compare

DebugMode debugMode

Selects debug visualization: None, ObjectIds, Edges, Blending, Normals, Depth, SpecialGroup.

float depthMultiplier

Depth visualization multiplier for the Depth debug mode (1–100, default 1).

bool compareMode

Enable A/B comparison with a split line.

bool compareSameSide

Pans the split line horizontally over the same side.

float comparePanning

Horizontal panning of the split line (0–0.5, default 0.25).

float compareLineAngle

Angle of the compare divider line (default 1.4).

float compareLineWidth

Width of the compare divider line (0.0001–0.05, default 0.002).

Color compareLineColor

Color of the compare divider line (default white).

EdgeFusionObject (Per-Object Component)

Properties

bool overrideRadius

Enable a custom blend radius for this specific object.

float customRadius

Custom blend radius in meters (0–0.5, default 0.05). Set to 0 to disable blending for this object.

bool overrideObjectId

Enable a custom Object ID for this object.

int customObjectId

Custom Object ID. Objects with the same ID are considered the same for inter-object detection.

bool useRandomId

Use a random Object ID instead of one derived from object position.

bool randomIdPerChild

Assign a different random ID to each child renderer.

bool disallowIntraObjectFusion

Disable intra-object fusion for this object while keeping inter-object fusion.

IncludeMode includeMode

Whether to include only this object or also its children: OnlyThisObject (default) or IncludeChildren.

LayerMask childLayerMask

Layer mask filter for child renderers when includeMode is IncludeChildren.

List<Renderer> renderers read-only

List of renderers managed by this component.

Material nonInstancingMaterial

If set, indicates a material on the managed renderers that does not support GPU instancing.

Methods

void Refresh()

Rebuild the renderer list and update material properties. Call after modifying component settings at runtime.

Code Examples

using EdgeFusion;
using UnityEngine.Rendering.HighDefinition;

// Access EdgeFusionPass from a Custom Pass Volume
CustomPassVolume cpv = FindObjectOfType<CustomPassVolume>();
foreach (var pass in cpv.customPasses) {
    if (pass is EdgeFusionPass ef) {
        ef.intensity = 1.0f;
        ef.radius = 0.02f;
        ef.sampleCount = 24;
        ef.enableIntraObjectFusion = true;
        break;
    }
}

// Override radius for a specific object
EdgeFusionObject efo = myObject.AddComponent<EdgeFusionObject>();
efo.overrideRadius = true;
efo.customRadius = 0.05f;
efo.includeMode = IncludeMode.IncludeChildren;
efo.Refresh();
Was this page helpful?