|
|
|
|
|
|
float2 vec = r * float2(cos(phi), sin(phi)); |
|
|
|
|
|
|
|
// Compute the screen-space position and the squared distance (in mm) in the image plane. |
|
|
|
float2 position; float xy2; |
|
|
|
int2 position; float xy2; |
|
|
|
|
|
|
|
if (useTangentPlane) |
|
|
|
{ |
|
|
|
|
|
|
float2 positionSS = ComputeScreenSpacePosition(positionCS); |
|
|
|
|
|
|
|
position = positionSS * _ScreenSize.xy; |
|
|
|
position = (int2)(positionSS * _ScreenSize.xy); |
|
|
|
position = pixelCoord + vec * pixelsPerMm; |
|
|
|
position = (int2)(pixelCoord + vec * pixelsPerMm); |
|
|
|
xy2 = r * r; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
uint2 localCoord = DecodeMorton2D(mortonCode); |
|
|
|
uint2 tileAnchor = groupId * GROUP_SIZE_1D; |
|
|
|
uint2 pixelCoord = tileAnchor + localCoord; |
|
|
|
int2 cacheAnchor = tileAnchor - TEXTURE_CACHE_BORDER; |
|
|
|
int2 cacheAnchor = (int2)tileAnchor - TEXTURE_CACHE_BORDER; |
|
|
|
uint2 cacheCoord = localCoord + TEXTURE_CACHE_BORDER; |
|
|
|
float stencilRef = STENCILLIGHTINGUSAGE_SPLIT_LIGHTING; |
|
|
|
|
|
|
|
|
|
|
float centerDepth = 0; |
|
|
|
float4 cachedValue = float4(0, 0, 0, 0); |
|
|
|
|
|
|
|
bool passedStencilTest = StencilTest(pixelCoord, stencilRef); |
|
|
|
bool passedStencilTest = StencilTest((int2)pixelCoord, stencilRef); |
|
|
|
|
|
|
|
[branch] if (passedStencilTest) |
|
|
|
{ |
|
|
|
|
|
|
quadCoord.x = max(0, (int)(quadIndex - (halfCacheWidthInQuads - 1))); |
|
|
|
quadCoord.y = min(quadIndex, halfCacheWidthInQuads - 1); |
|
|
|
break; |
|
|
|
case 3: |
|
|
|
default: // 3 |
|
|
|
int2 cacheCoord2 = 2 * (startQuad + quadCoord) + int2(laneIndex & 1, (laneIndex >> 1) & 1); |
|
|
|
int2 pixelCoord2 = tileAnchor + cacheCoord2 - TEXTURE_CACHE_BORDER; |
|
|
|
uint2 cacheCoord2 = 2 * (startQuad + quadCoord) + uint2(laneIndex & 1, (laneIndex >> 1) & 1); |
|
|
|
int2 pixelCoord2 = (int2)(tileAnchor + cacheCoord2) - TEXTURE_CACHE_BORDER; |
|
|
|
float4 cachedValue2 = float4(0, 0, 0, 0); |
|
|
|
|
|
|
|
[branch] if (StencilTest(pixelCoord2, stencilRef)) |
|
|
|