trying to fix light culling still
This commit is contained in:
Vendored
+4
-1
@@ -115,5 +115,8 @@
|
||||
"-Wno-dev"
|
||||
],
|
||||
"C_Cpp.default.cppStandard": "c++20",
|
||||
"C_Cpp.default.intelliSenseMode": "msvc-x64"
|
||||
"C_Cpp.default.intelliSenseMode": "msvc-x64",
|
||||
"files.watcherExclude": {
|
||||
"**/target": true
|
||||
}
|
||||
}
|
||||
@@ -105,10 +105,10 @@ void cullLights(ComputeShaderInput in)
|
||||
for ( uint i = in.groupIndex; i < numPointLights; i += BLOCK_SIZE * BLOCK_SIZE )
|
||||
{
|
||||
PointLight light = pointLights[i];
|
||||
//if(light.insideFrustum(groupFrustum, nearClipVS, maxDepthVS))
|
||||
if(light.insideFrustum(groupFrustum, nearClipVS, maxDepthVS))
|
||||
{
|
||||
tAppendLight(i);
|
||||
//if(!light.insidePlane(minPlane))
|
||||
if(!light.insidePlane(minPlane))
|
||||
{
|
||||
oAppendLight(i);
|
||||
}
|
||||
|
||||
@@ -43,9 +43,9 @@ struct PointLight : ILightEnv
|
||||
{
|
||||
bool result = true;
|
||||
|
||||
//if(positionVS.z - range > zNear || positionVS.z + colorRange.w < zFar)
|
||||
if(positionVS.z - colorRange.w > zNear || positionVS.z + colorRange.w < zFar)
|
||||
{
|
||||
// result = false;
|
||||
result = false;
|
||||
}
|
||||
for(int i = 0; i < 4 && result; ++i)
|
||||
{
|
||||
|
||||
@@ -36,6 +36,15 @@ void LightCullingPass::beginFrame()
|
||||
uniformUpdate.data = (uint8*)&viewParams;
|
||||
viewParamsBuffer->updateContents(uniformUpdate);
|
||||
|
||||
LightEnv lightEnv = scene->getLightBuffer();
|
||||
for(uint32 i = 0; i < lightEnv.numPointLights; ++i)
|
||||
{
|
||||
lightEnv.pointLights[i].positionVS = lightEnv.pointLights[i].positionWS;
|
||||
}
|
||||
uniformUpdate.size = sizeof(PointLight) * MAX_POINT_LIGHTS;
|
||||
uniformUpdate.data = (uint8*)&lightEnv.pointLights;
|
||||
pointLightBuffer->updateContents(uniformUpdate);
|
||||
|
||||
BulkResourceData counterReset;
|
||||
uint32 reset = 0;
|
||||
counterReset.data = (uint8*)&reset;
|
||||
|
||||
@@ -19,14 +19,16 @@ Scene::Scene(Gfx::PGraphics graphics)
|
||||
lightEnv.directionalLights[0].color = Vector4(1, 1, 1, 1);
|
||||
lightEnv.directionalLights[0].direction = Vector4(1, 1, 0, 1);
|
||||
lightEnv.directionalLights[0].intensity = Vector4(1, 1, 1, 1);
|
||||
lightEnv.numDirectionalLights = 1;
|
||||
lightEnv.numDirectionalLights = 0;
|
||||
srand((unsigned int)time(NULL));
|
||||
for(uint32 i = 0; i < MAX_POINT_LIGHTS/2; ++i)
|
||||
for(uint32 i = 0; i < 1; ++i)
|
||||
{
|
||||
lightEnv.pointLights[i].colorRange = Vector4(frand(), frand(), frand(), frand() * 30);
|
||||
lightEnv.pointLights[i].positionWS = Vector4(frand() * 100-50, frand(), frand() * 100-50, 1);
|
||||
}
|
||||
lightEnv.numPointLights = MAX_POINT_LIGHTS/2;
|
||||
lightEnv.numPointLights = 1;
|
||||
lightEnv.pointLights[0].colorRange = Vector4(1, 0, 0, 100);
|
||||
lightEnv.pointLights[0].positionWS = Vector4(0, 10, 0, 1);
|
||||
}
|
||||
|
||||
Scene::~Scene()
|
||||
|
||||
Reference in New Issue
Block a user