More light culling changes
This commit is contained in:
@@ -11,7 +11,7 @@ struct ComputeShaderInput
|
||||
};
|
||||
struct CullingParams
|
||||
{
|
||||
Texture2D depthTextureVS;
|
||||
Texture2D depthTexture;
|
||||
|
||||
globallycoherent RWStructuredBuffer<uint> oLightIndexCounter;
|
||||
globallycoherent RWStructuredBuffer<uint> tLightIndexCounter;
|
||||
@@ -67,7 +67,7 @@ void tAppendLight(uint lightIndex)
|
||||
void cullLights(ComputeShaderInput in)
|
||||
{
|
||||
int2 texCoord = int2(in.dispatchThreadID.xy);
|
||||
float fDepth = pCullingParams.depthTextureVS.Load(int3(texCoord, 0)).r;
|
||||
float fDepth = pCullingParams.depthTexture.Load(int3(texCoord, 0)).r;
|
||||
|
||||
uint uDepth = asuint(fDepth);
|
||||
if(in.groupIndex == 0)
|
||||
@@ -98,8 +98,9 @@ void cullLights(ComputeShaderInput in)
|
||||
for ( uint i = in.groupIndex; i < pLightEnv.numPointLights; i += BLOCK_SIZE * BLOCK_SIZE )
|
||||
{
|
||||
PointLight light = pLightEnv.pointLights[i];
|
||||
light.updatePosition();
|
||||
//TODO: why doesn't this check go through?
|
||||
if(light.insideFrustum(groupFrustum, nearClipVS))
|
||||
if(light.insideFrustum(groupFrustum, nearClipVS, maxDepthVS))
|
||||
{
|
||||
tAppendLight(i);
|
||||
if(!light.insidePlane(minPlane))
|
||||
|
||||
@@ -23,6 +23,7 @@ struct PointLight : ILightEnv
|
||||
{
|
||||
float4 position_WS;
|
||||
float4 colorRange;
|
||||
float4 position_CS;
|
||||
|
||||
float3 illuminate<B:IBRDF>(LightingParameter params, B brdf)
|
||||
{
|
||||
@@ -32,16 +33,19 @@ struct PointLight : ILightEnv
|
||||
float illuminance = max(1 - d / colorRange.w, 0);
|
||||
return illuminance * brdf.evaluate(params.tbn, params.viewDir_TS, normalize(lightDir_TS), colorRange.xyz);
|
||||
}
|
||||
|
||||
bool insidePlane(Plane plane, float3 center_CS)
|
||||
void updatePosition()
|
||||
{
|
||||
float3 position_CS = center_CS + plane.n * colorRange.w;
|
||||
return plane.pointInside(position_CS);
|
||||
position_CS = mul(pViewParams.projectionMatrix, mul(pViewParams.viewMatrix, position_WS));
|
||||
}
|
||||
|
||||
bool insidePlane(Plane plane)
|
||||
{
|
||||
float3 edge_CS = position_CS + plane.n * colorRange.w;
|
||||
return plane.pointInside(edge_CS);
|
||||
}
|
||||
|
||||
bool insideFrustum(Frustum frustum, float nearClipVS, float maxDepthVS)
|
||||
{
|
||||
float4 clipPos = mul(pViewParams.projectionMatrix, mul(pViewParams.viewMatrix, position_WS));
|
||||
float3 center_CS = clipPos.xyz / clipPos.w;
|
||||
if(insidePlane(frustum.basePlane, center_CS))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user