Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion EdgeDetect-PostProcessingUnity/EdgeDetectPostProcessing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public override void Interp(EdgeDetectMode from, EdgeDetectMode to, float t)
[Range(0f,1f)]
public FloatParameter edgesOnly = new FloatParameter() { value = 0.0f };
public ColorParameter edgesOnlyBgColor = new ColorParameter() { value = Color.white };
public ColorParameter OutlineColor = new ColorParameter() { value = Color.white };
}

//--------------------------------------------------------------------------------------------------------------------------------
Expand All @@ -60,7 +61,8 @@ public override void Render(PostProcessRenderContext context)
sheet.properties.SetFloat("_BgFade", settings.edgesOnly);
sheet.properties.SetFloat("_SampleDistance", settings.sampleDist);
sheet.properties.SetVector("_BgColor", settings.edgesOnlyBgColor.value);
sheet.properties.SetFloat("_Exponent", settings.edgeExp);
sheet.properties.SetVector("_OutlineColor", settings.OutlineColor.value);
sheet.properties.SetFloat("_Exponent", settings.edgeExp);
sheet.properties.SetFloat("_Threshold", settings.lumThreshold);

context.command.BlitFullscreenTriangle(context.source, context.destination, sheet, (int)settings.mode.value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,19 @@ public class EdgeDetectPostProcessing_Editor<T> : PostProcessEffectEditor<T> whe
SerializedParameterOverride sampleDist;
SerializedParameterOverride edgesOnly;
SerializedParameterOverride edgesOnlyBgColor;
SerializedParameterOverride edgesOutlineColor;

GUIContent gc_mode = new GUIContent("Mode");
GUIContent gc_mode = new GUIContent("Mode");
GUIContent gc_sensitivityDepth = new GUIContent(" Depth Sensitivity");
GUIContent gc_sensitivityNormals = new GUIContent(" Normals Sensitivity");
GUIContent gc_lumThreshold = new GUIContent(" Luminance Threshold");
GUIContent gc_edgeExp = new GUIContent(" Edge Exponent");
GUIContent gc_sampleDist = new GUIContent(" Sample Distance");
GUIContent gc_edgesOnly = new GUIContent(" Edges Only");
GUIContent gc_edgesOnlyBgColor = new GUIContent(" Color");
GUIContent gc_edgesOutlineColor = new GUIContent(" Outline Color");

string gc_description = "Detects spatial differences and converts into black outlines\n\nLegacy image effect from previous Unity versions ported to Post Processing v2";
string gc_description = "Detects spatial differences and converts into black outlines\n\nLegacy image effect from previous Unity versions ported to Post Processing v2";
GUIContent gc_background = new GUIContent("Background Options");

public override void OnEnable()
Expand All @@ -43,7 +45,8 @@ public override void OnEnable()
sampleDist = FindParameterOverride(x => x.sampleDist);
edgesOnly = FindParameterOverride(x => x.edgesOnly);
edgesOnlyBgColor = FindParameterOverride(x => x.edgesOnlyBgColor);
}
edgesOutlineColor = FindParameterOverride(x => x.OutlineColor);
}

public override void OnInspectorGUI()
{
Expand Down Expand Up @@ -83,5 +86,6 @@ public override void OnInspectorGUI()
GUILayout.Label(gc_background);
PropertyField(edgesOnly, gc_edgesOnly);
PropertyField(edgesOnlyBgColor, gc_edgesOnlyBgColor);
}
PropertyField(edgesOutlineColor, gc_edgesOutlineColor);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Shader "Hidden/EdgeDetect-PostProcess"
//Settings
half4 _Sensitivity;
half4 _BgColor;
half4 _OutlineColor;
half _BgFade;
half _SampleDistance;
float _Exponent;
Expand Down Expand Up @@ -133,7 +134,9 @@ Shader "Hidden/EdgeDetect-PostProcess"
edge *= CheckSame(sample1.xy, DecodeFloatRG(sample1.zw), sample2);
edge *= CheckSame(sample3.xy, DecodeFloatRG(sample3.zw), sample4);

return edge * lerp(color, _BgColor, _BgFade);
half4 outlines = (1.0 - edge) * _OutlineColor;
half4 bg = edge * lerp(color, _BgColor, _BgFade);
return lerp(outlines, bg, edge);
}

//--------------------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -176,7 +179,10 @@ Shader "Hidden/EdgeDetect-PostProcess"
edge *= CheckSame(centerNormal, centerDepth, sample1);
edge *= CheckSame(centerNormal, centerDepth, sample2);

return edge * lerp(color, _BgColor, _BgFade);

half4 outlines = (1.0 - edge) * _OutlineColor;
half4 bg = edge * lerp(color, _BgColor, _BgFade);
return lerp(outlines, bg, edge);
}

//--------------------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -288,7 +294,9 @@ Shader "Hidden/EdgeDetect-PostProcess"
//if(len >= _Threshold)
// color.rgb = 0;

return len * lerp(color, _BgColor, _BgFade);
half4 outlines = (1.0 - len) * _OutlineColor;
half4 bg = len * lerp(color, _BgColor, _BgFade);
return lerp(outlines, bg, len);
}

ENDHLSL
Expand Down