Skip to content

Commit c9b5867

Browse files
committed
add depth fill pass
1 parent 6bb1d90 commit c9b5867

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

Editor/Generation/ShaderBuilder.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,10 @@ public static void AppendTags(ShaderStringBuilder sb, Dictionary<string, string>
535535

536536
private void AppendPasses()
537537
{
538+
if (ShaderGraphView.graphData.depthFillPass)
539+
{
540+
_sb.AppendLine("Pass { ZWrite On ColorMask 0 }");
541+
}
538542
if (grabpass && SupportsGrabpas)
539543
{
540544
_sb.AppendLine("GrabPass { Tags { \"LightMode\" = \"GrabPass\" } \"_CameraOpaqueTexture\" }");

Editor/Generation/TemplateOutput.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ public override void AdditionalElements(VisualElement root)
6464
var outline = new EnumField("Outline Pass", graphData.outlinePass);
6565
outline.RegisterValueChangedCallback(x => graphData.outlinePass = (GraphData.OutlinePassMode)x.newValue);
6666
root.Add(outline);
67+
68+
// https://github.com/pema99/shader-knowledge/blob/main/tips-and-tricks.md#avoiding-draw-order-issues-with-transparent-shaders
69+
var depthFill = new Toggle("Depth Fill Pass") { value = graphData.depthFillPass, tooltip = "Avoid draw order issues with transparent shaders" };
70+
depthFill.RegisterValueChangedCallback(x => graphData.depthFillPass = x.newValue);
71+
root.Add(depthFill);
6772

6873
var stencil = new Toggle("Stencil") { value = graphData.stencil };
6974
stencil.RegisterValueChangedCallback(x => graphData.stencil = x.newValue);

Editor/Serialization/GraphData.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class GraphData
1414
public string fallback = string.Empty;
1515
public string include = string.Empty;
1616
public OutlinePassMode outlinePass = OutlinePassMode.Disabled;
17+
public bool depthFillPass = false;
1718
public bool stencil = false;
1819
public VRCFallbackTags vrcFallbackTags = new VRCFallbackTags();
1920
public bool unlocked = false;

0 commit comments

Comments
 (0)