0 Favourites

How do I create multiple layers of lighting?

  • I have a project where, following the lighting demo capx, I have my top layer set to an opaque black, with "splotches" of light created with the Destination Out blend mode.

    In my layout, I have the moon as a light source, and there's a building that stands between the player and the moon. Light from the moon (in the background) should not be able to penetrate the front of the building, right? What I want to do is make it so that light from the moon cannot shine on the front of the building.

    I've tried tinkering with the idea of having multiple opaque layers, but that doesn't seem to work. I've been stuck on this issue for a while, and I'm not getting anywhere. Help and guidance would be greatly appreciated. Thank you.

    EDIT: This is a 2D game, not top-down.

  • [quote:1fgg8qfn]If you want them to show without lighting, you may need to have duplicate objects at the same position on one of these above layers. The underneath object exists solely to cast the shadow, then the object on top is for appearance.

    Or conversely, if you want something NOT to show, you should be able to hide them with a shadow caster object.

  • I should have clarified: This is a 2D game, not top-down. The moon is in my "background" layer, the player and building are on the "main" layer, and the light sources are above that on the opaque "light" layer.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • It will be easier to understand the problem if you could share your capx, or at least a screenshot.

  • Of course!

  • So the inside of the house should be completely dark?

    Create a new layer (transparent), place a black rectangle above the building:

    You can add a smaller light source to the same layout with "Destination out" and pin it to the player.

    By the way, I suggest you use resources wisely. There are like 5 objects in your game and it's already 23Mb!

    Light image alone is 3Mb. You can make it 10 times smaller and stretch on the layout.

    Fireplace sound - 15Mb! Do you really need 5 minutes of high-quality fire crackling sound??

  • Thank you! Just to take it a step further, what If I wanted a separate light source inside the building independent from the moon?

  • Just add it to the same layer with that black rectangle.

  • What blend mode should that building light on the shadow layer be set to? Destination Out isn't doing anything.

  • Create a separate layer ("Layer 0" on my screenshot), set "Force own textures=Yes", "transparent=Yes"

    Place a black sprite on top of the building on this layer.

    Place a small Light sprite with "destination out" blend mode on this layer, above the black sprite.

    You can pin this Light sprite to player - it will look like the player is carrying a candle.

  • Okay, this light seems to shine very dimly, but I want it to shine to its fullest extent. The Destination Out only gives it a dull glow.

    P.S. Thanks for all your help! I really appreciate that you took your time to answer my questions!

  • This light on "Layer 0" is shining only very dimly with Destination Out. How do I make it shine fully?

    P.S. Thanks for your help with all of this so far! I appreciate that you took your time to answer my questions and give advice!

  • It's because the building sprite is still behind the black "light" layer.

    You need to make another layer between the "light" and "layer 0" and move the building to it.

  • But the player also needs to be placed above the building.

  • You got me. I don't know

    Maybe move the player to the building layer when it goes inside. And then move back to MAIN layer when it exits.

    You will need to make the entrance and exit wide enough for the player and make these areas quite dark, to make the switching between layers less obvious.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)