浏览代码

Merge pull request #718 from Unity-Technologies/Homogeneous-naming-postpas-prepass

HDRenderPipeline: Homegenize name prepass postpass
/feature-ReflectionProbeFit
GitHub 7 年前
当前提交
fa0eed63
共有 9 个文件被更改,包括 41 次插入41 次删除
  1. 4
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/Lit/LitUI.cs
  2. 20
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/Unlit/BaseUnlitUI.cs
  3. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDCustomSamplerId.cs
  4. 18
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs
  5. 8
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDStringConstants.cs
  6. 4
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.shader
  7. 4
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/LitTessellation.shader
  8. 18
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipeline/FrameSettings.cs
  9. 4
      ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipeline.cs

4
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/Lit/LitUI.cs


EditorGUILayout.LabelField(StylesBaseUnlit.TransparencyInputsText, EditorStyles.boldLabel);
++EditorGUI.indentLevel;
var isPrePass = material.HasProperty(kPreRefractionPass) && material.GetFloat(kPreRefractionPass) > 0.0;
var isPrepass = material.HasProperty(kPreRefractionPass) && material.GetFloat(kPreRefractionPass) > 0.0;
&& !isPrePass)
&& !isPrepass)
{
m_MaterialEditor.ShaderProperty(refractionMode, Styles.refractionModeText);
var mode = (Lit.RefractionMode)refractionMode.floatValue;

20
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/Unlit/BaseUnlitUI.cs


public static GUIContent distortionBlurScaleText = new GUIContent("Distortion Blur Scale", "Distortion Blur Scale");
public static GUIContent distortionBlurRemappingText = new GUIContent("Distortion Blur Remapping", "Distortion Blur Remapping");
public static GUIContent transparentPrePassText = new GUIContent("Pre Refraction Pass", "Render objects before the refraction pass");
public static GUIContent transparentPrepassText = new GUIContent("Pre Refraction Pass", "Render objects before the refraction pass");
public static string advancedText = "Advanced Options";
}

if (enableFogOnTransparent != null)
m_MaterialEditor.ShaderProperty(enableFogOnTransparent, StylesBaseUnlit.enableTransparentFogText);
if (preRefractionPass != null)
m_MaterialEditor.ShaderProperty(preRefractionPass, StylesBaseUnlit.transparentPrePassText);
m_MaterialEditor.ShaderProperty(preRefractionPass, StylesBaseUnlit.transparentPrepassText);
EditorGUI.indentLevel--;
}

{
material.SetOverrideTag("RenderType", "Transparent");
material.SetInt("_ZWrite", 0);
var isPrePass = material.HasProperty(kPreRefractionPass) && material.GetFloat(kPreRefractionPass) > 0.0f;
material.renderQueue = (int)(isPrePass ? HDRenderQueue.PreRefraction : HDRenderQueue.Transparent);
var isPrepass = material.HasProperty(kPreRefractionPass) && material.GetFloat(kPreRefractionPass) > 0.0f;
material.renderQueue = (int)(isPrepass ? HDRenderQueue.PreRefraction : HDRenderQueue.Transparent);
if (material.HasProperty(kBlendMode))
{

material.SetShaderPassEnabled(HDShaderPassNames.s_GBufferDebugDisplayStr, true);
material.SetShaderPassEnabled(HDShaderPassNames.s_MotionVectorsStr, enablePass);
material.SetShaderPassEnabled(HDShaderPassNames.s_DistortionVectorsStr, distortionEnable); // note: use distortionEnable
material.SetShaderPassEnabled(HDShaderPassNames.s_TransparentDepthPrePassStr, enablePass);
material.SetShaderPassEnabled(HDShaderPassNames.s_TransparentDepthPrepassStr, enablePass);
material.SetShaderPassEnabled(HDShaderPassNames.s_TransparentDepthPostPassStr, enablePass);
material.SetShaderPassEnabled(HDShaderPassNames.s_TransparentDepthPostpassStr, enablePass);
material.SetShaderPassEnabled(HDShaderPassNames.s_MetaStr, enablePass);
material.SetShaderPassEnabled(HDShaderPassNames.s_ShadowCasterStr, enablePass);
}

bool depthWriteEnable = (material.GetFloat(kTransparentDepthPrepassEnable) > 0.0f) && ((SurfaceType)material.GetFloat(kSurfaceType) == SurfaceType.Transparent);
if (depthWriteEnable)
{
material.SetShaderPassEnabled(HDShaderPassNames.s_TransparentDepthPrePassStr, true);
material.SetShaderPassEnabled(HDShaderPassNames.s_TransparentDepthPrepassStr, true);
material.SetShaderPassEnabled(HDShaderPassNames.s_TransparentDepthPrePassStr, false);
material.SetShaderPassEnabled(HDShaderPassNames.s_TransparentDepthPrepassStr, false);
}
}

