Scripting Support (C#)
advanced scriptingEdge Fusion (HDRP) · Scripting Support (C#)
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 blendLayersDefault layers that participate in edge fusion blending.
RenderingLayerMask renderingLayerFilterRendering layer filter for single-sided objects selected by Blend Layers.
bool blendWithOthersWhen enabled, geometry not selected by any layer setting also blends with marked objects (default true).
LayerMask doubleSidedLayersLayers rendered double-sided in the ObjectID pass.
RenderingLayerMask doubleSidedRenderingLayerFilterRendering layer filter for double-sided selection.
LayerMask specialGroupLayersLayers for GameObjects with special vertex shaders that should also blend.
RenderingLayerMask specialGroupRenderingLayerFilterRendering layer filter for special group selection.
Effect Settings
float intensityOverall intensity of the edge fusion effect (0–1, default 1).
float radiusDefault blur radius in world units / meters (0.0001–0.5, default 0.035).
bool enableIntraObjectFusionEnable fusion of edges within the same object based on normal/depth discontinuities.
bool intraObjectFusionPerObjectWhen enabled, intra-object fusion only runs on renderers with an EdgeFusionObject component that allows it.
bool concavityTestWhen enabled, only fuse concave edges. When disabled, both concave and convex edges are fused.
float normalThresholdNormal threshold for detecting edges within the same object (0.001–0.95, default 0.6).
float shadowProtectionThreshold for shadow detection and blending adjustment (0–0.01, default 0.0002).
Quality
int sampleCountNumber of samples for edge detection (4–32, default 24).
bool jitterEnables temporal jitter to reduce banding artifacts.
float maxBlendDistanceMaximum distance for edge blending (default 50).
int binarySearchStepsNumber of binary search refinement steps when locating the nearest edge (1–10, default 7).
int earlyExitHitsMax number of edge hits before early exit (1–32, default 5).
float maxScreenRadiusMaximum screen-space search radius (0.01–0.5, default 0.1).
float msaaEdgeFixPowerAdjusts color sampling to reduce MSAA edge artifacts. Only applicable with MSAA enabled.
Noise
float noiseIntensityIntensity of the 3D noise texture applied to blending (0–1).
float noiseScaleScale of the 3D noise texture sampling (0.1–10, default 5).
float noiseContrastContrast of the noise applied to edge positions (0–1, default 0.75).
ID Exclusions
IdExclusionPair[] idExclusionPairsPairs 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 debugModeSelects debug visualization: None, ObjectIds, Edges, Blending, Normals, Depth, SpecialGroup.
float depthMultiplierDepth visualization multiplier for the Depth debug mode (1–100, default 1).
bool compareModeEnable A/B comparison with a split line.
bool compareSameSidePans the split line horizontally over the same side.
float comparePanningHorizontal panning of the split line (0–0.5, default 0.25).
float compareLineAngleAngle of the compare divider line (default 1.4).
float compareLineWidthWidth of the compare divider line (0.0001–0.05, default 0.002).
Color compareLineColorColor of the compare divider line (default white).
EdgeFusionObject (Per-Object Component)
Properties
bool overrideRadiusEnable a custom blend radius for this specific object.
float customRadiusCustom blend radius in meters (0–0.5, default 0.05). Set to 0 to disable blending for this object.
bool overrideObjectIdEnable a custom Object ID for this object.
int customObjectIdCustom Object ID. Objects with the same ID are considered the same for inter-object detection.
bool useRandomIdUse a random Object ID instead of one derived from object position.
bool randomIdPerChildAssign a different random ID to each child renderer.
bool disallowIntraObjectFusionDisable intra-object fusion for this object while keeping inter-object fusion.
IncludeMode includeModeWhether to include only this object or also its children: OnlyThisObject (default) or IncludeChildren.
LayerMask childLayerMaskLayer mask filter for child renderers when includeMode is IncludeChildren.
List<Renderer> renderers read-onlyList of renderers managed by this component.
Material nonInstancingMaterialIf 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();Suggest an improvement
Help us improve this documentation page.