浏览代码

displaye sampled color in HiZ for debug

/main
Frédéric Vauchelles 7 年前
当前提交
f994c6c3
共有 6 个文件被更改,包括 69 次插入8 次删除
  1. 39
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugDisplay.cs
  2. 9
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugDisplay.cs.hlsl
  3. 20
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugFullScreen.shader
  4. 1
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs
  5. 1
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDStringConstants.cs
  6. 7
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.hlsl

39
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugDisplay.cs


public uint endPositionSSY; // Proxy, HiZ, Linear
public float endHitWeight; // HiZ, Linear
// 1x32 bits (padding)
public float padding;
// 3x32 Lighting
public Vector3 lightingSampledColor; // All
// 2x32 bits (padding)
public Vector2 padding;
public Vector2 loopStartPositionSS { get { return new Vector2(loopStartPositionSSX, loopStartPositionSSY); } }
public Vector2 endPositionSS { get { return new Vector2(endPositionSSX, endPositionSSY); } }

public float debugOverlayRatio = 0.33f;
public FullScreenDebugMode fullScreenDebugMode = FullScreenDebugMode.None;
public float fullscreenDebugMip = 0.0f;
public bool showSSRayGrid = true;
public bool showSSRayDepthPyramid = true;
public bool showSSRayGrid = false;
public bool showSSRayDepthPyramid = false;
public bool showSSSampledColor = false;
public MaterialDebugSettings materialDebugSettings = new MaterialDebugSettings();
public LightingDebugSettings lightingDebugSettings = new LightingDebugSettings();

new DebugUI.Value { displayName = "End Linear Depth", getter = () => screenSpaceTracingDebugData.endLinearDepth },
new DebugUI.Value { displayName = "End Position", getter = () => screenSpaceTracingDebugData.endPositionSS },
}
},
new DebugUI.Container
{
displayName = "Lighting",
children =
{
new DebugUI.Value { displayName = "Sampled Color", getter = () => string.Format("({0:F6}, {1:F6}, {2:F6})", screenSpaceTracingDebugData.lightingSampledColor.x, screenSpaceTracingDebugData.lightingSampledColor.y, screenSpaceTracingDebugData.lightingSampledColor.z) },
}
}
);
break;

debugSettingsContainer.children.Add(
new DebugUI.EnumField { displayName = "Debug Mode", getter = GetDebugLightingSubMode, setter = SetScreenSpaceTracingDebugMode, enumNames = debugScreenSpaceTracingHiZStrings, enumValues = debugScreenSpaceTracingHiZValues, onValueChanged = RefreshScreenSpaceTracingDebug },
new DebugUI.BoolField { displayName = "Display Grid", getter = () => showSSRayGrid, setter = v => showSSRayGrid = v },
new DebugUI.BoolField { displayName = "Display Depth", getter = () => showSSRayDepthPyramid, setter = v => showSSRayDepthPyramid = v }
new DebugUI.BoolField { displayName = "Display Depth", getter = () => showSSRayDepthPyramid, setter = v => showSSRayDepthPyramid = v },
new DebugUI.BoolField { displayName = "Display Sampled Color", getter = () => showSSSampledColor, setter = v => showSSSampledColor = v }
);
settingsContainer.children.Add(
new DebugUI.Container

new DebugUI.Value { displayName = "Cell Size", getter = () => screenSpaceTracingDebugData.iterationCellSize },
new DebugUI.Value { displayName = "Intersection Kind", getter = () => k_HiZIntersectionKind[(int)screenSpaceTracingDebugData.iterationIntersectionKind] },
}
},
new DebugUI.Container
{
displayName = "Lighting",
children =
{
new DebugUI.Value { displayName = "Sampled Color", getter = () => string.Format("({0:F6}, {1:F6}, {2:F6})", screenSpaceTracingDebugData.lightingSampledColor.x, screenSpaceTracingDebugData.lightingSampledColor.y, screenSpaceTracingDebugData.lightingSampledColor.z) },
}
}
);
break;

new DebugUI.Value { displayName = "Mip Level", getter = () => screenSpaceTracingDebugData.iterationMipLevel },
new DebugUI.Value { displayName = "Cell Id", getter = () => screenSpaceTracingDebugData.iterationCellId },
new DebugUI.Value { displayName = "Cell Size", getter = () => screenSpaceTracingDebugData.iterationCellSize },
}
},
new DebugUI.Container
{
displayName = "Lighting",
children =
{
new DebugUI.Value { displayName = "Sampled Color", getter = () => string.Format("({0:F6}, {1:F6}, {2:F6})", screenSpaceTracingDebugData.lightingSampledColor.x, screenSpaceTracingDebugData.lightingSampledColor.y, screenSpaceTracingDebugData.lightingSampledColor.z) },
}
}
);

