diff --git a/libraries/render-utils/src/LightClusterGrid.slh b/libraries/render-utils/src/LightClusterGrid.slh index 3eb3b53ccc..efb38f621e 100644 --- a/libraries/render-utils/src/LightClusterGrid.slh +++ b/libraries/render-utils/src/LightClusterGrid.slh @@ -69,8 +69,8 @@ ivec3 clusterGrid_getCluster(int index) { return ivec3(numPointLights, numSpotLights, contentOffset); } -int clusterGrid_getClusterLightId(int index, ivec2 cluster) { - int arrayElement = cluster.y + index; +int clusterGrid_getClusterLightId(int index, int offset) { + int arrayElement = offset + index; int element = _clusterGridContent[arrayElement]; return element; // int element = _clusterGridContent[arrayElement >> 1]; diff --git a/libraries/render-utils/src/lightClusters_drawClusterContent.slf b/libraries/render-utils/src/lightClusters_drawClusterContent.slf index 284e7cb9fe..3c9f7bad1c 100644 --- a/libraries/render-utils/src/lightClusters_drawClusterContent.slf +++ b/libraries/render-utils/src/lightClusters_drawClusterContent.slf @@ -44,7 +44,7 @@ void main(void) { int numLights = cluster.x + cluster.y; float numLightsScale = clamp(numLights * 0.05, 0.01, 1.0); - ivec2 clusterAddress = ivec2(numLights, cluster.z); + int clusterOffset = cluster.z; ivec3 dims = frustumGrid.dims.xyz; dims.z +=1; @@ -67,7 +67,7 @@ void main(void) { int numLightTouching = 0; for (int i = 0; i < numLights; i++) { // Need the light now - int theLightIndex = clusterGrid_getClusterLightId(i, clusterAddress); + int theLightIndex = clusterGrid_getClusterLightId(i, clusterOffset); Light light = getLight(theLightIndex); // Clip againgst the light volume and Make the Light vector going from fragment to light center in world space diff --git a/libraries/render-utils/src/local_lights_shading.slf b/libraries/render-utils/src/local_lights_shading.slf index b8e70f439d..1522239e7f 100644 --- a/libraries/render-utils/src/local_lights_shading.slf +++ b/libraries/render-utils/src/local_lights_shading.slf @@ -65,7 +65,6 @@ void main(void) { discard; } int lightClusterOffset = cluster.z; - ivec2 clusterAddress = ivec2(numLights, lightClusterOffset); ivec3 dims = frustumGrid.dims.xyz; if (clusterPos.x < 0 || clusterPos.x >= dims.x) { @@ -97,7 +96,7 @@ void main(void) { int numLightTouching = 0; for (int i = 0; i < cluster.x; i++) { // Need the light now - int theLightIndex = clusterGrid_getClusterLightId(i, clusterAddress); + int theLightIndex = clusterGrid_getClusterLightId(i, lightClusterOffset); Light light = getLight(theLightIndex); // Clip againgst the light volume and Make the Light vector going from fragment to light center in world space @@ -145,7 +144,7 @@ void main(void) { for (int i = cluster.x; i < numLights; i++) { // Need the light now - int theLightIndex = clusterGrid_getClusterLightId(i, clusterAddress); + int theLightIndex = clusterGrid_getClusterLightId(i, lightClusterOffset); Light light = getLight(theLightIndex); // Clip againgst the light volume and Make the Light vector going from fragment to light center in world space