浏览代码

Updated debug for screen space tracing

/feature-ScreenSpaceProjection
Frédéric Vauchelles 7 年前
当前提交
ae245c12
共有 5 个文件被更改,包括 51 次插入11 次删除
  1. 14
      ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/ScreenSpaceRaymarching.hlsl
  2. 7
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugDisplay.cs
  3. 39
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugFullScreen.shader
  4. 1
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/LightingDebug.cs
  5. 1
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs

14
ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/ScreenSpaceRaymarching.hlsl


#endif
};
float _SSTCrossingOffset = 1;
void CalculateRayTXS(ScreenSpaceRaymarchInput input, out float3 positionTXS, out float3 rayTXS)
{
float3 positionVS = input.startPositionVS;

ScreenSpaceRaymarchInput input,
out ScreenSpaceRayHit hit)
{
const float2 CROSS_OFFSET = float2(2, 2);
const float2 CROSS_OFFSET = float2(1, 1);
const int MAX_ITERATIONS = 32;
ZERO_INITIALIZE(ScreenSpaceRayHit, hit);

debug.startPositionSSX = uint(startPositionTXS.x);
debug.startPositionSSY = uint(startPositionTXS.y);
debug.startLinearDepth = 1 / startPositionTXS.z;
debug.levelMax = input.maxLevel;
debug.iterationMax = MAX_ITERATIONS;
#endif
bool hitSuccessful = true;

// Calculate planes to intersect for each cell
int2 cellPlanes = sign(rayTXS.xy);
float2 crossOffset = CROSS_OFFSET * cellPlanes;
float2 crossOffset = CROSS_OFFSET * cellPlanes * _SSTCrossingOffset;
cellPlanes = clamp(cellPlanes, 0, 1);
// Initialize loop

debug.positionTXS = positionTXS;
debug.hitLinearDepth = 1 / positionTXS.z;
debug.hitPositionSS = uint2(positionTXS.xy);
debug.iteration = iteration;
debug.level = currentLevel;
}
#endif

}
#ifdef DEBUG_DISPLAY
debug.level = maxUsedLevel;
debug.iteration = iteration;
debug.levelMax = maxUsedLevel;
debug.iterationMax = iteration;
debug.hitDistance = hit.distance;
if (input.writeStepDebug)

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


break;
}
}
list.Add(
new DebugUI.FloatField
{
displayName = "SST Crossing Offset",
getter = () => lightingDebugSettings.sstCrossingOffset,
setter = value => lightingDebugSettings.sstCrossingOffset = value,
});
list.Add(new DebugUI.EnumField { displayName = "Fullscreen Debug Mode", getter = () => (int)fullScreenDebugMode, setter = value => fullScreenDebugMode = (FullScreenDebugMode)value, enumNames = lightingFullScreenDebugStrings, enumValues = lightingFullScreenDebugValues, onValueChanged = RefreshLightingDebug });
switch (fullScreenDebugMode)

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


if (posInput.positionSS.y < 200)
{
// Draw debug statistics
uint depth = uint(debug.startLinearDepth * 1000);
if (SampleDebugFontNumber(posInput.positionSS - uint2(100, 10), depth))
const uint kStartDepthString[] = { 'S', 't', 'a', 'r', 't', ' ', 'D', 'e', 'p', 't', 'h', ':', ' ', 0u };
const uint kDepthString[] = { 'D', 'e', 'p', 't', 'h', ':', ' ', 0u };
const uint kLevelString[] = { 'L', 'e', 'v', 'e', 'l', ':', ' ', 0u };
const uint kIterationString[] = { 'I', 't', 'e', 'r', 'a', 't', 'i', 'o', 'n', ':', ' ', 0u };
uint2 p = uint2(70, 10);
bool isValid = false;
SAMPLE_DEBUG_STRING(posInput.positionSS - p, kStartDepthString, isValid);
if (isValid)
col = float4(1, 1, 1, 1);
if (SampleDebugFloatNumber(posInput.positionSS - p - uint2(100, 00), debug.startLinearDepth))
col = float4(1, 1, 1, 1);
p += uint2(00, 20);
isValid = false;
SAMPLE_DEBUG_STRING(posInput.positionSS - p, kDepthString, isValid);
if (isValid)
col = float4(1, 1, 1, 1);
if (SampleDebugFloatNumber(posInput.positionSS - p - uint2(100, 00), debug.hitLinearDepth))
col = float4(1, 1, 1, 1);
p += uint2(00, 20);
isValid = false;
SAMPLE_DEBUG_STRING(posInput.positionSS - p, kLevelString, isValid);
if (isValid)
col = float4(1, 1, 1, 1);
if (SampleDebugFontNumber(posInput.positionSS - p - uint2(100, 00), debug.level))
p += uint2(00, 20);
uint hitLinearDepth = uint(debug.hitLinearDepth * 1000);
if (SampleDebugFontNumber(posInput.positionSS - uint2(100, 30), hitLinearDepth))
isValid = false;
SAMPLE_DEBUG_STRING(posInput.positionSS - p, kIterationString, isValid);
if (isValid)
if (SampleDebugFontNumber(posInput.positionSS - p - uint2(100, 00), debug.iteration))
col = float4(1, 1, 1, 1);
p += uint2(00, 20);
}
return col;

1
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/LightingDebug.cs


}
public DebugScreenSpaceTracing debugScreenSpaceTracingMode = DebugScreenSpaceTracing.None;
public float sstCrossingOffset;
public DebugLightingMode debugLightingMode = DebugLightingMode.None;
public ShadowMapDebugMode shadowDebugMode = ShadowMapDebugMode.None;
public bool shadowDebugUseSelection = false;

1
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs


public void ApplyDebugDisplaySettings(HDCamera hdCamera, CommandBuffer cmd)
{
cmd.SetGlobalFloat("_SSTCrossingOffset", m_CurrentDebugDisplaySettings.lightingDebugSettings.sstCrossingOffset);
if (m_CurrentDebugDisplaySettings.IsDebugDisplayEnabled() ||
m_CurrentDebugDisplaySettings.fullScreenDebugMode != FullScreenDebugMode.None ||
m_CurrentDebugDisplaySettings.colorPickerDebugSettings.colorPickerMode != ColorPickerDebugMode.None)

正在加载...
取消
保存