if (depthWriteEnable)
{
material.SetShaderPassEnabled(HDShaderPassNames.s_TransparentDepthPostPassStr, true);
material.SetShaderPassEnabled(HDShaderPassNames.s_TransparentDepthPostpassStr, true);
material.SetShaderPassEnabled(HDShaderPassNames.s_TransparentDepthPostPassStr, false);
material.SetShaderPassEnabled(HDShaderPassNames.s_TransparentDepthPostpassStr, false);
}
}

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDCustomSamplerId.cs


ForwardPassName,
ForwardTransparentDepthPrepass,
RenderForwardError,
TransparentDepthPostPass,
TransparentDepthPostpass,
ObjectsVelocity,
CameraVelocity,
GaussianPyramidColor,

18
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs


ShaderPassName[] m_DepthOnlyAndDepthForwardOnlyPassNames = { HDShaderPassNames.s_DepthForwardOnlyName, HDShaderPassNames.s_DepthOnlyName };
ShaderPassName[] m_DepthForwardOnlyPassNames = { HDShaderPassNames.s_DepthForwardOnlyName };
ShaderPassName[] m_DepthOnlyPassNames = { HDShaderPassNames.s_DepthOnlyName };
ShaderPassName[] m_TransparentDepthPrePassNames = { HDShaderPassNames.s_TransparentDepthPrePassName };
ShaderPassName[] m_TransparentDepthPostPassNames = { HDShaderPassNames.s_TransparentDepthPostPassName };
ShaderPassName[] m_TransparentDepthPrepassNames = { HDShaderPassNames.s_TransparentDepthPrepassName };
ShaderPassName[] m_TransparentDepthPostpassNames = { HDShaderPassNames.s_TransparentDepthPostpassName };
ShaderPassName[] m_ForwardErrorPassNames = { HDShaderPassNames.s_AlwaysName, HDShaderPassNames.s_ForwardBaseName, HDShaderPassNames.s_DeferredName, HDShaderPassNames.s_PrepassBaseName, HDShaderPassNames.s_VertexName, HDShaderPassNames.s_VertexLMRGBMName, HDShaderPassNames.s_VertexLMName };
ShaderPassName[] m_SinglePassName = new ShaderPassName[1];

RenderForwardError(m_CullResults, camera, renderContext, cmd, ForwardPass.Transparent);
// Fill depth buffer to reduce artifact for transparent object during postprocess
RenderTransparentDepthPostPass(m_CullResults, camera, renderContext, cmd, ForwardPass.Transparent);
RenderTransparentDepthPostpass(m_CullResults, camera, renderContext, cmd, ForwardPass.Transparent);
PushFullScreenDebugTexture(cmd, m_CameraColorBuffer, camera, renderContext, FullScreenDebugMode.NanTracker);

}
}
if (m_FrameSettings.enableTransparentPrePass)
if (m_FrameSettings.enableTransparentPrepass)
RenderTransparentRenderList(cull, camera, renderContext, cmd, m_TransparentDepthPrePassNames);
RenderTransparentRenderList(cull, camera, renderContext, cmd, m_TransparentDepthPrepassNames);
}
}
}

}
}
void RenderTransparentDepthPostPass(CullResults cullResults, Camera camera, ScriptableRenderContext renderContext, CommandBuffer cmd, ForwardPass pass)
void RenderTransparentDepthPostpass(CullResults cullResults, Camera camera, ScriptableRenderContext renderContext, CommandBuffer cmd, ForwardPass pass)
if (!m_FrameSettings.enableTransparentPostPass)
if (!m_FrameSettings.enableTransparentPostpass)
using (new ProfilingSample(cmd, "Render Transparent Depth Post ", GetSampler(CustomSamplerId.TransparentDepthPostPass)))
using (new ProfilingSample(cmd, "Render Transparent Depth Post ", GetSampler(CustomSamplerId.TransparentDepthPostpass)))
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, m_TransparentDepthPostPassNames);
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, m_TransparentDepthPostpassNames);
}
}

