浏览代码

Renamed PreTransparent to PreRefraction

/Yibing-Project-2
Frédéric Vauchelles 7 年前
当前提交
1e32285e
共有 11 个文件被更改,包括 43 次插入42 次删除
  1. 2
      ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugDisplay.cs
  2. 19
      ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugDisplay.cs.hlsl
  3. 2
      ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugFullScreen.shader
  4. 2
      ScriptableRenderPipeline/HDRenderPipeline/Debug/LightingDebugPanel.cs
  5. 34
      ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs
  6. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRenderQueue.cs
  7. 4
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Editor/BaseLitUI.cs
  8. 2
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Editor/LitUI.cs
  9. 2
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.shader
  10. 14
      ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/Editor/BaseUnlitUI.cs
  11. 2
      ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/Unlit.shader

2
ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugDisplay.cs


MinLightingFullScreenDebug,
SSAO,
DeferredShadows,
PreTransparentColorPyramid,
PreRefractionColorPyramid,
DepthPyramid,
FinalColorPyramid,
MaxLightingFullScreenDebug,

19
ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugDisplay.cs.hlsl


#define FULLSCREENDEBUGMODE_NONE (0)
#define FULLSCREENDEBUGMODE_MIN_LIGHTING_FULL_SCREEN_DEBUG (1)
#define FULLSCREENDEBUGMODE_SSAO (2)
#define FULLSCREENDEBUGMODE_DEFERRED_SHADOWS (3)
#define FULLSCREENDEBUGMODE_PRE_TRANSPARENT_COLOR_PYRAMID (4)
#define FULLSCREENDEBUGMODE_DEPTH_PYRAMID (5)
#define FULLSCREENDEBUGMODE_FINAL_COLOR_PYRAMID (6)
#define FULLSCREENDEBUGMODE_MAX_LIGHTING_FULL_SCREEN_DEBUG (7)
#define FULLSCREENDEBUGMODE_MIN_RENDERING_FULL_SCREEN_DEBUG (8)
#define FULLSCREENDEBUGMODE_MOTION_VECTORS (9)
#define FULLSCREENDEBUGMODE_NAN_TRACKER (10)
#define FULLSCREENDEBUGMODE_MAX_RENDERING_FULL_SCREEN_DEBUG (11)
#define FULLSCREENDEBUGMODE_SSAOBEFORE_FILTERING (3)
#define FULLSCREENDEBUGMODE_DEFERRED_SHADOWS (4)
#define FULLSCREENDEBUGMODE_PRE_REFRACTION_COLOR_PYRAMID (5)
#define FULLSCREENDEBUGMODE_DEPTH_PYRAMID (6)
#define FULLSCREENDEBUGMODE_FINAL_COLOR_PYRAMID (7)
#define FULLSCREENDEBUGMODE_MAX_LIGHTING_FULL_SCREEN_DEBUG (8)
#define FULLSCREENDEBUGMODE_MIN_RENDERING_FULL_SCREEN_DEBUG (9)
#define FULLSCREENDEBUGMODE_MOTION_VECTORS (10)
#define FULLSCREENDEBUGMODE_NAN_TRACKER (11)
#define FULLSCREENDEBUGMODE_MAX_RENDERING_FULL_SCREEN_DEBUG (12)
#endif

2
ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugFullScreen.shader


