More light culling fixes
This commit is contained in:
@@ -99,7 +99,7 @@ void cullLights(ComputeShaderInput in)
|
|||||||
{
|
{
|
||||||
PointLight light = pLightEnv.pointLights[i];
|
PointLight light = pLightEnv.pointLights[i];
|
||||||
//TODO: why doesn't this check go through?
|
//TODO: why doesn't this check go through?
|
||||||
if(light.insideFrustum(groupFrustum, nearClipVS, maxDepthVS))
|
if(light.insideFrustum(groupFrustum, nearClipVS))
|
||||||
{
|
{
|
||||||
tAppendLight(i);
|
tAppendLight(i);
|
||||||
if(!light.insidePlane(minPlane))
|
if(!light.insidePlane(minPlane))
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ void taskMain(
|
|||||||
{
|
{
|
||||||
uint m = mesh.meshletOffset + i;
|
uint m = mesh.meshletOffset + i;
|
||||||
MeshletDescription meshlet = pScene.meshletInfos[m];
|
MeshletDescription meshlet = pScene.meshletInfos[m];
|
||||||
//if(meshlet.boundingBox.insideFrustum(localToClip, viewFrustum))
|
if(meshlet.boundingBox.insideFrustum(localToClip, viewFrustum))
|
||||||
{
|
{
|
||||||
uint index;
|
uint index;
|
||||||
InterlockedAdd(head, 1, index);
|
InterlockedAdd(head, 1, index);
|
||||||
|
|||||||
@@ -39,13 +39,13 @@ struct Frustum
|
|||||||
Plane basePlane;
|
Plane basePlane;
|
||||||
bool pointInside(float3 point)
|
bool pointInside(float3 point)
|
||||||
{
|
{
|
||||||
if (basePlane.pointInside(point))
|
if (!basePlane.pointInside(point))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for(int p = 0; p < 4; ++p)
|
for(int p = 0; p < 4; ++p)
|
||||||
{
|
{
|
||||||
if(sides[p].pointInside(point))
|
if(!sides[p].pointInside(point))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,21 +33,29 @@ struct PointLight : ILightEnv
|
|||||||
return illuminance * brdf.evaluate(params.tbn, params.viewDir_TS, normalize(lightDir_TS), colorRange.xyz);
|
return illuminance * brdf.evaluate(params.tbn, params.viewDir_TS, normalize(lightDir_TS), colorRange.xyz);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool insidePlane(Plane plane, float3 position_CS)
|
bool insidePlane(Plane plane, float3 center_CS)
|
||||||
{
|
{
|
||||||
|
float3 position_CS = center_CS + plane.n * colorRange.w;
|
||||||
return plane.pointInside(position_CS);
|
return plane.pointInside(position_CS);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool insideFrustum(Frustum frustum)
|
bool insideFrustum(Frustum frustum, float nearClipVS, float maxDepthVS)
|
||||||
{
|
{
|
||||||
bool result = true;
|
|
||||||
float4 clipPos = mul(pViewParams.projectionMatrix, mul(pViewParams.viewMatrix, position_WS));
|
float4 clipPos = mul(pViewParams.projectionMatrix, mul(pViewParams.viewMatrix, position_WS));
|
||||||
float3 position_CS = clipPos.xyz / clipPos.w;
|
float3 center_CS = clipPos.xyz / clipPos.w;
|
||||||
|
if(insidePlane(frustum.basePlane, center_CS))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
uint result = 0;
|
||||||
for(int i = 0; i < 4; ++i)
|
for(int i = 0; i < 4; ++i)
|
||||||
{
|
{
|
||||||
|
if(insidePlane(frustum.sides[i], center_CS))
|
||||||
|
{
|
||||||
|
result++;
|
||||||
}
|
}
|
||||||
return result;
|
}
|
||||||
|
return result > 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user