fixing light culling

This commit is contained in:
Dynamitos
2024-02-23 08:31:21 +01:00
parent 15813ba612
commit a3f5ad2841
8 changed files with 37 additions and 24 deletions
+7 -7
View File
@@ -89,20 +89,20 @@ void cullLights(ComputeShaderInput in)
float fMinDepth = asfloat(uMinDepth);
float fMaxDepth = asfloat(uMaxDepth);
float minDepth = fMinDepth;
float maxDepth = fMaxDepth;
float nearClip = 0.1f;
float minDepthVS = clipToView(float4(0, 0, fMinDepth, 1)).z;
float maxDepthVS = clipToView(float4(0, 0, fMaxDepth, 1)).z;
float nearClipVS = clipToView(float4(0, 0, 0, 1)).z;
Plane minPlane = {float3(0, 0, -1), -minDepth};
Plane minPlane = {float3(0, 0, -1), -minDepthVS};
for ( uint i = in.groupIndex; i < pLightEnv.numPointLights; i += BLOCK_SIZE * BLOCK_SIZE )
{
PointLight light = pLightEnv.pointLights[i];
float3 lightClip = light.getClipPosition();
if(light.insideFrustum(groupFrustum, lightClip, nearClip, maxDepth))
float3 light_VS = light.getViewPosition();
if(light.insideFrustum(groupFrustum, light_VS, nearClipVS, maxDepthVS))
{
tAppendLight(i);
if(!light.insidePlane(minPlane, lightClip))
if(!light.insidePlane(minPlane, light_VS))
{
oAppendLight(i);
}