three-csm
three-csm copied to clipboard
Shader Error
Trying to use this library but happen to get this error:
ERROR: 0:1552: '[]' : array index out of range
ERROR: 0:1552: '[]' : array index out of range
ERROR: 0:1556: '[]' : array index out of range
ERROR: 0:1556: '[]' : array index out of range
Shader code on them lines:
1539:
1540: #endif
1541:
1542: if(linearDepth >= CSM_cascades[3].x && (linearDepth < CSM_cascades[3].y || 3 == CSM_CASCADES - 1)) RE_Direct( directLight, geometry, material, reflectedLight );
1543:
1544:
1545:
1546: directionalLight = directionalLights[ 4 ];
1547: getDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );
1548:
1549: #if defined( USE_SHADOWMAP ) && ( 4 < 5 )
1550:
1551: directionalLightShadow = directionalLightShadows[ 4 ];
1552: if(linearDepth >= CSM_cascades[4].x && linearDepth < CSM_cascades[4].y) directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ 4 ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ 4 ] ) : 1.0;
1553:
1554: #endif
1555:
1556: if(linearDepth >= CSM_cascades[4].x && (linearDepth < CSM_cascades[4].y || 4 == CSM_CASCADES - 1)) RE_Direct( directLight, geometry, material, reflectedLight );
1557:
1558:
1559:
1560: #endif
1561:
1562: #endif
Instantiating like this:
let csm = new CSM({
fov: 80,
maxFar: camera.far,
lightIntensity: 0.2,
cascades: 4,
shadowMapSize: 2048,
camera: camera,
parent: scene,
});
Any ideas?
Same here, @vHawk any ideas? 😅
I found that it could be caused by other light sources that also cast shadows, removing them resolves the issue.
It wasn't supposed to work with other light sources with shadows and I never tested such cases. It would be nice if it did actually work, but I don't think I'm going to implement it.