9
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugDisplay.cs.hlsl


uint endPositionSSX;
uint endPositionSSY;
float endHitWeight;
float padding;
float3 lightingSampledColor;
float2 padding;
};
//

{
return value.endHitWeight;
}
float GetPadding(ScreenSpaceTracingDebug value)
float3 GetLightingSampledColor(ScreenSpaceTracingDebug value)
{
return value.lightingSampledColor;
}
float2 GetPadding(ScreenSpaceTracingDebug value)
{
return value.padding;
}

20
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugFullScreen.shader


float _RequireToFlipInputTexture;
float _ShowGrid;
float _ShowDepthPyramidDebug;
float _ShowSSRaySampledColor;
CBUFFER_END
TEXTURE2D(_DebugFullScreenTexture);

const float w = clamp(1 - startPositionRingSDF - positionRingSDF, 0, 1);
col.rgb = col.rgb * w + float3(1, 1, 1) * (1 - w);
// Draw sampled color
if (_ShowSSRaySampledColor == 1)
{
const float4 rect = float4(endPositionSS + float2(10, 10), endPositionSS + float2(60, 60));
const float4 distToRects = float4(rect.zw - posInput.positionSS, posInput.positionSS - rect.xy);
if (all(distToRects > 0))
{
const float distToRect = min(min(distToRects.x, distToRects.y), min(distToRects.z, distToRects.w));
const float sdf = clamp(distToRect * 0.5, 0, 1);
col = float4(
lerp(float3(1, 1, 1), debug.lightingSampledColor, sdf),
1.0
);
color.a = 0;
}
}
col = float4(col.rgb * col.a + color.rgb, 1);
col = float4(col.rgb * col.a + color.rgb * color.a, 1);
return col;
}

1
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs


cmd.SetGlobalInt(HDShaderIDs._DebugStep, HDUtils.debugStep);
cmd.SetGlobalInt(HDShaderIDs._ShowGrid, m_CurrentDebugDisplaySettings.showSSRayGrid ? 1 : 0);
cmd.SetGlobalInt(HDShaderIDs._ShowDepthPyramidDebug, m_CurrentDebugDisplaySettings.showSSRayDepthPyramid ? 1 : 0);
cmd.SetGlobalInt(HDShaderIDs._ShowSSRaySampledColor, m_CurrentDebugDisplaySettings.showSSSampledColor ? 1 : 0);
// The DebugNeedsExposure test allows us to set a neutral value if exposure is not needed. This way we don't need to make various tests inside shaders but only in this function.
cmd.SetGlobalFloat(HDShaderIDs._DebugExposure, m_CurrentDebugDisplaySettings.DebugNeedsExposure() ? lightingDebugSettings.debugExposure : 0.0f);

1
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDStringConstants.cs


public static readonly int _DebugExposure = Shader.PropertyToID("_DebugExposure");
public static readonly int _DebugScreenSpaceTracingData = Shader.PropertyToID("_DebugScreenSpaceTracingData");
public static readonly int _ShowGrid = Shader.PropertyToID("_ShowGrid");
public static readonly int _ShowSSRaySampledColor = Shader.PropertyToID("_ShowSSRaySampledColor");
public static readonly int _ShowDepthPyramidDebug = Shader.PropertyToID("_ShowDepthPyramidDebug");
public static readonly int _DebugViewMaterial = Shader.PropertyToID("_DebugViewMaterial");

7
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.hlsl


lighting.specularReflected = F * preLD.rgb * weight;
#ifdef DEBUG_DISPLAY
if (debug)
{
ScreenSpaceTracingDebug debug = _DebugScreenSpaceTracingData[0];
debug.lightingSampledColor = preLD;
_DebugScreenSpaceTracingData[0] = debug;
}
if (_DebugLightingMode == debugMode
&& (_DebugLightingSubMode == DEBUGSCREENSPACETRACING_LINEAR_SAMPLED_COLOR
|| _DebugLightingSubMode == DEBUGSCREENSPACETRACING_HI_ZSAMPLED_COLOR))

正在加载...
取消
保存