Skip to content

Commit

Permalink
[8.x.x Backport] Fix pre/post pass sg properties #82 (#86)
Browse files Browse the repository at this point in the history
* Fix depth pre/post passes not correctly enabled when switching shaders on the material

# Conflicts:
#	com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitMasterNode.cs
#	com.unity.render-pipelines.high-definition/Editor/Material/Unlit/HDShaderGUI.cs
#	com.unity.render-pipelines.high-definition/Editor/ShaderGraph/HDSubShaderUtilities.cs

* Hide prepass and postpass in the material UI

# Conflicts:
#	com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/SurfaceOptionUIBlock.cs

* Updated changelog

Co-authored-by: sebastienlagarde <sebastien@unity3d.com>
  • Loading branch information
alelievr and sebastienlagarde committed May 5, 2020
1 parent 3f6c2f2 commit 990903f
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 11 deletions.
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed scalarization code for contact shadows
- Fix MaterialBalls having same guid issue
- Fix spelling and grammatical errors in material samples
- Fixed depth prepass and postpass being disabled after changing the shader in the material UI.

### Changed
- Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ class EyeGUI : HDShaderGUI
// For surface option shader graph we only want all unlit features but alpha clip, back then front rendering and SSR
const SurfaceOptionUIBlock.Features surfaceOptionFeatures = SurfaceOptionUIBlock.Features.Unlit
^ SurfaceOptionUIBlock.Features.AlphaCutoffThreshold
^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass;
^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass
^ SurfaceOptionUIBlock.Features.ShowPrePassAndPostPass;

MaterialUIBlockList uiBlocks = new MaterialUIBlockList
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,7 @@ public override void CollectShaderProperties(PropertyCollector collector, Genera
);
HDSubShaderUtilities.AddAlphaCutoffShaderProperties(collector, alphaTest.isOn, false);
HDSubShaderUtilities.AddDoubleSidedProperty(collector, doubleSidedMode);
HDSubShaderUtilities.AddPrePostPassProperties(collector, alphaTestDepthPrepass.isOn, alphaTestDepthPostpass.isOn);

base.CollectShaderProperties(collector, generationMode);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class FabricGUI : HDShaderGUI
const SurfaceOptionUIBlock.Features surfaceOptionFeatures = SurfaceOptionUIBlock.Features.Unlit
^ SurfaceOptionUIBlock.Features.AlphaCutoffThreshold
^ SurfaceOptionUIBlock.Features.BackThenFrontRendering
^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass;
^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass
^ SurfaceOptionUIBlock.Features.ShowPrePassAndPostPass;

MaterialUIBlockList uiBlocks = new MaterialUIBlockList
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,7 @@ public override void CollectShaderProperties(PropertyCollector collector, Genera
);
HDSubShaderUtilities.AddAlphaCutoffShaderProperties(collector, alphaTest.isOn, false);
HDSubShaderUtilities.AddDoubleSidedProperty(collector, doubleSidedMode);
HDSubShaderUtilities.AddPrePostPassProperties(collector, false, false);

base.CollectShaderProperties(collector, generationMode);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class HairGUI : HDShaderGUI
const SurfaceOptionUIBlock.Features surfaceOptionFeatures = SurfaceOptionUIBlock.Features.Unlit
^ SurfaceOptionUIBlock.Features.AlphaCutoffThreshold
^ SurfaceOptionUIBlock.Features.BackThenFrontRendering
^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass;
^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass
^ SurfaceOptionUIBlock.Features.ShowPrePassAndPostPass;

MaterialUIBlockList uiBlocks = new MaterialUIBlockList
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,7 @@ public override void CollectShaderProperties(PropertyCollector collector, Genera
);
HDSubShaderUtilities.AddAlphaCutoffShaderProperties(collector, alphaTest.isOn, alphaTestShadow.isOn);
HDSubShaderUtilities.AddDoubleSidedProperty(collector, doubleSidedMode);
HDSubShaderUtilities.AddPrePostPassProperties(collector, alphaTestDepthPrepass.isOn, alphaTestDepthPostpass.isOn);

base.CollectShaderProperties(collector, generationMode);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class HDLitGUI : HDShaderGUI
const SurfaceOptionUIBlock.Features surfaceOptionFeatures = SurfaceOptionUIBlock.Features.Unlit
^ SurfaceOptionUIBlock.Features.AlphaCutoffThreshold
^ SurfaceOptionUIBlock.Features.BackThenFrontRendering
^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass;
^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass
^ SurfaceOptionUIBlock.Features.ShowPrePassAndPostPass;

MaterialUIBlockList uiBlocks = new MaterialUIBlockList
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,7 @@ public override void CollectShaderProperties(PropertyCollector collector, Genera
);
HDSubShaderUtilities.AddAlphaCutoffShaderProperties(collector, alphaTest.isOn, alphaTestShadow.isOn);
HDSubShaderUtilities.AddDoubleSidedProperty(collector, doubleSidedMode);
HDSubShaderUtilities.AddPrePostPassProperties(collector, alphaTestDepthPrepass.isOn, alphaTestDepthPostpass.isOn);

