浏览代码

Add a helper function FetchIndexWithBoundsCheck()

/main
Evgenii Golubev 6 年前
当前提交
4f47b43c
共有 3 个文件被更改,包括 24 次插入90 次删除
  1. 16
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoopDef.hlsl
  2. 39
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumetrics/VolumeVoxelization.compute
  3. 59
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumetrics/VolumetricLighting.compute

16
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoopDef.hlsl


return 1;
}
uint FetchIndex(uint tileOffset, uint lightIndex)
uint FetchIndex(uint globalOffset, uint lightIndex)
return tileOffset + lightIndex;
return globalOffset + lightIndex;
uint FetchIndexWithBoundsCheck(uint start, uint count, uint i)
{
if (i < count)
{
return FetchIndex(start, i);
}
else
{
return UINT_MAX;
}
}
LightData FetchLight(uint start, uint i)
{

39
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumetrics/VolumeVoxelization.compute


uint volumeIndices[2];
// Fetch two initial indices from both clusters.
if (i < volumeCounts[0])
{
volumeIndices[0] = FetchIndex(volumeStarts[0], i);
}
else
{
volumeIndices[0] = UINT_MAX;
}
if (j < volumeCounts[1])
{
volumeIndices[1] = FetchIndex(volumeStarts[1], j);
}
else
{
volumeIndices[1] = UINT_MAX;
}
volumeIndices[0] = FetchIndexWithBoundsCheck(volumeStarts[0], volumeCounts[0], i);
volumeIndices[1] = FetchIndexWithBoundsCheck(volumeStarts[1], volumeCounts[1], j);
do
{

if (volumeIndex == volumeIndices[0])
{
i++;
if (i < volumeCounts[0])
{
volumeIndices[0] = FetchIndex(volumeStarts[0], i);
}
else
{
volumeIndices[0] = UINT_MAX;
}
volumeIndices[0] = FetchIndexWithBoundsCheck(volumeStarts[0], volumeCounts[0], i);
if (j < volumeCounts[1])
{
volumeIndices[1] = FetchIndex(volumeStarts[1], j);
}
else
{
volumeIndices[1] = UINT_MAX;
}
volumeIndices[1] = FetchIndexWithBoundsCheck(volumeStarts[1], volumeCounts[1], j);
}
} while (i < volumeCounts[0] || j < volumeCounts[1]);
}

59
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Volumetrics/VolumetricLighting.compute


uint lightIndices[2];
// Fetch two initial indices from both clusters.
if (i < lightCounts[0])
{
lightIndices[0] = FetchIndex(lightStarts[0], i);
}
else
{
lightIndices[0] = UINT_MAX;
}
if (j < lightCounts[1])
{
lightIndices[1] = FetchIndex(lightStarts[1], j);
}
else
{
lightIndices[1] = UINT_MAX;
}
lightIndices[0] = FetchIndexWithBoundsCheck(lightStarts[0], lightCounts[0], i);
lightIndices[1] = FetchIndexWithBoundsCheck(lightStarts[1], lightCounts[1], j);
// Process all punctual lights except for box lights (which are technically not even punctual).
do

if (lightIndex == lightIndices[0])
{
i++;
if (i < lightCounts[0])
{
lightIndices[0] = FetchIndex(lightStarts[0], i);
}
else
{
lightIndices[0] = UINT_MAX;
}
lightIndices[0] = FetchIndexWithBoundsCheck(lightStarts[0], lightCounts[0], i);
if (j < lightCounts[1])
{
lightIndices[1] = FetchIndex(lightStarts[1], j);
}
else
{
lightIndices[1] = UINT_MAX;
}
lightIndices[1] = FetchIndexWithBoundsCheck(lightStarts[1], lightCounts[1], j);
}
} while (i < lightCounts[0] || j < lightCounts[1]);

if (lightIndex == lightIndices[0])
{
i++;
if (i < lightCounts[0])
{
lightIndices[0] = FetchIndex(lightStarts[0], i);
}
else
{
lightIndices[0] = UINT_MAX;
}
lightIndices[0] = FetchIndexWithBoundsCheck(lightStarts[0], lightCounts[0], i);
if (j < lightCounts[1])
{
lightIndices[1] = FetchIndex(lightStarts[1], j);
}
else
{
lightIndices[1] = UINT_MAX;
}
lightIndices[1] = FetchIndexWithBoundsCheck(lightStarts[1], lightCounts[1], j);
}
#endif // USE_CLUSTERED_LIGHTLIST
}

正在加载...
取消
保存