GitHub
7 年前
当前提交
60b4f09e
共有 4 个文件被更改,包括 118 次插入 和 102 次删除
-
98ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightLoop/LightLoop.hlsl
-
13ScriptableRenderPipeline/HDRenderPipeline/Lighting/Lighting.hlsl
-
100ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightLoop/TilePass.hlsl
-
9ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightLoop/TilePass.hlsl.meta
|
|||
#ifndef UNITY_TILE_PASS_INCLUDED |
|||
#define UNITY_TILE_PASS_INCLUDED |
|||
|
|||
#ifdef LIGHTLOOP_TILE_PASS |
|||
|
|||
// Calculate the offset in global light index light for current light category |
|||
int GetTileOffset(PositionInputs posInput, uint lightCategory) |
|||
{ |
|||
uint2 tileIndex = posInput.tileCoord; |
|||
return (tileIndex.y + lightCategory * _NumTileFtplY) * _NumTileFtplX + tileIndex.x; |
|||
} |
|||
|
|||
void GetCountAndStartTile(PositionInputs posInput, uint lightCategory, out uint start, out uint lightCount) |
|||
{ |
|||
const int tileOffset = GetTileOffset(posInput, lightCategory); |
|||
|
|||
// The first entry inside a tile is the number of light for lightCategory (thus the +0) |
|||
lightCount = g_vLightListGlobal[DWORD_PER_TILE * tileOffset + 0] & 0xffff; |
|||
start = tileOffset; |
|||
} |
|||
|
|||
#ifdef USE_FPTL_LIGHTLIST |
|||
|
|||
uint GetTileSize() |
|||
{ |
|||
return TILE_SIZE_FPTL; |
|||
} |
|||
|
|||
void GetCountAndStart(PositionInputs posInput, uint lightCategory, out uint start, out uint lightCount) |
|||
{ |
|||
GetCountAndStartTile(posInput, lightCategory, start, lightCount); |
|||
} |
|||
|
|||
uint FetchIndex(uint tileOffset, uint lightIndex) |
|||
{ |
|||
const uint lightIndexPlusOne = lightIndex + 1; // Add +1 as first slot is reserved to store number of light |
|||
// Light index are store on 16bit |
|||
return (g_vLightListGlobal[DWORD_PER_TILE * tileOffset + (lightIndexPlusOne >> 1)] >> ((lightIndexPlusOne & 1) * DWORD_PER_TILE)) & 0xffff; |
|||
} |
|||
|
|||
#elif defined(USE_CLUSTERED_LIGHTLIST) |
|||
|
|||
#include "ClusteredUtils.hlsl" |
|||
|
|||
uint GetTileSize() |
|||
{ |
|||
return TILE_SIZE_CLUSTERED; |
|||
} |
|||
|
|||
void GetCountAndStartCluster(PositionInputs posInput, uint lightCategory, out uint start, out uint lightCount) |
|||
{ |
|||
uint2 tileIndex = posInput.tileCoord; |
|||
|
|||
float logBase = g_fClustBase; |
|||
if (g_isLogBaseBufferEnabled) |
|||
{ |
|||
logBase = g_logBaseBuffer[tileIndex.y * _NumTileClusteredX + tileIndex.x]; |
|||
} |
|||
|
|||
int clustIdx = SnapToClusterIdxFlex(posInput.linearDepth, logBase, g_isLogBaseBufferEnabled != 0); |
|||
|
|||
int nrClusters = (1 << g_iLog2NumClusters); |
|||
const int idx = ((lightCategory * nrClusters + clustIdx) * _NumTileClusteredY + tileIndex.y) * _NumTileClusteredX + tileIndex.x; |
|||
uint dataPair = g_vLayeredOffsetsBuffer[idx]; |
|||
start = dataPair & 0x7ffffff; |
|||
lightCount = (dataPair >> 27) & 31; |
|||
} |
|||
|
|||
void GetCountAndStart(PositionInputs posInput, uint lightCategory, out uint start, out uint lightCount) |
|||
{ |
|||
GetCountAndStartCluster(posInput, lightCategory, start, lightCount); |
|||
} |
|||
|
|||
uint FetchIndex(uint tileOffset, uint lightIndex) |
|||
{ |
|||
return g_vLightListGlobal[tileOffset + lightIndex]; |
|||
} |
|||
|
|||
#endif // USE_FPTL_LIGHTLIST |
|||
|
|||
#else |
|||
|
|||
uint GetTileSize() |
|||
{ |
|||
return 1; |
|||
} |
|||
|
|||
#endif // LIGHTLOOP_TILE_PASS |
|||
|
|||
LightData FetchLight(uint start, uint i) |
|||
{ |
|||
#ifdef LIGHTLOOP_TILE_PASS |
|||
int j = FetchIndex(start, i); |
|||
#else |
|||
int j = start + i; |
|||
#endif |
|||
return _LightDatas[j]; |
|||
} |
|||
|
|||
#endif // UNITY_TILE_PASS_INCLUDED |
|
|||
fileFormatVersion: 2 |
|||
guid: b1c455fce09a92b428a86a3d13e35509 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue