|
|
|
|
|
|
// these uniforms are only needed for when OPAQUES_ONLY is NOT defined |
|
|
|
// but there's a problem with our front-end compilation of compute shaders with multiple kernels causing it to error |
|
|
|
//#ifdef USE_CLUSTERED_LIGHTLIST |
|
|
|
float4x4 g_mInvScrProjection; |
|
|
|
float4x4 g_mInvScrProjection; // TODO: remove, unused in HDRP |
|
|
|
|
|
|
|
float g_fClustScale; |
|
|
|
float g_fClustBase; |
|
|
|
|
|
|
TEXTURE2D_ARRAY(_Env2DTextures); |
|
|
|
float4x4 _Env2DCaptureVP[MAX_ENV2D_LIGHT]; |
|
|
|
|
|
|
|
// XRTODO: Need to stereo-ize access |
|
|
|
TEXTURE2D(_DeferredShadowTexture); |
|
|
|
|
|
|
|
CBUFFER_START(UnityPerLightLoop) |
|
|
|
|
|
|
float logBase = g_fClustBase; |
|
|
|
if (g_isLogBaseBufferEnabled) |
|
|
|
{ |
|
|
|
// XRTODO: Stereo-ize access to g_logBaseBuffer |
|
|
|
logBase = g_logBaseBuffer[tileIndex.y * _NumTileClusteredX + tileIndex.x]; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
float logBase = g_fClustBase; |
|
|
|
if (g_isLogBaseBufferEnabled) |
|
|
|
{ |
|
|
|
logBase = g_logBaseBuffer[tileIndex.y * _NumTileClusteredX + tileIndex.x]; |
|
|
|
// XRTODO - DONE: Stereo-ize access to g_logBaseBuffer |
|
|
|
const uint eyeOffset = unity_StereoEyeIndex * _NumTileClusteredX * _NumTileClusteredY; |
|
|
|
logBase = g_logBaseBuffer[eyeOffset + (tileIndex.y * _NumTileClusteredX) + tileIndex.x]; |
|
|
|
} |
|
|
|
|
|
|
|
return SnapToClusterIdxFlex(linearDepth, logBase, g_isLogBaseBufferEnabled != 0); |
|
|
|
|
|
|
{ |
|
|
|
int nrClusters = (1 << g_iLog2NumClusters); |
|
|
|
const int idx = ((lightCategory * nrClusters + clusterIndex) * _NumTileClusteredY + tileIndex.y) * _NumTileClusteredX + tileIndex.x; |
|
|
|
int idx = ((lightCategory * nrClusters + clusterIndex) * _NumTileClusteredY + tileIndex.y) * _NumTileClusteredX + tileIndex.x; |
|
|
|
|
|
|
|
// XRTODO - DONE: Add the eye offset. Each eye is split into category, cluster, x, y |
|
|
|
idx += unity_StereoEyeIndex * LIGHTCATEGORY_COUNT * nrClusters * _NumTileClusteredX * _NumTileClusteredY; |
|
|
|
|
|
|
|
uint dataPair = g_vLayeredOffsetsBuffer[idx]; |
|
|
|
start = dataPair & 0x7ffffff; |
|
|
|
lightCount = (dataPair >> 27) & 31; |
|
|
|
|
|
|
{ |
|
|
|
// XRTODO - DONE: Will have to fix up GetLightClusterIndex and GetCountAndStartCluster |
|
|
|
// basicaly the log base and offset buffers are stereo ized. depth tex anywhere as well? |
|
|
|
|
|
|
|
// Note: XR depends on unity_StereoEyeIndex already being defined, |
|
|
|
// which means ShaderVariables.hlsl needs to be defined ahead of this! |
|
|
|
|
|
|
|
uint2 tileIndex = posInput.tileCoord; |
|
|
|
uint clusterIndex = GetLightClusterIndex(tileIndex, posInput.linearDepth); |
|
|
|
|
|
|
|