How do I cast light on an object and not the backgroundt

0 favourites
  • 15 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hi All,

    I'm having trouble casting light on a single object and not the surrounding background. I think I have the layers right, but something isn't working quite right with all the blending modes. Ideally, the light sprite would only 'shine' on the poker chip itself and not the surrounding background or UI (drag the green dot around to move the light).

    If anyone can assist, it would be appreciated? I think I need a sprite in the masking layer that creates a mask of the object below, however I can't seem to get that working..

    Any assistance would be much appreciated!

    -Remy

  • Have you tried the C2 EXAMPLE Lighting.capx try it and you will learn.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If you have not then here is file

  • You only want the light on the chip and nothing else ?

    Here is a test of what I think you are after. Using large sprite. If you move the mouse/light to the far left of the screen the light is no longer hidden. Needs work...

  • You only want the light on the chip and nothing else ?

    Here is a test of what I think you are after. Using large sprite. If you move the mouse/light to the far left of the screen the light is no longer hidden. Needs work...

    RamPackWobble, this is exactly what I was looking for -- and the balloons brightened my day

    Thanks!

    -Remy

  • Glad you like it - but it was using a large sprite to hide the spotlight , no problem on a PC but might need a "few coats of thought" for mobile...

  • Glad you like it - but it was using a large sprite to hide the spotlight , no problem on a PC but might need a "few coats of thought" for mobile...

    Heh, and wouldn't you know that's my next problem.... I saw how you used the 'cut out' circle with "destination in" applied, however, in my context, I need to be able to dynamically switch the poker chip to other objects of choice. So, I can simply create a new object on the same "light" layer and set it's blend mode accordingly, however, if the objects aren't the size of the entire viewport I'm working with (which they never are), i get the light bleeding onto the background for any area in the view port that is outside the sprite's bounding box of the object created

    I've tried having another "mask_sprite" that is blank sprite as big as the viewport I need the object to move around in. It also has a 'destination in' blend mode and instead of having another object sprite in that layer, I tried to Load Image From URL on the "mask_sprite" to programmatically place my object of choice into the "mask_sprite" sprite, however, now NO light is seen at all.

    Any "coats of thought" on how I could either combine any give sprite/object with another background sprite in order to achieve the desired effect? OR if as mentioned about, I have one sprite that is the size of the viewport that I"m operating in that I can paste/load the object of choice in/onto?

  • If you have not then here is file

    Thanks, however, the example does not light only an object and not the background. The example RamPackWobble provided solves most of my issue, however, there is a new twist now, referenced above

    Cheers,

    -Remy

  • Are you only trying to highlight certain objects - something along the lines of "choose this one ?" but using light ? If so another option would be to just have the sprite with an animation you can play as required ?

  • I do not know what you mean but, is it like this

  • Here is an example using an alpha mapped sprite to cast (?) a glint on a chosen coin

  • I do not know what you mean but, is it like this

    Not quite...

    To clarify, try turning the background to black, then, the light should ONLY shine on the circular object, and NOT the black background... That is the first problem that RamPackWobble solved. The second is the need to essentially programmatically generate the "light" layer in RamPackWobble s example.. Right now he uses a big blank sprite with a circle 'cutout' with a destination in blend applied, I need to be able to drop in any particular object into that layer and achieve the same effect. If I try Spawning/creating a duplicate object of the one on display, say, a playing card to continue the poker theme, I'll see the light shine on the background too, not just the playing card. I thought if I applied a destination in blend to the entire later that would work, then I could drop any object in, however, I only want this effect to apply to a window within the current layout, not to the whole layout...

    Appreciate your help though Lordshiva1948

  • Here is an example using an alpha mapped sprite to cast (?) a glint on a chosen coin

    This is the gist of what I"m trying to achieve, yes, however, since the object can be dynamic, I need to use effects (like 'additive') on the object in question.. and can't use a static glint

    -Remy

  • jay in you last msg did you any chance try to send CAPX? if yes where is it?

  • To be honest, Construct's blending modes are very counter-intuitive and unreliable. As I read this topic, I am trying to replicate the "source in" blend mode like in the official example and all I get is a black color on the transparent areas of the sprite that has the source-in mode and no blending at all with the sprite bellow.

    A dedicated masking system per layer (like in After Effects) and blending modes that are standard in drawing-photo editing applications will be a great benefit. They will allow complex and dynamic effects like splatters, decals, fog and all sort off things.

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