Fix a bad conversion to integer for negative values of the GRid COordinates

This commit is contained in:
samcake 2016-11-10 17:57:11 -08:00
parent 784a0540ed
commit 1d3fc1b647
2 changed files with 4 additions and 3 deletions

View file

@ -136,6 +136,7 @@ ivec3 frustumGrid_eyeToClusterPos(vec3 eyePos) {
vec3 volumePos = frustumGrid_eyeToVolume(eyePos, frustumGrid.eyeToGridProj, frustumGrid.rangeNear, frustumGrid.rangeFar);
vec3 gridPos = frustumGrid_volumeToGrid(volumePos, frustumGrid.dims);
if (gridPos.z >= frustumGrid.dims.z) {
@ -143,7 +144,7 @@ ivec3 frustumGrid_eyeToClusterPos(vec3 eyePos) {
}
return ivec3(gridPos);
return ivec3(floor(gridPos));
}
int frustumGrid_eyeToClusterDirH(vec3 eyeDir) {

View file

@ -38,9 +38,9 @@ void main(void) {
// From frag world pos find the cluster
vec4 clusterEyePos = frustumGrid_worldToEye(fragWorldPos);
ivec3 clusterPos = frustumGrid_eyeToClusterPos(clusterEyePos.xyz);
int clusterIndex = frustumGrid_clusterToIndex(clusterPos);
ivec3 cluster = clusterGrid_getCluster(frustumGrid_clusterToIndex(clusterPos));
ivec3 cluster = clusterGrid_getCluster(clusterIndex);
int numLights = cluster.x + cluster.y;
float numLightsScale = clamp(numLights * 0.05, 0.01, 1.0);