浏览代码

Create common function for indexing into layered offset buffer

/main
Robert Srinivasiah 7 年前
当前提交
c310dc18
共有 3 个文件被更改,包括 14 次插入8 次删除
  1. 10
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/ClusteredUtils.hlsl
  2. 7
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoopDef.hlsl
  3. 5
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/lightlistbuild-clustered.compute

10
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/ClusteredUtils.hlsl


return (eyeOffset + (tileIndex.y * numTilesX) + tileIndex.x);
}
uint GenerateLayeredOffsetBufferIndex(uint lightCategory, uint2 tileIndex, uint clusterIndex, uint numTilesX, uint numTilesY, int numClusters, uint eyeIndex)
{
// Each eye is split into category, cluster, x, y
uint eyeOffset = eyeIndex * LIGHTCATEGORY_COUNT * numClusters * numTilesX * numTilesY;
int lightOffset = ((lightCategory * numClusters + clusterIndex) * numTilesY + tileIndex.y) * numTilesX + tileIndex.x;
return (eyeOffset + lightOffset);
}
#endif

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


void GetCountAndStartCluster(uint2 tileIndex, uint clusterIndex, uint lightCategory, out uint start, out uint lightCount)
{
int nrClusters = (1 << g_iLog2NumClusters);
int idx = ((lightCategory * nrClusters + clusterIndex) * _NumTileClusteredY + tileIndex.y) * _NumTileClusteredX + tileIndex.x;
idx += unity_StereoEyeIndex * LIGHTCATEGORY_COUNT * nrClusters * _NumTileClusteredX * _NumTileClusteredY;
const int idx = GenerateLayeredOffsetBufferIndex(lightCategory, tileIndex, clusterIndex, _NumTileClusteredX, _NumTileClusteredY, nrClusters, unity_StereoEyeIndex);
uint dataPair = g_vLayeredOffsetsBuffer[idx];
start = dataPair & 0x7ffffff;
lightCount = (dataPair >> 27) & 31;

5
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/lightlistbuild-clustered.compute


// XRTODO - DONE: Stereo-ize this initial 'offs' to jump into the correct half of g_LayeredOffs.
// The offsets are organized Category/Cluster/Row/Column.
// For stereo, we just add eyeIndex*LIGHTCATEGORY_COUNT*nrClusters*nrTilesX*nrTilesY
// TODO: Functionalize g_LayeredOffset indexing?
uint layeredOffsetBase = eyeIndex * LIGHTCATEGORY_COUNT * (nrClusters*nrTilesX*nrTilesY);
offs = layeredOffsetBase + (i*nrTilesX*nrTilesY) + (tileIDX.y*nrTilesX) + tileIDX.x;
offs = GenerateLayeredOffsetBufferIndex(0, tileIDX, i, nrTilesX, nrTilesY, nrClusters, eyeIndex);
for(int category=0; category<LIGHTCATEGORY_COUNT; category++)
{
int numLights = min(categoryListCount[category],31); // only allow 5 bits

正在加载...
取消
保存