Light fixes to correct light culling. Now lights show up properly!

This commit is contained in:
TriVoxel
2025-05-05 14:27:24 -06:00
parent 5b5de92890
commit e569352f0b
3 changed files with 5 additions and 5 deletions

View File

@ -9,8 +9,7 @@
"texture_params": [],
"vertex_shader": "../include/pass.vert.glsl",
"fragment_shader": "clear_color_depth_pass.frag.glsl",
"color_attachments": ["_HDR"],
"clear_depth": 0.0
"color_attachments": ["_HDR"]
}
]
}

View File

@ -478,8 +478,8 @@ void main() {
#endif
#ifdef _Clusters
// compute linear depth for clustering directly from the reconstructed view-space pos:
float viewz = length(viewPos);
// compute depth for clustering: use the view-space Z component (linearized depth)
float viewz = viewPos.z;
int clusterI = getClusterI(texCoord, viewz, cameraPlane);
int numLights = int(texelFetch(clustersData, ivec2(clusterI, 0), 0).r * 255);

View File

@ -24,7 +24,8 @@ void main() {
// gl_Position = vec4((gl_VertexID % 2) * 4.0 - 1.0, (gl_VertexID / 2) * 4.0 - 1.0, 0.0, 1.0);
// For reverse-Z, the “far” plane lives at NDC z = 0
vec4 v = vec4(pos.x, pos.y, 0.0, 1.0);
vec4 ndcFar = vec4(pos.x, pos.y, 0.0, 1.0);
vec4 v = invVP * ndcFar;
v = vec4(invVP * v);
v.xyz /= v.w;
viewRay = v.xyz - eye;