I’m using the URP 2D Renderer & Unity built in 2D Lights.
How would I go about creating a globally lit scene but some lights & sprites are only rendered if they are being lit by a specific light?
Example in this video:
you can see that the scene is dimly globally lit, however the Zombies are only rendered when the player light is over them. How can this be recreated using the built in Unity 2D lights?
I’ve tried using different sprite layers where the global light won’t affect the “hidden” sprites. However they are still rendered as fully black and not transparent.
Furthermore it’d also like other lights to only be visible IF another light is on them (like a player FOV).
Anyone have any suggestions or could point me in the right direction? Or is this feature simply not possible with current 2D lights implementation?
That wouldn’t work because the sprite mask doesn’t change depending on obstacles, so for an example if there is a wall between the player and the object, the object would still be inside the mask because it doesnt reflect the light “rays”/shape
I see. Perhaps you could manually override the geometry of a sprite used by the mask?
That way you could follow the raycsting and vertex/triangles approach used by the video while staying within the Unity’s higher level 2D API. That said, I’ve never used that method, so I can’t guarantee this would work.
Maybe Freeform light and setting m_ShapePath with reflection (it has no public setter)?
Plus SpriteMask with overriden geometry to prevent viewing things outside that shape?