Getting issues with the shadow concept

Hello Three js Team,

I am working with the nice shadow feature provided by three js. But phasing problem to get the shadow in same cases.

  1. My first question is MeshBasicMaterial are those that does not respond to light so i think mesh made by them also does not produce any shadow. ?

  2. RawShaderMaterial in this material type my mesh is not responding to light please can anyone tell me why?

And also is there any replacement of RawShaderMaterial to make light sensitive objects

Thanks and Regards

Meshes with MesBasicMaterial can cast shadows.

I’m afraid I don’t see an attached TXT file in your post.

@Mugen87 i really appreciate your presence.

Please see this is my mesh

InstanceMesh.txt (86.5 KB)

and this is my light josn light.txt (862 Bytes)

Here when i have the light so my scene looks like this

Here i dont have any shadow at all

It seems you are using a mesh with an InstancedBufferGeometry. That means you have to use a custom shader. If you do not ensure that this shader uses shadow map related logic, it won’t support shadows.

Have you considered to use InstancedMesh instead?

Yes i am using the custom shader (vertex and fragment). One question here whats the difference if i use instancedMesh instead of mesh and also if i dont want to use so what login i have to use can you please explain me.


When using InstancedMesh you can use all built-in materials (e.g. MeshBasicMaterial) with instancing without customize shaders. Besides, using shadows will work automatically.

If you are not going to use InstancedMesh, you have to enhance your custom shaders by yourself with shadow mapping related code. This is an advanced topic and requires a good understanding of three.js's shaders.