Hi,
Does anyone know how to BLOCK point light from passing through certain objects with this package?
Picture illustration below:
I want the point light to not pass certain objects (Shadow Intensity set to 1.0).
Other objects should have a Shadow Intensity of 0.5 or something…
Can someone point me in the right direction?
I dont think you can do this directly with the current vision of 2D lighting system.
Creating two lights and using two different target layers should do the trick, just a little inconvenient.
Thanks for the reply.
Ok! that’s unfortunate, do you know if they have it on the roadmap? Feels like it should be a key feature…
I use many 2D lights in my game and feel the current 2d lighting system missing many features it should have. I think the team is working on the improvement of light render efficiency and the future roadmap is unclear. And we will wait at least some time.
I can’t get 2D lights react differently with different sorting layers. For example, if I have a gameobject with a sprite and a shadow caster 2D, I configure the sprite in the sorting layer A and shadow caster to affect sorting layer B. If I have two lights where both affect B, but only one to A, both produce shadows over B with the shadow caster that is in A
https://discussions.unity.com/t/789666
Can you help me please?
It’s been over a year and you probably don’t need your answer anymore, but for anyone who finds this thread, you can play with the “shadow intensity” value of your light and add a shadow caster to anything you want blocking light. It’s a little finnicky, but I think it does the trick for most games.
One issue with it is it illuminates the entire object, but still blocks the shadow, but I suppose this could be solved with either normal maps or just creating an invisible separate object with a shadow caster over the object you want casting shadows.(and removing the shadow caster on the object)
Not sure if this was added recently or the previous person just didn’t know about it.
Yeah, this was what I said like … two years ago… so sad…
2 Likes
Yeah, I never used it 2 years ago, but it feels like they just abandoned the whole shadow cast system. I noticed if I shape the shadow caster at a certain angle the light will pass right through sometimes… Like, I’m talking narrowing the one end of a square, not making crazy shapes! It’s sooo bugged! XD
1 Like
another 2 years passed, providing reference for others who encounter the similar situation.
I have a solution for my case that light should blocked by wall.the following picture shows result. it’s the basic idea that using filed of view as mask after light render.
key points :
- render feature, a simple custom feature to get rendered fov, reference
- fov, raycast to generate filed of view ,reference
- render texture , saving mask(fov), with a camera only culling fov layer
- material(shader graph), working with render feature to get rendered fov and apply(mask) fov
at starting , try shadow caster 2d with tile map(in my case), it’s very poor performance(only 10+fps even freeze on 25*25 map full with wall).
Yeah for something like this you have to go custom. 2D Renderer by itself targets a limited band of use cases.
Could you elaborate on what going custom could mean? At least enough for me to be able to do my own research? The super harsh lines im getting are driving me insane lol.
Check the links provided by @niwhocug
They can also be combined. Create field of view mesh, then blur it with renderer feature to soften the effect.