浏览代码

Update LuxMeter debugview

/main
Sebastien Lagarde 7 年前
当前提交
8820a5f9
共有 5 个文件被更改,包括 63 次插入37 次删除
  1. 3
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugDisplay.cs
  2. 22
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugDisplay.cs.hlsl
  3. 71
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugFullScreen.shader
  4. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs
  5. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoop.hlsl

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


public enum FullScreenDebugMode
{
None,
LuxMeterBuffer,
SSAO,
DeferredShadows,
PreRefractionColorPyramid,

// Rendering
MinRenderingFullScreenDebug,
HDRBuffer,
MotionVectors,
NanTracker,
MaxRenderingFullScreenDebug

22
ScriptableRenderPipeline/HDRenderPipeline/HDRP/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_REFRACTION_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_LUX_METER_BUFFER (2)
#define FULLSCREENDEBUGMODE_SSAO (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_HDRBUFFER (10)
#define FULLSCREENDEBUGMODE_MOTION_VECTORS (11)
#define FULLSCREENDEBUGMODE_NAN_TRACKER (12)
#define FULLSCREENDEBUGMODE_MAX_RENDERING_FULL_SCREEN_DEBUG (13)
#endif

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


{
Varyings output;
output.positionCS = GetFullScreenTriangleVertexPosition(input.vertexID);
output.texcoord = GetFullScreenTriangleTexCoord(input.vertexID);
output.texcoord = GetFullScreenTriangleTexCoord(input.vertexID);
return output;
}

}
// <<<
float4 DisplayPixelInformationAtMousePosition(Varyings input, float4 result, float4 mouseResult)
{
if (_MousePixelCoord.z >= 0.0 && _MousePixelCoord.z <= 1.0 && _MousePixelCoord.w >= 0 && _MousePixelCoord.w <= 1.0)
{
// Display message offset:
int displayTextOffsetX = 1.5 * DEBUG_FONT_TEXT_WIDTH;
#if UNITY_UV_STARTS_AT_TOP
int displayTextOffsetY = -DEBUG_FONT_TEXT_HEIGHT;
#else
int displayTextOffsetY = DEBUG_FONT_TEXT_HEIGHT;
#endif
uint2 displayUnormCoord = uint2(_MousePixelCoord.x + displayTextOffsetX, _MousePixelCoord.y + displayTextOffsetY);
uint2 unormCoord = input.positionCS.xy;
float3 fontColor = float3(1.0, 0.0, 0.0);
DrawFloat(mouseResult.x, fontColor, unormCoord, displayUnormCoord, result.rgb);
displayUnormCoord.x = _MousePixelCoord.x + displayTextOffsetX;
displayUnormCoord.y += displayTextOffsetY;
DrawFloat(mouseResult.y, fontColor, unormCoord, displayUnormCoord, result.rgb);
displayUnormCoord.x = _MousePixelCoord.x + displayTextOffsetX;
displayUnormCoord.y += displayTextOffsetY;
DrawFloat(mouseResult.z, fontColor, unormCoord, displayUnormCoord, result.rgb);
displayUnormCoord.x = _MousePixelCoord.x + displayTextOffsetX;
displayUnormCoord.y += displayTextOffsetY;
DrawFloat(mouseResult.w, fontColor, unormCoord, displayUnormCoord, result.rgb);
}
return result;
}
float4 GetResult(Varyings input, float2 coord)
{
// SSAO

float4 color = SAMPLE_TEXTURE2D(_DebugFullScreenTexture, sampler_DebugFullScreenTexture, coord);
return float4(color.rrr / (color.rrr + 1), 1.0);
}
if (_FullScreenDebugMode == FULLSCREENDEBUGMODE_HDRBUFFER)
{
float4 result = SAMPLE_TEXTURE2D(_DebugFullScreenTexture, sampler_DebugFullScreenTexture, coord);
float4 mouseResult = SAMPLE_TEXTURE2D(_DebugFullScreenTexture, sampler_DebugFullScreenTexture, _MousePixelCoord.zw);
return DisplayPixelInformationAtMousePosition(input, result, mouseResult);
}
if (_FullScreenDebugMode == FULLSCREENDEBUGMODE_LUX_METER_BUFFER)
{
float4 result = SAMPLE_TEXTURE2D(_DebugFullScreenTexture, sampler_DebugFullScreenTexture, coord);
result.rgb = GetColorCodeFunction(result.x, _DebugLuxMeterParam);
float4 mouseResult = SAMPLE_TEXTURE2D(_DebugFullScreenTexture, sampler_DebugFullScreenTexture, _MousePixelCoord.zw);
return DisplayPixelInformationAtMousePosition(input, result, mouseResult);
}
return float4(0.0, 0.0, 0.0, 0.0);
}

float4 result = GetResult(input, input.texcoord);
if (_MousePixelCoord.z >= 0.0 && _MousePixelCoord.z <= 1.0 && _MousePixelCoord.w >= 0 && _MousePixelCoord.w <= 1.0)
{
// Display message offset:
int displayTextOffsetX = 1.5 * DEBUG_FONT_TEXT_WIDTH;
#if UNITY_UV_STARTS_AT_TOP
int displayTextOffsetY = -DEBUG_FONT_TEXT_HEIGHT;
#else
int displayTextOffsetY = DEBUG_FONT_TEXT_HEIGHT;
#endif
uint2 displayUnormCoord = uint2(_MousePixelCoord.x + displayTextOffsetX, _MousePixelCoord.y + displayTextOffsetY);
uint2 unormCoord = input.positionCS.xy;
float4 mouseResult = GetResult(input, _MousePixelCoord.zw);
float3 fontColor = float3(1.0, 0.0, 0.0);
DrawFloat(mouseResult.x, fontColor, unormCoord, displayUnormCoord, result.rgb);
displayUnormCoord.x = _MousePixelCoord.x + displayTextOffsetX;
displayUnormCoord.y += displayTextOffsetY;
DrawFloat(mouseResult.y, fontColor, unormCoord, displayUnormCoord, result.rgb);
displayUnormCoord.x = _MousePixelCoord.x + displayTextOffsetX;
displayUnormCoord.y += displayTextOffsetY;
DrawFloat(mouseResult.z, fontColor, unormCoord, displayUnormCoord, result.rgb);
}
return result;
}

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs


RenderTransparentDepthPostpass(m_CullResults, camera, renderContext, cmd, ForwardPass.Transparent);
PushFullScreenDebugTexture(cmd, m_CameraColorBuffer, hdCamera, renderContext, FullScreenDebugMode.NanTracker);
PushFullScreenDebugTexture(cmd, m_CameraColorBuffer, hdCamera, renderContext, FullScreenDebugMode.HDRBuffer);
PushFullScreenDebugTexture(cmd, m_CameraColorBuffer, hdCamera, renderContext, FullScreenDebugMode.LuxMeterBuffer);
RenderGaussianPyramidColor(camera, cmd, renderContext, FullScreenDebugMode.FinalColorPyramid);

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoop.hlsl


{
specularLighting = float3(0.0, 0.0, 0.0); // Disable specular lighting
// Take the luminance
diffuseLighting = GetColorCodeFunction(Luminance(diffuseLighting).xxx, _DebugLuxMeterParam);
diffuseLighting = Luminance(diffuseLighting).xxx;
}
else if (_DebugLightingMode == DEBUGLIGHTINGMODE_VISUALIZE_CASCADE)
{

正在加载...
取消
保存