float4 color = SAMPLE_TEXTURE2D(_DebugFullScreenTexture, sampler_DebugFullScreenTexture, input.texcoord);
return float4(color.rgb, 0.0);
}
if (_FullScreenDebugMode == FULLSCREENDEBUGMODE_PRE_TRANSPARENT_COLOR_PYRAMID
if (_FullScreenDebugMode == FULLSCREENDEBUGMODE_PRE_REFRACTION_COLOR_PYRAMID
|| _FullScreenDebugMode == FULLSCREENDEBUGMODE_FINAL_COLOR_PYRAMID)
{
float4 color = SAMPLE_TEXTURE2D(_DebugFullScreenTexture, sampler_DebugFullScreenTexture, input.texcoord);

2
ScriptableRenderPipeline/HDRenderPipeline/Debug/LightingDebugPanel.cs


var fullScreenDebugModeValue = (FullScreenDebugMode)fullScreenDebugModeHandler.GetValue();
switch (fullScreenDebugModeValue)
{
case FullScreenDebugMode.PreTransparentColorPyramid:
case FullScreenDebugMode.PreRefractionColorPyramid:
case FullScreenDebugMode.FinalColorPyramid:
case FullScreenDebugMode.DepthPyramid:
{

34
ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs


enum ForwardPass
{
Opaque,
PreTransparent,
PreRefraction,
static readonly RenderQueueRange k_RenderQueue_PreTransparent = new RenderQueueRange { min = (int)HDRenderQueue.GeometryLast + 1, max = (int)HDRenderQueue.PreTransparent };
static readonly RenderQueueRange k_RenderQueue_Transparent = new RenderQueueRange { min = (int)HDRenderQueue.PreTransparent + 1, max = 5000 };
static readonly RenderQueueRange k_RenderQueue_PreRefraction = new RenderQueueRange { min = (int)HDRenderQueue.GeometryLast + 1, max = (int)HDRenderQueue.PreRefraction };
static readonly RenderQueueRange k_RenderQueue_Transparent = new RenderQueueRange { min = (int)HDRenderQueue.PreRefraction + 1, max = 5000 };
readonly HDRenderPipelineAsset m_Asset;

// Do a depth pre-pass for transparent objects that want it that will fill the depth buffer to reduce the overdraw (typical usage is hair rendering)
RenderTransparentDepthPrepass(m_CullResults, camera, renderContext, cmd);
// Render pre transparent objects
RenderForward(m_CullResults, camera, renderContext, cmd, ForwardPass.PreTransparent);
RenderForwardError(m_CullResults, camera, renderContext, cmd, ForwardPass.PreTransparent);
// Render pre refraction objects
RenderForward(m_CullResults, camera, renderContext, cmd, ForwardPass.PreRefraction);
RenderForwardError(m_CullResults, camera, renderContext, cmd, ForwardPass.PreRefraction);
RenderGaussianPyramidColor(camera, cmd, renderContext, FullScreenDebugMode.PreTransparentColorPyramid);
RenderGaussianPyramidColor(camera, cmd, renderContext, FullScreenDebugMode.PreRefractionColorPyramid);
// Render all type of transparent forward (unlit, lit, complex (hair...)) to keep the sorting between transparent objects.
RenderForward(m_CullResults, camera, renderContext, cmd, ForwardPass.Transparent);

RendererConfiguration rendererConfiguration = 0,
RenderStateBlock? stateBlock = null,
Material overrideMaterial = null,
bool preTransparentQueue = false)
bool preRefractionQueue = false)
rendererConfiguration, stateBlock, overrideMaterial, preTransparentQueue);
rendererConfiguration, stateBlock, overrideMaterial, preRefractionQueue);
}
void RenderTransparentRenderList(CullResults cull,

RendererConfiguration rendererConfiguration = 0,
RenderStateBlock? stateBlock = null,
Material overrideMaterial = null,
bool preTransparentQueue = false)
bool preRefractionQueue = false)
{
if (!m_CurrentDebugDisplaySettings.renderingDebugSettings.displayTransparentObjects)
return;

var filterSettings = new FilterRenderersSettings(true)
{
renderQueueRange = preTransparentQueue
? k_RenderQueue_PreTransparent
renderQueueRange = preRefractionQueue
? k_RenderQueue_PreRefraction
: k_RenderQueue_Transparent
};

cmd.ClearRenderTarget(false, true, Color.clear);
// Only transparent object can render distortion vectors
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, HDShaderPassNames.s_DistortionVectorsName, preTransparentQueue:true);
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, HDShaderPassNames.s_DistortionVectorsName, preRefractionQueue:true);
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, HDShaderPassNames.s_DistortionVectorsName);
}
}

}
else
{
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, m_ForwardAndForwardOnlyPassNames, HDUtils.k_RendererConfigurationBakedLighting, preTransparentQueue: pass == ForwardPass.PreTransparent);
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, m_ForwardAndForwardOnlyPassNames, HDUtils.k_RendererConfigurationBakedLighting, preRefractionQueue: pass == ForwardPass.PreRefraction);
}
}
}

using (new ProfilingSample(cmd,"Forward Transparent Depth Prepass"))
{
CoreUtils.SetRenderTarget(cmd, m_CameraDepthStencilBufferRT);
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, HDShaderPassNames.s_TransparentDepthPrepassName, preTransparentQueue: true);
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, HDShaderPassNames.s_TransparentDepthPrepassName, preTransparentQueue: false);
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, HDShaderPassNames.s_TransparentDepthPrepassName, preRefractionQueue: true);
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, HDShaderPassNames.s_TransparentDepthPrepassName);
}
}

else
{
RenderTransparentRenderList(cullResults, camera, renderContext, cmd, m_ForwardErrorPassNames, 0,
null, m_ErrorMaterial, pass == ForwardPass.PreTransparent);
null, m_ErrorMaterial, pass == ForwardPass.PreRefraction);
}
}
}

2
ScriptableRenderPipeline/HDRenderPipeline/HDRenderQueue.cs


Geometry = UnityEngine.Rendering.RenderQueue.Geometry,
AlphaTest = UnityEngine.Rendering.RenderQueue.AlphaTest,
GeometryLast = UnityEngine.Rendering.RenderQueue.GeometryLast,
PreTransparent = 2750,
PreRefraction = 2750,
Transparent = UnityEngine.Rendering.RenderQueue.Transparent,
Overlay = UnityEngine.Rendering.RenderQueue.Overlay
}

