Skip to content

Commit

Permalink
More lighting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Duttenheim committed Nov 11, 2024
1 parent b0f8f9b commit b2ef026
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 72 deletions.
6 changes: 6 additions & 0 deletions code/render/clustering/clustercontext.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,16 @@ ClusterContext::Create(float ZNear, float ZFar, const CoreGraphics::WindowId win
{
CmdSetShaderProgram(cmdBuf, state.clusterGenerateProgram);

state.clusterDimensions[0] = Math::divandroundup(viewport.width(), ClusterSubdivsX);
state.clusterDimensions[1] = Math::divandroundup(viewport.height(), ClusterSubdivsY);
state.clusterDimensions[2] = ClusterSubdivsZ;

state.xResolution = viewport.width();
state.yResolution = viewport.height();
state.invXResolution = 1.0f / state.xResolution;
state.invYResolution = 1.0f / state.yResolution;
state.zInvScale = float(state.clusterDimensions[2]) / Math::log2(state.zDistribution);
state.zInvBias = -(float(state.clusterDimensions[2]) * Math::log2(state.zNear) / Math::log2(state.zDistribution));

// Run the job as series of 1024 clusters at a time
CmdDispatch(cmdBuf, Math::ceil((state.clusterDimensions[0] * state.clusterDimensions[1] * state.clusterDimensions[2]) / 64.0f), 1, 1);
Expand Down
40 changes: 37 additions & 3 deletions code/render/frame/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,18 @@
{
"name": "SunShadowDepth",
"stage": "PixelShaderRead"
},
{
"name": "ClusterLightIndexLists",
"stage": "PixelShaderRead"
},
{
"name": "ClusterFogIndexLists",
"stage": "PixelShaderRead"
},
{
"name": "ClusterDecalIndexLists",
"stage": "PixelShaderRead"
}
],

Expand Down Expand Up @@ -464,6 +476,26 @@
"_comment": "TODO: Move this to a separate pass later on",
"subpass_dependencies": [ "Skypass" ],
"attachments": [ "LightBuffer" ],

"resource_dependencies": [
{
"name": "SunShadowDepth",
"stage": "PixelShaderRead"
},
{
"name": "ClusterLightIndexLists",
"stage": "PixelShaderRead"
},
{
"name": "ClusterFogIndexLists",
"stage": "PixelShaderRead"
},
{
"name": "ClusterDecalIndexLists",
"stage": "PixelShaderRead"
}
],

"depth": "ZBuffer",
"ops": [
{
Expand Down Expand Up @@ -684,13 +716,15 @@
},

{
"blit": {
"copy": {
"name": "ColorBuffer Copy",
"from": {
"tex": "ColorBuffer"
"tex": "ColorBuffer",
"bits": "ColorBits"
},
"to": {
"tex": "SceneBuffer"
"tex": "SceneBuffer",
"bits": "ColorBits"
}
}
},
Expand Down
Loading

0 comments on commit b2ef026

Please sign in to comment.