|
@@ -80,15 +80,15 @@ technique TiledDeferredImageBasedLighting
|
|
|
|
|
|
|
|
GroupMemoryBarrierWithGroupSync();
|
|
GroupMemoryBarrierWithGroupSync();
|
|
|
|
|
|
|
|
- minTileZ = asfloat(sTileMinZ);
|
|
|
|
|
- maxTileZ = asfloat(sTileMaxZ);
|
|
|
|
|
|
|
+ minTileZ = -asfloat(sTileMinZ);
|
|
|
|
|
+ maxTileZ = -asfloat(sTileMaxZ);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void calcTileAABB(uint2 tileId, float viewZMin, float viewZMax, out float3 center, out float3 extent)
|
|
void calcTileAABB(uint2 tileId, float viewZMin, float viewZMax, out float3 center, out float3 extent)
|
|
|
{
|
|
{
|
|
|
uint2 pixelPos = tileId * TILE_SIZE;
|
|
uint2 pixelPos = tileId * TILE_SIZE;
|
|
|
|
|
|
|
|
- // Convert threat XY coordinates to NDC coordinates
|
|
|
|
|
|
|
+ // Convert thread XY coordinates to NDC coordinates
|
|
|
float2 uvTopLeft = (pixelPos + 0.5f) / gFramebufferSize;
|
|
float2 uvTopLeft = (pixelPos + 0.5f) / gFramebufferSize;
|
|
|
float2 uvBottomRight = (pixelPos + uint2(TILE_SIZE, TILE_SIZE) - 0.5f) / gFramebufferSize;
|
|
float2 uvBottomRight = (pixelPos + uint2(TILE_SIZE, TILE_SIZE) - 0.5f) / gFramebufferSize;
|
|
|
|
|
|
|
@@ -104,9 +104,8 @@ technique TiledDeferredImageBasedLighting
|
|
|
ndcMin.y *= flipY;
|
|
ndcMin.y *= flipY;
|
|
|
ndcMax.y *= flipY;
|
|
ndcMax.y *= flipY;
|
|
|
|
|
|
|
|
- // Camera is looking along negative z, therefore min in view space is max in NDC
|
|
|
|
|
- ndcMin.z = convertToNDCZ(viewZMax);
|
|
|
|
|
- ndcMax.z = convertToNDCZ(viewZMin);
|
|
|
|
|
|
|
+ ndcMin.z = convertToNDCZ(viewZMin);
|
|
|
|
|
+ ndcMax.z = convertToNDCZ(viewZMax);
|
|
|
|
|
|
|
|
float4 corner[5];
|
|
float4 corner[5];
|
|
|
// Far
|
|
// Far
|
|
@@ -165,7 +164,7 @@ technique TiledDeferredImageBasedLighting
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
float ao = gAmbientOcclusionTex.Load(int3(pixelPos.xy, 0));
|
|
float ao = gAmbientOcclusionTex.Load(int3(pixelPos.xy, 0));
|
|
|
- float4 ssr = gSSRTex.Load(int3(pixelPos.xy, 0));
|
|
|
|
|
|
|
+ float4 ssr = 0;//gSSRTex.Load(int3(pixelPos.xy, 0));
|
|
|
float3 imageBasedSpecular = getImageBasedSpecular(worldPosition, V, specR, surfaceData, ao, ssr, probeOffset, numProbes);
|
|
float3 imageBasedSpecular = getImageBasedSpecular(worldPosition, V, specR, surfaceData, ao, ssr, probeOffset, numProbes);
|
|
|
|
|
|
|
|
float4 totalLighting = existingColor;
|
|
float4 totalLighting = existingColor;
|
|
@@ -210,7 +209,7 @@ technique TiledDeferredImageBasedLighting
|
|
|
calcTileAABB(groupId.xy, minTileZ, maxTileZ, center, extent);
|
|
calcTileAABB(groupId.xy, minTileZ, maxTileZ, center, extent);
|
|
|
|
|
|
|
|
// Find probes overlapping the tile
|
|
// Find probes overlapping the tile
|
|
|
- for (uint i = 0; i < gNumProbes && i < MAX_LIGHTS; i += TILE_SIZE)
|
|
|
|
|
|
|
+ for (uint i = threadIndex; i < gNumProbes && i < MAX_LIGHTS; i += TILE_SIZE)
|
|
|
{
|
|
{
|
|
|
float4 probePosition = mul(gMatView, float4(gReflectionProbes[i].position, 1.0f));
|
|
float4 probePosition = mul(gMatView, float4(gReflectionProbes[i].position, 1.0f));
|
|
|
float probeRadius = gReflectionProbes[i].radius;
|
|
float probeRadius = gReflectionProbes[i].radius;
|
|
@@ -254,7 +253,7 @@ technique TiledDeferredImageBasedLighting
|
|
|
if (all(dispatchThreadId.xy < viewportMax))
|
|
if (all(dispatchThreadId.xy < viewportMax))
|
|
|
{
|
|
{
|
|
|
#if MSAA_COUNT > 1
|
|
#if MSAA_COUNT > 1
|
|
|
- float4 lighting = getLighting(pixelPos, 0, clipSpacePos.xy, surfaceData[0], 0, gNumProbes);
|
|
|
|
|
|
|
+ float4 lighting = getLighting(pixelPos, 0, clipSpacePos.xy, surfaceData[0], 0, sNumProbes);
|
|
|
writeBufferSample(pixelPos, 0, lighting);
|
|
writeBufferSample(pixelPos, 0, lighting);
|
|
|
|
|
|
|
|
bool doPerSampleShading = needsPerSampleShading(surfaceData);
|
|
bool doPerSampleShading = needsPerSampleShading(surfaceData);
|
|
@@ -263,7 +262,7 @@ technique TiledDeferredImageBasedLighting
|
|
|
[unroll]
|
|
[unroll]
|
|
|
for(uint i = 1; i < MSAA_COUNT; ++i)
|
|
for(uint i = 1; i < MSAA_COUNT; ++i)
|
|
|
{
|
|
{
|
|
|
- lighting = getLighting(pixelPos, i, clipSpacePos.xy, surfaceData[i], 0, gNumProbes);
|
|
|
|
|
|
|
+ lighting = getLighting(pixelPos, i, clipSpacePos.xy, surfaceData[i], 0, sNumProbes);
|
|
|
writeBufferSample(pixelPos, i, lighting);
|
|
writeBufferSample(pixelPos, i, lighting);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -275,7 +274,7 @@ technique TiledDeferredImageBasedLighting
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
#else
|
|
|
- float4 lighting = getLighting(pixelPos, 0, clipSpacePos.xy, surfaceData[0], 0, gNumProbes);
|
|
|
|
|
|
|
+ float4 lighting = getLighting(pixelPos, 0, clipSpacePos.xy, surfaceData[0], 0, sNumProbes);
|
|
|
gOutput[pixelPos] = lighting;
|
|
gOutput[pixelPos] = lighting;
|
|
|
#endif
|
|
#endif
|
|
|
}
|
|
}
|