I have place several box object with same ‘Z’ position as (10) and different in ‘Y’ axis position. Similarly I have placed another some boxes with same ‘Z’ position as(-10) and different in ‘Y’ axis. I need to show the shadow of objects placed on Z=10 on the objects placed on Z=-10. How to do that?. I have attached the snapshot of my object for reference.
Well, shadow casting does not only depend on the object’s position but also on the position and direction of the light. So try to position a directional light in front of your objects with
position.z = 10 and set it’s target property to one of the respective objects.
Thanks for your reply @Mugen87. I can’t target a particular object. because sometime that object might be deleted. So How to set target?
The light has a target to begin with, an
Object3D that you can move around freely. Typically just add it to the scene as a sibling to the light, so that you can position it in the same coordinate system.
To the original question: All objects that cast shadows contribute to the same shadow map (if within the “view” of the shadow camera, which is aligned with the light soure), and all objects that receive shadows will receive from the same shadow map (if within “view”). Each light has a separate shadow map.
MisunderstandingI am not 100% sure I understand your question, but my interpretation is that you need to make sure that the first shadow-receiving object also casts shadow, and that the next object also receives shadow.
So what will be the position for light. is it same as other object (position.z=10) ?
You can try positioning the light at (someXOffset, someYOffset, 20) and set its target at (0,0,10).
Oh. Okay. I will try and let you know
Yes I already did that
No change @EliasHasle. I have tested with different color for the directional light. still no change in my design. My camera position and lookAt are (0,0,450) , is it may a factor ?
It is hard to tell what is wrong without seeing the code and, preferably, a live demo, as described in the pinned topic.
Did you follow the example from the docs?
No, I didn’t use spot light. I have used the directional light only
Yes I am using like this. But I have set receiveShadow for both front and back side objects.
Then I think you need to share more for anyone to be able to help you effectively.
I have set cast and receive shadow property for all objects