- Home /
Cast two shadow from object in different layer on same plane
Hi all,
Here is my situation at the moment, beginning with Unity, I tried to search here and on the internet, and the doc but couldn't find what i'm looking for :
(I am using unity pro.)
I have two object A and B, each with a mesh and with "cast shadow" enable. Each object is in a different layer (let's say layerA for object A and layerB for object B). The problem I am encoutering is that I want to cast (with dynamic shadows) both object's shadow, on the same surface (let's say a wall.) (because I need to handle separatly the intensity and the color of shadows separatly)
The way I proceed is the following: I am using two directional lights, one culling the layerA, and the other culling the layerB. But it only display on the surface only one of the two shadows... (In fact, the same layer as the plane)
I think I know why it doesn't work, but I don't how if it's even possible to achieve what I'm looking for...
Any suggestions ? Thanks
PS: I set light mode to deferred rendering and not forwarding.
Answer by wip · Aug 10, 2014 at 04:05 PM
Maybe this discussion will help you: http://forum.unity3d.com/threads/is-there-a-way-to-cast-shadows-from-one-layer-onto-another.196125/
Answer by NateJC · Jul 29, 2016 at 04:50 PM
I figured out a workable solution for my case:
1) Make a parent game object that has the collider & rigid body
2) Now add two nested children to it, each with the same Mesh + Mesh Renderer components
3) Name one of them "View" and the other "Shadow Only"
4) For the View object, use these settings:
5) For the Shadow Only object, use these settings:
6) Now apply all physics & animations to the parent object, and everything else should work naturally!
The problem with this solution is that you have to add the same model into the scene twice every time you need this effect. It is ofcourse possible to semi-automate this via a script, would be great though to have a more elegant solutuin.
Your answer
Follow this Question
Related Questions
Soft Shadows are hard... 1 Answer
no shadow with until texture ?? 2 Answers
Making Sprites Darker / Shadowed? 1 Answer
Shadows and lights are flashing and disapperaring when player is moving 0 Answers