浏览代码

Fix linear raymarching

/main
Frédéric Vauchelles 7 年前
当前提交
d8df9bad
共有 2 个文件被更改,包括 5 次插入12 次删除
  1. 14
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Reflection/ScreenSpaceTracing.hlsl
  2. 3
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.hlsl

14
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Reflection/ScreenSpaceTracing.hlsl


{
uint2 positionSS; // Position of the hit point (SS)
float2 positionNDC; // Position of the hit point (NDC)
float3 positionWS; // Position of the hit point (WS)
float linearDepth; // Linear depth of the hit point
#ifdef DEBUG_DISPLAY

raySS /= max(abs(raySS.x), abs(raySS.y));
raySS *= 1 << mipLevel;
// Offset by half a texel
positionSS += raySS * 0.5;
// Offset by a texel
positionSS += raySS * 1.0;
#ifdef DEBUG_DISPLAY
float3 debugIterationPositionSS = positionSS;

hit.linearDepth = 1 / positionSS.z;
hit.positionNDC = float2(positionSS.xy) / float2(bufferSize);
hit.positionSS = uint2(positionSS.xy);
float worldInterpolationFactor = (hit.linearDepth - rcp(startPositionSS.z)) / (rayEndDepth - rcp(startPositionSS.z));
hit.positionWS = input.rayOriginWS + input.rayDirWS * worldInterpolationFactor;
#ifdef DEBUG_DISPLAY
DebugComputeCommonOutput(input.rayDirWS, hitSuccessful, PROJECTIONMODEL_LINEAR, hit);

hit.positionNDC = hitPositionNDC;
hit.positionSS = hitPositionSS;
hit.linearDepth = hitLinearDepth;
hit.positionWS = hitPositionWS;
bool hitSuccessful = hitLinearDepth > 0; // Negative means that the hit is behind the camera

hit.linearDepth = 1 / positionSS.z;
hit.positionNDC = float2(positionSS.xy) / float2(bufferSize);
hit.positionSS = uint2(positionSS.xy);
float worldInterpolationFactor = (hit.linearDepth - rcp(startPositionSS.z)) / (rayEndDepth - rcp(startPositionSS.z));
hit.positionWS = input.rayOriginWS + input.rayDirWS * worldInterpolationFactor;
if (hit.linearDepth > (1 / invHiZDepth) + settingsRayDepthSuccessBias)
hitSuccessful = false;

input,
// Settings (linear)
SSRT_SETTING(RayLevel, SSRTID),
SSRT_SETTING(RayMaxIterations, SSRTID),
SSRT_SETTING(RayMaxLinearIterations, SSRTID),
uint(PROJECTIONMODEL_NONE),
PROJECTIONMODEL_NONE,
#endif
// Out
hit

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


// -------------------------------
if (projectionModel == PROJECTIONMODEL_PROXY)
{
// Perform a linear raymarch to detect close range collisions
ssRayInput.rayOriginWS = hit.positionWS;
ssRayInput.rayOriginWS = rayOriginWS;
ssRayInput.rayDirWS = rayDirWS;
#if DEBUG_DISPLAY
ssRayInput.debug = debug;

正在加载...
取消
保存