three-csm icon indicating copy to clipboard operation
three-csm copied to clipboard

Shader Error

Open lucas-jones opened this issue 4 years ago • 3 comments

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?

lucas-jones avatar Feb 07 '21 17:02 lucas-jones

Same here, @vHawk any ideas? 😅

gonuit avatar Mar 14 '21 20:03 gonuit

I found that it could be caused by other light sources that also cast shadows, removing them resolves the issue.

gonuit avatar Mar 18 '21 20:03 gonuit

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.

StrandedKitty avatar Oct 23 '21 21:10 StrandedKitty