How do I multiple ShadowCasters / ShadowLights

0 favourites
  • 15 posts
From the Asset Store
Be quick and choose the right answer for the shown equation.
  • Hello there,

    I would like to add several light sources and generate dynamic shadows. I have already tried with the ShadowCaster and the ShadowLights, but without success.

    So far I have the following sequence:

    https://www.dropbox.com/s/nqvjn0okwsg8e ... s.jpg?dl=0

    ...and here is a screenshot of my map:

    https://www.dropbox.com/s/ys8h90arbqibb ... n.jpg?dl=0

    The green lines are the ShadowCaster. The Layer opacity is 100% and I will see all black. <img src="{SMILIES_PATH}/icon_e_surprised.gif" alt=":o" title="Surprised">

    Can someone help me there? <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

  • You need a shadow caster behavior on everything that needs a shadow cast.

    Watch the CPU power though when you add more lights and more stuff. It can really add up quick. Unity or U4E would be the best in this case.

    Construct has Dynamic lighting, and if used right it can look really good. But at this time I think the solution for you is to try something more engendered for the task of shadow casting,

    A few fake shadows here and there is fine, but be sure to watch the rendering overhead. Construct can do a lot of great things. Accurate, efficient shadow-casting is not one of them. For really nice shadows you will need something that takes the 3D nature of the object into account.

    TRy making your sprites with pre-rendered shadows is another solution I have found.

    Better to use a chainsaw to cut trees, and a table saw to make fine woodwork. Picking the right tool for the job is verry important, otherwise you are going to do lots of things to equal the features of the other engines.

    C2 makes great 2D games , faking 3D games it does ok.... but you will need to invest a lot more time into making our artwork.

    Look in the effect section there is a guy named Somebody that made a great shadow effect.

  • I had a ShadowCaster and ShadowLights, but once I use a second ShadowLights, appear no more shadows.

  • You need more than 1 layer.

    The lamp and the shadows should be on the same layer IIRC:

    https://www.scirra.com/manual/178/shadow-light

    I dont use them very much, sorry my memory is hazy.

  • Seeing your graphics using shadowlight might be overkill..

    I'd go for pinning a shadow object (sprite) to your player and setting it's angle based on where the lightsource is..

  • LittleStain: Ok, but this solved not my problem. I edit my first post.

    I have several rooms. For example in the third room (right on top) you have a "daylight" and a lamp. In the first room (where start the player) you have another lamp. The green line are ShadowCasters.

    jojoe: Thanks for your edit. Before I trying the ShadowCaster and ShadowLights, I used "Parallax Lightmaps". Its only a Sprite (created in GIMP), but this was not good for me. I want more Dynamic.

  • In my opinion faking it the way I suggested would give better (and probably less gpu-intensive) results in your case..

    another way would be setting the shadows to a certain amount of opacity and using the Alpha threshold effect on the shadow layer..

  • In my opinion faking it the way I suggested would give better (and probably less gpu-intensive) results in your case..

    another way would be setting the shadows to a certain amount of opacity and using the Alpha threshold effect on the shadow layer..

    Hi LittleStain, great way to put it.

    One of the best "Rules of thumb" I have heard for Video game development is "Better to fake it than make it".

    Wossi

    An old trick we did with the blender game engine was to take the 3D model which was casting the shadow, replace the material with a flat black material, then Smash the model flat on the same normal as the light direction. Then flip and mirror the object to make an exact shadow.

    In Construct 2 you can do the same thing with the sprites, by duplicating the animated sprite, Use the Set Color to Black (0,0,0)

    Here I make a Jumpman with a fake shadow for you.

    https://mega.nz/#!VFY31A7Q!xroRHt6HoVp_ ... pw54D5LEV4

    I am doing it in real time, just for this example, you are going to want to do this shadow sprite in your image editor.

    Just Flip it , and smash it. You can also Skew it in your image editor, but I suggest not doing that. Anyway, enjoy your Lazy-Mans-Free shadow Hack!

    Have a good day <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

  • Here is one with an animated sprite. Just put your sprites into the Shadow family and enable it by setting the instance variable Shadow to True. Leave the original set to false. Then Invert the Y axis, and make the height about half the original height.

    https://mega.nz/#!UIA1XBRA!MhmuMro-jTHD ... Vax9l5NZBk

  • Thanks for all replies! <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">

    Here is my other solution with a type of "light mapping". It's a little bit more of dynamic as a simple sprite, but the lights will be shine in the adjacent room.

    https://www.dropbox.com/s/10847ox199nqw ... t.jpg?dl=0

  • Ok, here is my minimal updated *.capx file.

    https://www.dropbox.com/s/fx4uqq5t9ee3v ... .capx?dl=0

    When I use only one ShadowLight, than it works correctly. But whenever I drag the second ShadowLight in the first room, the ShadowCaster don't work! What am I doing wrong?

  • The shadowcaster object casts Shadows, not light..

    Creating a second object to cast shadows will not add light, only more shadows..

    That's why I gave the suggestion using the alpha-threshold and semi-transparant shadowcasters on the shadow layer so everything over a certain alpha value would become shadows..

  • Sorry, but that's too much for me.

    I think the "ShadowLight Object" create the Lights and the "ShadowCaster Behavior" generates the Shadows. The theory I do not understand really. Can you show me on the *.capx file, what exactly do you mean?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The shadowlight object decides from which point the shadows are casted..

    There is no light involved, only shadows are created..

    In my opinion using one of the "old" methods of faking it would suit your case much better:

    From my download archive (Don't remember original poster)

  • Thank you for helping, but that's all not for multiple lights. Also ShadowCaster and ShadowLight are not the best way, to solved my problem. <img src="{SMILIES_PATH}/icon_e_sad.gif" alt=":(" title="Sad">

    That is I want to go:

    https://www.dropbox.com/s/n1tfn0045zves ... p.jpg?dl=0

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