More light culling fixes
This commit is contained in:
@@ -39,13 +39,13 @@ struct Frustum
|
||||
Plane basePlane;
|
||||
bool pointInside(float3 point)
|
||||
{
|
||||
if (basePlane.pointInside(point))
|
||||
if (!basePlane.pointInside(point))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for(int p = 0; p < 4; ++p)
|
||||
{
|
||||
if(sides[p].pointInside(point))
|
||||
if(!sides[p].pointInside(point))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -33,21 +33,29 @@ struct PointLight : ILightEnv
|
||||
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);
|
||||
}
|
||||
|
||||
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));
|
||||
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)
|
||||
{
|
||||
|
||||
if(insidePlane(frustum.sides[i], center_CS))
|
||||
{
|
||||
result++;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return result > 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user