directionalLight.castShadow not working

Why am I getting this error when I change directionalLight.castShadow = true?

THREE.WebGLProgram: Shader Error 0 - VALIDATE_STATUS false


var directionalLight= new THREE.DirectionalLight(0xffffff,.2);
  // directionalLight.castShadow = true


You’re most likely using some custom material (or a mix of them) that does not support light shadows properly - but it’s hard to say without knowing more details about the project / dependencies you’re using.

I am using MeshStandardMaterial. I have applied some properties such as roughness and metalness and has an envMap

And there are absolutely no other dependencies installed or custom shader materials used in the app, besides three ?

Could you show the code of how you create the material?

function setMaterials(model) {
  model.traverse((mesh) => {
      mesh.castShadow = true
      mesh.recieveShadow = true
    if (!mesh.isMesh) return;
     material = mesh.material
     material.opacity = material?.userData?.opacity;
     material.emissive = material?.userData?.color;
     material.color = material?.userData?.color;
     material.specularColor = material?.userData?.specular;
     material.roughness = 1 - material?.userData?.shininess / 100;
     material.metalness = material?.userData?.shininess / 100;
     material.side = material?.userData?.side;
     material.transparent = material?.userData?.transparent;

  return model;
  1. recieveShadow :point_right: receiveShadow, but that won’t really fix the error.
  2. The second question was more important - is three the only dependency? Which version of three are you using and how are you including it in the project? Are you modifying / creating shaders in any way?
  3. Does the error disappear when you remove all the lines related to material in the code shared above?

Yes, there are no shaders added. I added three in a separate file. THREE.REVISION is
‘148’. The error only occurs when directionalLight.castShadow is true