8
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDStringConstants.cs


public static readonly string s_SRPDefaultUnlitStr = "SRPDefaultUnlit";
public static readonly string s_MotionVectorsStr = "MotionVectors";
public static readonly string s_DistortionVectorsStr = "DistortionVectors";
public static readonly string s_TransparentDepthPrePassStr = "TransparentDepthPrepass";
public static readonly string s_TransparentDepthPrepassStr = "TransparentDepthPrepass";
public static readonly string s_TransparentDepthPostPassStr = "TransparentDepthPostPass";
public static readonly string s_TransparentDepthPostpassStr = "TransparentDepthPostpass";
public static readonly string s_MetaStr = "Meta";
public static readonly string s_ShadowCasterStr = "ShadowCaster";

public static readonly ShaderPassName s_SRPDefaultUnlitName = new ShaderPassName(s_SRPDefaultUnlitStr);
public static readonly ShaderPassName s_MotionVectorsName = new ShaderPassName(s_MotionVectorsStr);
public static readonly ShaderPassName s_DistortionVectorsName = new ShaderPassName(s_DistortionVectorsStr);
public static readonly ShaderPassName s_TransparentDepthPrePassName = new ShaderPassName(s_TransparentDepthPrePassStr);
public static readonly ShaderPassName s_TransparentDepthPrepassName = new ShaderPassName(s_TransparentDepthPrepassStr);
public static readonly ShaderPassName s_TransparentDepthPostPassName = new ShaderPassName(s_TransparentDepthPostPassStr);
public static readonly ShaderPassName s_TransparentDepthPostpassName = new ShaderPassName(s_TransparentDepthPostpassStr);
// Legacy name
public static readonly ShaderPassName s_AlwaysName = new ShaderPassName("Always");

4
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.shader


