trying to fix light culling still

This commit is contained in:
Dynamitos
2021-07-11 22:23:01 +02:00
parent 7f019a28b4
commit bc09920462
5 changed files with 22 additions and 8 deletions
+4 -1
View File
@@ -115,5 +115,8 @@
"-Wno-dev" "-Wno-dev"
], ],
"C_Cpp.default.cppStandard": "c++20", "C_Cpp.default.cppStandard": "c++20",
"C_Cpp.default.intelliSenseMode": "msvc-x64" "C_Cpp.default.intelliSenseMode": "msvc-x64",
"files.watcherExclude": {
"**/target": true
}
} }
+2 -2
View File
@@ -105,10 +105,10 @@ void cullLights(ComputeShaderInput in)
for ( uint i = in.groupIndex; i < numPointLights; i += BLOCK_SIZE * BLOCK_SIZE ) for ( uint i = in.groupIndex; i < numPointLights; i += BLOCK_SIZE * BLOCK_SIZE )
{ {
PointLight light = pointLights[i]; PointLight light = pointLights[i];
//if(light.insideFrustum(groupFrustum, nearClipVS, maxDepthVS)) if(light.insideFrustum(groupFrustum, nearClipVS, maxDepthVS))
{ {
tAppendLight(i); tAppendLight(i);
//if(!light.insidePlane(minPlane)) if(!light.insidePlane(minPlane))
{ {
oAppendLight(i); oAppendLight(i);
} }
+2 -2
View File
@@ -43,9 +43,9 @@ struct PointLight : ILightEnv
{ {
bool result = true; 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) for(int i = 0; i < 4 && result; ++i)
{ {
@@ -36,6 +36,15 @@ void LightCullingPass::beginFrame()
uniformUpdate.data = (uint8*)&viewParams; uniformUpdate.data = (uint8*)&viewParams;
viewParamsBuffer->updateContents(uniformUpdate); 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; BulkResourceData counterReset;
uint32 reset = 0; uint32 reset = 0;
counterReset.data = (uint8*)&reset; counterReset.data = (uint8*)&reset;
+5 -3
View File
@@ -19,14 +19,16 @@ Scene::Scene(Gfx::PGraphics graphics)
lightEnv.directionalLights[0].color = Vector4(1, 1, 1, 1); lightEnv.directionalLights[0].color = Vector4(1, 1, 1, 1);
lightEnv.directionalLights[0].direction = Vector4(1, 1, 0, 1); lightEnv.directionalLights[0].direction = Vector4(1, 1, 0, 1);
lightEnv.directionalLights[0].intensity = Vector4(1, 1, 1, 1); lightEnv.directionalLights[0].intensity = Vector4(1, 1, 1, 1);
lightEnv.numDirectionalLights = 1; lightEnv.numDirectionalLights = 0;
srand((unsigned int)time(NULL)); 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].colorRange = Vector4(frand(), frand(), frand(), frand() * 30);
lightEnv.pointLights[i].positionWS = Vector4(frand() * 100-50, frand(), frand() * 100-50, 1); 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() Scene::~Scene()