4
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Editor/BaseLitUI.cs


SetKeyword(material, "_TESSELLATION_PHONG", tessMode == TessellationMode.Phong);
}
var isPrePass = material.GetFloat(kTransparentPrepass) > 0.0;
SetKeyword(material, "_REFRACTION_ON", !isPrePass); // Refraction is not available for pre transparent (color buffer cannot be fetched)
var isPrePass = material.GetFloat(kPrePrefractionPass) > 0.0;
SetKeyword(material, "_REFRACTION_ON", !isPrePass); // Refraction is not available for pre refraction (color buffer cannot be fetched)
}
static public void SetupBaseLitMaterialPass(Material material)

2
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Editor/LitUI.cs


EditorGUILayout.LabelField(StylesBaseUnlit.TransparencyInputsText, EditorStyles.boldLabel);
++EditorGUI.indentLevel;
var isPrePass = material.GetFloat(kTransparentPrepass) > 0.0;
var isPrePass = material.GetFloat(kPrePrefractionPass) > 0.0;
if (refractionMode != null && !isPrePass)
{
m_MaterialEditor.ShaderProperty(refractionMode, Styles.refractionModeText);

2
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.shader


_ThicknessMultiplier("Thickness Multiplier", Float) = 1.0
_TransmittanceColor("Transmittance Color", Color) = (1.0, 1.0, 1.0)
_ATDistance("Transmittance Absorption Distance", Float) = 1.0
[ToggleOff] _PreTransparentPass("PreTransparentPass", Float) = 0.0
[ToggleOff] _PreRefractionPass("PreRefractionPass", Float) = 0.0
// Stencil state
[HideInInspector] _StencilRef("_StencilRef", Int) = 2 // StencilLightingUsage.RegularLighting (fixed at compile time)

14
ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/Editor/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 Transparent Pass", "Render in pre-transparent pass");
public static GUIContent transparentPrePassText = new GUIContent("Pre Refraction Pass", "Render objects before the refraction pass");
public static string advancedText = "Advanced Options";
}

protected const string kDistortionBlurRemapMin = "_DistortionBlurRemapMin";
protected MaterialProperty distortionBlurRemapMax = null;
protected const string kDistortionBlurRemapMax = "_DistortionBlurRemapMax";
protected MaterialProperty transparentPrepass = null;
protected const string kTransparentPrepass = "_PreTransparentPass";
protected MaterialProperty preRefractionPass = null;
protected const string kPrePrefractionPass = "_PreRefractionPass";
// See comment in LitProperties.hlsl
const string kEmissionColor = "_EmissionColor";

distortionBlurScale = FindProperty(kDistortionBlurScale, props, false);
distortionBlurRemapMin = FindProperty(kDistortionBlurRemapMin, props, false);
distortionBlurRemapMax = FindProperty(kDistortionBlurRemapMax, props, false);
transparentPrepass = FindProperty(kTransparentPrepass, props, false);
preRefractionPass = FindProperty(kPrePrefractionPass, props, false);
}
void SurfaceTypePopup()

{
BlendModePopup();
m_MaterialEditor.ShaderProperty(transparentPrepass, StylesBaseUnlit.transparentPrePassText);
m_MaterialEditor.ShaderProperty(preRefractionPass, StylesBaseUnlit.transparentPrePassText);
}
m_MaterialEditor.ShaderProperty(alphaCutoffEnable, StylesBaseUnlit.alphaCutoffEnableText);
if (alphaCutoffEnable.floatValue == 1.0f)

{
material.SetOverrideTag("RenderType", "Transparent");
material.SetInt("_ZWrite", 0);
var isPrePass = material.GetFloat(kTransparentPrepass) > 0.0f;
material.renderQueue = (int)(isPrePass ? HDRenderQueue.PreTransparent : HDRenderQueue.Transparent);
var isPrePass = material.GetFloat(kPrePrefractionPass) > 0.0f;
material.renderQueue = (int)(isPrePass ? HDRenderQueue.PreRefraction : HDRenderQueue.Transparent);
SetKeyword(material, "_BLENDMODE_LERP", BlendMode.Lerp == blendMode);
SetKeyword(material, "_BLENDMODE_ADD", BlendMode.Add == blendMode);

2
ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/Unlit.shader


_DistortionBlurRemapMax("DistortionBlurRemapMax", Float) = 1.0
// Transparency
[ToggleOff] _PreTransparentPass("PreTransparentPass", Float) = 0.0
[ToggleOff] _PreRefractionPass("PreRefractionPass", Float) = 0.0
[ToggleOff] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0
_AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5

正在加载...
取消
保存