Pass
{
Name "TransparentDepthPostPass"
Tags { "LightMode" = "TransparentDepthPostPass" }
Name "TransparentDepthPostpass"
Tags { "LightMode" = "TransparentDepthPostpass" }
Cull[_CullMode]
ZWrite On

4
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/LitTessellation.shader


Pass
{
Name "TransparentDepthPostPass"
Tags { "LightMode" = "TransparentDepthPostPass" }
Name "TransparentDepthPostpass"
Tags { "LightMode" = "TransparentDepthPostpass" }
Cull[_CullMode]
ZWrite On

18
ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipeline/FrameSettings.cs


public static string kEnableSSSAndTransmission = "Enable SSS and Transmission";
public static string kForwardOnly = "Forward Only";
public static string kDeferredDepthPrePass = "Deferred Depth Prepass";
public static string kDeferredDepthPrepass = "Deferred Depth Prepass";
public static string kDeferredDepthPrepassATestOnly = "Deferred Depth Prepass ATest Only";
public static string KEnableTransparentPrepass = "Enable Transparent Prepass";

public bool enableDepthPrepassWithDeferredRendering = false;
public bool enableAlphaTestOnlyInDeferredPrepass = false;
public bool enableTransparentPrePass = true;
public bool enableTransparentPrepass = true;
public bool enableTransparentPostPass = true;
public bool enableTransparentPostpass = true;
public bool enableDistortion = true;
public bool enablePostprocess = true;

frameSettings.enableDepthPrepassWithDeferredRendering = this.enableDepthPrepassWithDeferredRendering;
frameSettings.enableAlphaTestOnlyInDeferredPrepass = this.enableAlphaTestOnlyInDeferredPrepass;
frameSettings.enableTransparentPrePass = this.enableTransparentPrePass;
frameSettings.enableTransparentPrepass = this.enableTransparentPrepass;
frameSettings.enableTransparentPostPass = this.enableTransparentPostPass;
frameSettings.enableTransparentPostpass = this.enableTransparentPostpass;
frameSettings.enableDistortion = this.enableDistortion;
frameSettings.enablePostprocess = this.enablePostprocess;

aggregate.enableDepthPrepassWithDeferredRendering = frameSettings.enableDepthPrepassWithDeferredRendering;
aggregate.enableAlphaTestOnlyInDeferredPrepass = frameSettings.enableAlphaTestOnlyInDeferredPrepass;
aggregate.enableTransparentPrePass = frameSettings.enableTransparentPrePass;
aggregate.enableTransparentPrepass = frameSettings.enableTransparentPrepass;
aggregate.enableTransparentPostPass = frameSettings.enableTransparentPostPass;
aggregate.enableTransparentPostpass = frameSettings.enableTransparentPostpass;
aggregate.enableDistortion = camera.cameraType == CameraType.Reflection ? false : frameSettings.enableDistortion;
// Planar and real time cubemap doesn't need post process and render in FP16

DebugMenuManager.instance.AddDebugItem<bool>(menuName, kDeferredDepthPrepassATestOnly, () => frameSettings.enableDepthPrepassWithDeferredRendering, (value) => frameSettings.enableDepthPrepassWithDeferredRendering = (bool)value);
DebugMenuManager.instance.AddDebugItem<bool>(menuName, KEnableTransparentPrepass, () => frameSettings.enableAlphaTestOnlyInDeferredPrepass, (value) => frameSettings.enableAlphaTestOnlyInDeferredPrepass = (bool)value);
DebugMenuManager.instance.AddDebugItem<bool>(menuName, KEnableTransparentPrepass, () => frameSettings.enableTransparentPrePass, (value) => frameSettings.enableTransparentPrePass = (bool)value);
DebugMenuManager.instance.AddDebugItem<bool>(menuName, KEnableTransparentPrepass, () => frameSettings.enableTransparentPrepass, (value) => frameSettings.enableTransparentPrepass = (bool)value);
DebugMenuManager.instance.AddDebugItem<bool>(menuName, kEnableTransparentPostpass, () => frameSettings.enableTransparentPostPass, (value) => frameSettings.enableTransparentPostPass = (bool)value);
DebugMenuManager.instance.AddDebugItem<bool>(menuName, kEnableTransparentPostpass, () => frameSettings.enableTransparentPostpass, (value) => frameSettings.enableTransparentPostpass = (bool)value);
DebugMenuManager.instance.AddDebugItem<bool>(menuName, kEnableDistortion, () => frameSettings.enableDistortion, (value) => frameSettings.enableDistortion = (bool)value);
DebugMenuManager.instance.AddDebugItem<bool>(menuName, kEnablePostprocess, () => frameSettings.enablePostprocess, (value) => frameSettings.enablePostprocess = (bool)value);

4
ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipeline.cs


private ShadowSliceData[] m_ShadowSlices = new ShadowSliceData[kMaxCascades];
// Pipeline pass names
private static readonly ShaderPassName m_DepthPrePass = new ShaderPassName("DepthOnly");
private static readonly ShaderPassName m_DepthPrepass = new ShaderPassName("DepthOnly");
private static readonly ShaderPassName m_LitPassName = new ShaderPassName("LightweightForward");
private static readonly ShaderPassName m_UnlitPassName = new ShaderPassName("SRPDefaultUnlit"); // Renders all shaders without a lightmode tag

context.ExecuteCommandBuffer(cmd);
CommandBufferPool.Release(cmd);
var opaqueDrawSettings = new DrawRendererSettings(m_CurrCamera, m_DepthPrePass);
var opaqueDrawSettings = new DrawRendererSettings(m_CurrCamera, m_DepthPrepass);
opaqueDrawSettings.sorting.flags = SortFlags.CommonOpaque;
var opaqueFilterSettings = new FilterRenderersSettings(true)

正在加载...
取消
保存