浏览代码

[ScreenSpaceTracing] fixed dirVS, added debugs

/feature-ScreenSpaceProjection
Frédéric Vauchelles 7 年前
当前提交
8a772b86
共有 4 个文件被更改,包括 958 次插入16 次删除
  1. 944
      SampleScenes/HDTest/PlanarReflectionTests.unity
  2. 16
      ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/ScreenSpaceRaymarching.hlsl
  3. 1
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/LightingDebug.cs
  4. 13
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/LightingDebug.cs.hlsl

944
SampleScenes/HDTest/PlanarReflectionTests.unity
文件差异内容过多而无法显示
查看文件

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


const int MAX_ITERATIONS = 32;
float4 startPositionCS = mul(projectionMatrix, float4(startPositionVS, 1));
float4 dirCS = mul(projectionMatrix, float4(dirVS, 0));
float4 dirCS = mul(projectionMatrix, float4(dirVS, 1));
#if UNITY_UV_STARTS_AT_TOP
// Our clip space is correct, but the NDC is flipped.
// Conceptually, it should be (positionNDC.y = 1.0 - positionNDC.y), but this is more efficient.

float2 startPositionNDC = (startPositionCS.xy * rcp(startPositionCS.w)) * 0.5 + 0.5;
// store linear depth in z
float3 dirNDC = float3(normalize((dirCS.xy * rcp(dirCS.w)) * 0.5 + 0.5), -dirVS.z /*RHS convention for VS*/);
float l = length(dirCS.xy);
float3 dirNDC = dirCS.xyz / l;
float2 invDirNDC = 1 / dirNDC.xy;
int2 cellPlanes = clamp(sign(dirNDC.xy), 0, 1);

int currentLevel = minLevel;
int2 cellCount = bufferSize >> minLevel;
int2 cellCount = bufferSize >> currentLevel;
int2 cellSize = int2(1 / float2(cellCount));
// store linear depth in z

hit.distance += rayOffsetLength;
--currentLevel;
}
cellCount = bufferSize >> currentLevel;
cellSize = int2(1 / float2(cellCount));
}
hit.linearDepth = positionTXS.z;

case DEBUGSCREENSPACETRACING_POSITION_NDC:
hit.debugOutput = float3(startPositionNDC.xy, 0);
break;
case DEBUGSCREENSPACETRACING_DIR_VS:
hit.debugOutput = dirVS * 0.5 + 0.5;
break;
hit.debugOutput = dirNDC;
hit.debugOutput = float3(dirNDC.xy * 0.5 + 0.5, dirNDC.z);
break;
case DEBUGSCREENSPACETRACING_HIT_DISTANCE:
hit.debugOutput = hit.distance;

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


{
None,
PositionNDC,
DirVS,
DirNDC,
HitDistance,
HitDepth,

13
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/LightingDebug.cs.hlsl


//
#define DEBUGSCREENSPACETRACING_NONE (0)
#define DEBUGSCREENSPACETRACING_POSITION_NDC (1)
#define DEBUGSCREENSPACETRACING_DIR_NDC (2)
#define DEBUGSCREENSPACETRACING_HIT_DISTANCE (3)
#define DEBUGSCREENSPACETRACING_HIT_DEPTH (4)
#define DEBUGSCREENSPACETRACING_HIT_SUCCESS (5)
#define DEBUGSCREENSPACETRACING_ITERATION_COUNT (6)
#define DEBUGSCREENSPACETRACING_MAX_USED_LEVEL (7)
#define DEBUGSCREENSPACETRACING_DIR_VS (2)
#define DEBUGSCREENSPACETRACING_DIR_NDC (3)
#define DEBUGSCREENSPACETRACING_HIT_DISTANCE (4)
#define DEBUGSCREENSPACETRACING_HIT_DEPTH (5)
#define DEBUGSCREENSPACETRACING_HIT_SUCCESS (6)
#define DEBUGSCREENSPACETRACING_ITERATION_COUNT (7)
#define DEBUGSCREENSPACETRACING_MAX_USED_LEVEL (8)
#endif
正在加载...
取消
保存