Casting Shadows in C2

0 favourites
From the Asset Store
Magic Spells (SFX)
$4 USD
60% off
High quality spell, looping and casting sounds for your medieval & fantasy settings
  • AdamD says he's on holiday for a few days, but he'll come and respond when he's back

    Edit: In case you're wondering, I'm his trained monkey butler

  • Dude!! This is awesome!

    Please give us more details and/or the .capx =D

  • Thanks for all of the comments and feedback guys. Sorry it has taken me a while to respond, as SecondDimension mentioned, I've been away and without internet access for a few days.

    robin Sommer - I've been toying with the idea of a light based game but don't have any plans as of yet.

    sqiddster - This isn't a shader (that would probably be a more efficient way of doing it), I'm just using some maths and the canvas plugin. I should've mentioned the canvas plugin in the original post as it is brilliant.

    Venivididormi - I plan to post the .capx at some point (once I've cleaned it up a bit). It is math/loop heavy, I'm sure there is probably an easier way to do it but basically I project out the polygon away from the light source and draw it using the canvas plugin.

    Sylvain - Will do, once I've cleaned it up a bit.

    lemo - Thanks for the feedback. You're correct, the effect is highly exaggerated but perhaps I can explain my decisions. Firstly, shadows become exponentially bigger as the object casting the shadow gets closer to the light source. I've just exaggerated the effect because in the final version there will be fall off from the light which will blend with the shadow being cast (i.e. outside of the range of the light you won't be able to see the shadow). In the case of overlapping shadows, it is a problem as you note which is due to a glitch caused by multiple light sources. With multiple light sources you do get an overlapping shadow effect, see some examples: tinyurl.com/cd6o7yw and tinyurl.com/cqs7g8u. Although you can't see it, there are multiple light sources, close to each other, to create a soft shadow effect. I was just trying the effect out and need to fix it to get it to look right.

    AnD4D - Thanks for the comments. In response to your question in the other thread, I use a lot of sub-events, local variables and functions in the files. So I spread the effect out over quite a few events. If I were to compress it down then I think that the flashlight would be around 30ish events and the lightingTest would be about 60-70.

    spongehammer - Yes, there are actually multiple light sources all close together in the LightingTest example, I was playing around with creating a soft shadow effect.

    - As I mentioned above, I'll post the .capx files as soon as I've cleaned them up a bit. They require the canvas plugin to be installed.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I've put the .capx file for the flashlight demo online so that you guys can take a look at it. It is at: adamduncan.com/Flashlight/source.zip

    You'll need to add R0J0hound's excellent canvas plugin to run the examples: scirra.com/forum/plugin-canvas_topic46006.html

    I'll put the lighting test source code up soon too, I just want to see if I can fix a couple of issues with it.

  • Nice. Thanks for sharing.

  • Wow, this is pretty cool. I wanted a similar effect for my next game, so I'm going to have to thank you in advance for the share!

  • Cast shadow plugin? anyone? ;)

  • vry nice effect dude :D

    and the effect was incredibly realistic

  • Thanks for the comments and feedback everyone.

    I've put up the source code for the LightingTest, there are some changes that address some of the criticism. Apologies for the complexity (it isn't a simple approach), maths is not one of my strengths and I had to fumble through it a bit. You can download it from: adamduncan.com/LightingTest/source.zip

    I've only just discovered that R0J0hound made an example of cast shadows and posted it in the following thread: scirra.com/forum/dynamic-shadows-now-possible_topic56174.html. I recommend looking at it if you're interested in drawing cast shadows in this way (using the canvas plugin). It turns out R0J0hound does it much better than me and I feel like a bit of an idiot now that I've seen it. What I wanted to achieve was a bit more complex and I'm glad that I've solved the problem on my own though.

  • This isn't a shader (that would probably be a more efficient way of doing it), I'm just using some maths and the canvas plugin. I should've mentioned the canvas plugin in the original post as it is brilliant.

    I think C2 needs a dedicated canvas plugin for the same obvious reasons. ;)

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