Page 3 of 4
Assignation des lumières dans le cluster
Après avoir supprimées les lumières invisibles, ont cherche à répartir ces lumières au sein d'un cluster en fonction de leurs positions 3d de l'espace écrans
layout(local_size_x = X_GRID_SIZE, local_size_y = Y_GRID_SIZE, local_size_z = Z_GRID_SIZE) in;
#include "ClusteredStruct.glsl"
#include "ClusteredFrustum.glsl"
#include "ClusteredCollision.glsl"
uniform mat4 projView;
uniform mat4 proj;
uniform mat4 view;
void main()
{
uint xIndex = uint(gl_GlobalInvocationID.x);
uint yIndex = uint(gl_GlobalInvocationID.y);
uint zIndex = uint(gl_GlobalInvocationID.z);
// linear adresse inside the cluser grid
uint index = xIndex + (yIndex * GRID_SIZE.x) + (zIndex * GRID_SIZE.x * GRID_SIZE.y);
uint lightsOnScreen = atomicCounter(count);
int intersections = 0;
for(int i = 0; i < lightsOnScreen; i++)
{
bool colliding = SphereColliding(cubePlanes[index], NDCCoords[i].xzyw);
if(colliding)
{
int lightIndex = screenLights[i];
tileLights[index][intersections] = lightIndex;
intersections++;
}
}
lightIndexes[index] = intersections;
}