base.CollectShaderProperties(collector, generationMode);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class StackLitGUI : HDShaderGUI
const SurfaceOptionUIBlock.Features surfaceOptionFeatures = SurfaceOptionUIBlock.Features.Unlit
^ SurfaceOptionUIBlock.Features.AlphaCutoffThreshold
^ SurfaceOptionUIBlock.Features.BackThenFrontRendering
^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass;
^ SurfaceOptionUIBlock.Features.ShowAfterPostProcessPass
^ SurfaceOptionUIBlock.Features.ShowPrePassAndPostPass;

MaterialUIBlockList uiBlocks = new MaterialUIBlockList
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1424,6 +1424,7 @@ public override void CollectShaderProperties(PropertyCollector collector, Genera
);
HDSubShaderUtilities.AddAlphaCutoffShaderProperties(collector, alphaTest.isOn, false);
HDSubShaderUtilities.AddDoubleSidedProperty(collector, doubleSidedMode);
HDSubShaderUtilities.AddPrePostPassProperties(collector, false, false);

base.CollectShaderProperties(collector, generationMode);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public enum Features
ReceiveSSR = 1 << 8,
ShowAfterPostProcessPass = 1 << 9,
Unlit = Surface | BlendMode | DoubleSided | DoubleSidedNormalMode | AlphaCutoff | AlphaCutoffShadowThreshold | AlphaCutoffThreshold | BackThenFrontRendering | ShowAfterPostProcessPass,
ShowPrePassAndPostPass = 1 << 11,
Lit = All,
All = ~0,
}
Expand Down Expand Up @@ -483,11 +484,14 @@ void DrawSurfaceGUI()
if (transparentBackfaceEnable != null)
materialEditor.ShaderProperty(transparentBackfaceEnable, Styles.transparentBackfaceEnableText);

if (transparentDepthPrepassEnable != null)
materialEditor.ShaderProperty(transparentDepthPrepassEnable, Styles.transparentDepthPrepassEnableText);
if ((m_Features & Features.ShowPrePassAndPostPass) != 0)
{
if (transparentDepthPrepassEnable != null)
materialEditor.ShaderProperty(transparentDepthPrepassEnable, Styles.transparentDepthPrepassEnableText);

if (transparentDepthPostpassEnable != null)
materialEditor.ShaderProperty(transparentDepthPostpassEnable, Styles.transparentDepthPostpassEnableText);
if (transparentDepthPostpassEnable != null)
materialEditor.ShaderProperty(transparentDepthPostpassEnable, Styles.transparentDepthPostpassEnableText);
}

if (transparentWritingMotionVec != null)
materialEditor.ShaderProperty(transparentWritingMotionVec, Styles.transparentWritingMotionVecText);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ protected static void ResetMaterialCustomRenderQueue(Material material)
}

readonly static string[] floatPropertiesToSynchronize = {
"_UseShadowThreshold", kReceivesSSR, kUseSplitLighting
"_UseShadowThreshold", kReceivesSSR, kUseSplitLighting,
kTransparentDepthPrepassEnable, kTransparentDepthPostpassEnable
};

protected static void SynchronizeShaderGraphProperties(Material material)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class HDUnlitGUI : HDShaderGUI
const SurfaceOptionUIBlock.Features surfaceOptionFeatures = SurfaceOptionUIBlock.Features.Unlit
^ SurfaceOptionUIBlock.Features.AlphaCutoffThreshold
^ SurfaceOptionUIBlock.Features.DoubleSidedNormalMode
^ SurfaceOptionUIBlock.Features.BackThenFrontRendering;
^ SurfaceOptionUIBlock.Features.BackThenFrontRendering
^ SurfaceOptionUIBlock.Features.ShowPrePassAndPostPass;

MaterialUIBlockList uiBlocks = new MaterialUIBlockList
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ public override void CollectShaderProperties(PropertyCollector collector, Genera
);
HDSubShaderUtilities.AddAlphaCutoffShaderProperties(collector, alphaTest.isOn, false);
HDSubShaderUtilities.AddDoubleSidedProperty(collector, doubleSided.isOn ? DoubleSidedMode.Enabled : DoubleSidedMode.Disabled);
HDSubShaderUtilities.AddPrePostPassProperties(collector, false, false);

base.CollectShaderProperties(collector, generationMode);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1336,6 +1336,12 @@ public static void AddDoubleSidedProperty(PropertyCollector collector, DoubleSid
});
}

public static void AddPrePostPassProperties(PropertyCollector collector, bool prepass, bool postpass)
{
collector.AddToggleProperty(kTransparentDepthPrepassEnable, prepass);
collector.AddToggleProperty(kTransparentDepthPostpassEnable, postpass);
}

public static string RenderQueueName(HDRenderQueue.RenderQueueType value)
{
switch (value)
Expand Down

0 comments on commit 990903f

Please sign in to comment.