浏览代码

Various fix for debug modes:

- Debug Diffuse Lighting albedo override now works correctly for SSS materials.
- GBuffer debug now only shows GBuffer enabled material (no more forward only materials)
- Changed previous fix of PS4 crash in ShaderPassForward (it caused debug lighting for transparent objects to break).
/RenderPassXR_Sandbox
Julien Ignace 8 年前
当前提交
5a6b2e9c
共有 5 个文件被更改,包括 29 次插入18 次删除
  1. 5
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugDisplay.cs
  2. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugViewMaterialGBuffer.shader
  3. 15
      Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs
  4. 15
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl
  5. 10
      Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassForward.hlsl

5
Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugDisplay.cs


}
public bool IsDebugGBufferEnabled()
{
return m_DebugViewGBuffer != 0;
}
public bool IsDebugDisplayEnabled()
{
return (m_DebugViewEngine != 0 || m_DebugViewMaterial != 0 || m_DebugViewVarying != Attributes.DebugViewVarying.None || m_DebugViewProperties != Attributes.DebugViewProperties.None || m_DebugViewGBuffer != 0);

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugViewMaterialGBuffer.shader


Pass
{
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha // We will lerp only the values that are valid
Blend One Zero
HLSLPROGRAM
#pragma target 4.5

15
Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs


{
using (new Utilities.ProfilingSample("DisplayDebug ViewMaterial", cmd))
{
// Render Opaque forward
Utilities.SetRenderTarget(cmd, m_CameraColorBufferRT, m_CameraDepthStencilBufferRT, Utilities.kClearAll, Color.black);
RenderOpaqueRenderList(cull, hdCamera.camera, renderContext, cmd, "ForwardDisplayDebug", Utilities.kRendererConfigurationBakedLighting);
// Render GBuffer opaque
if (!m_Asset.renderingSettings.ShouldUseForwardRenderingOnly())
if(m_DebugDisplaySettings.materialDebugSettings.IsDebugGBufferEnabled() && !m_Asset.renderingSettings.ShouldUseForwardRenderingOnly())
{
using (new Utilities.ProfilingSample("DebugViewMaterialGBuffer", cmd))
{

}
else
{
Utilities.SetRenderTarget(cmd, m_CameraColorBufferRT, m_CameraDepthStencilBufferRT, Utilities.kClearAll, Color.black);
// Render Opaque forward
RenderOpaqueRenderList(cull, hdCamera.camera, renderContext, cmd, "ForwardDisplayDebug", Utilities.kRendererConfigurationBakedLighting);
// Render forward transparent
{
// Render forward transparent
RenderTransparentRenderList(cull, hdCamera.camera, renderContext, cmd, "ForwardDisplayDebug", Utilities.kRendererConfigurationBakedLighting);
}
}

15
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl


#endif
}
void ApplyDebugToBSDFData(inout BSDFData bsdfData)
void ApplyDebugToSurfaceData(inout SurfaceData surfaceData)
{
#ifdef DEBUG_DISPLAY
if (_DebugLightingMode == DEBUGLIGHTINGMODE_SPECULAR_LIGHTING)

if (overrideSmoothness)
{
bsdfData.perceptualRoughness = PerceptualSmoothnessToPerceptualRoughness(overrideSmoothnessValue);
bsdfData.roughness = PerceptualRoughnessToRoughness(bsdfData.perceptualRoughness);
surfaceData.perceptualSmoothness = overrideSmoothnessValue;
bsdfData.diffuseColor = _DebugLightingAlbedo.xyz;
surfaceData.baseColor = _DebugLightingAlbedo.xyz;
}
#endif
}

BSDFData ConvertSurfaceDataToBSDFData(SurfaceData surfaceData)
{
ApplyDebugToSurfaceData(surfaceData);
BSDFData bsdfData;
ZERO_INITIALIZE(BSDFData, bsdfData);

FillMaterialIdSSSData(surfaceData.baseColor, surfaceData.subsurfaceProfile, surfaceData.subsurfaceRadius, surfaceData.thickness, bsdfData);
}
ApplyDebugToBSDFData(bsdfData);
return bsdfData;
}

#if SHADEROPTIONS_PACK_GBUFFER_IN_U16
float4 outGBuffer0, outGBuffer1, outGBuffer2, outGBuffer3;
#endif
ApplyDebugToSurfaceData(surfaceData);
// RT0 - 8:8:8:8 sRGB
outGBuffer0 = float4(surfaceData.baseColor, surfaceData.specularOcclusion);

}
bakeDiffuseLighting = inGBuffer3.rgb;
ApplyDebugToBSDFData(bsdfData);
}
uint MaterialFeatureFlagsFromGBuffer(

10
Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassForward.hlsl


#if SHADERPASS != SHADERPASS_FORWARD
#if SHADERPASS != SHADERPASS_FORWARD
#error SHADERPASS_is_not_correctly_define
#endif

PreLightData preLightData = GetPreLightData(V, posInput, bsdfData);
outColor = float4(0.0, 0.0, 0.0, 0.0);
// We need to skip lighting when doing debug pass because the debug pass is done before lighting so some buffers may not be properly initialized potentially causing crashes on PS4.
#ifdef DEBUG_DISPLAY
if (_DebugLightingMode != DEBUGLIGHTINGMODE_NONE)
#endif
{
uint featureFlags = 0xFFFFFFFF;
float3 diffuseLighting;
float3 specularLighting;

outColor = float4(diffuseLighting + specularLighting, builtinData.opacity);
}
#ifdef _DEPTHOFFSET_ON
outputDepth = posInput.depthRaw;

正在加载...
取消
保存