Light2D and LightOccluder2D are confusing

chitogechitoge Posts: 6Member
edited June 2016 in 2D
I can't understand how Light2D works looking at the lights and shadow demo. <br />From the demo it looks like Light2D works by creating a CanvasModulate that darkens the entire game, then passing a white circle texture to a Light2D object which brightens the area of the texture size. <br /><br />LightOccluder2d works but the shadow itself is always rendered above the sprite node and I cannot find any way to render it behind its parent or any sprite. I've tried editing the z-index, checking "Behind parent", unchecking relative, changing the order of the nodes, and changing the sprite's mode from "Mix" to "Add".<br /><br />In this picture you can see that the LightOccluder2D shadow is above my sprite, although it's working as intended. Also, the light coming from the torch is simply the white circle image I got from the demo.

Comments

  • zadigzadig Posts: 28Member
    In short:<br /><br />You don't need the CanvasModulate.<br />You need:<br />·A light2D WITH an image texture.<br />·LightOccluder2D (as many as necessary for your scene)  WITH an OccluderPolygon2D defined ("Occluder" field of the LightOccluder2D) - this guy is the one with the boundaries that will cast shadows. Forget about the Sprite (set no image at all).<br /><br />After that you just need to play with the settings to achieve the desired results :)

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file