[CAPX] Yet another shadow caster

Show us your completed creations made in Construct 2

Post » Fri Aug 30, 2013 3:34 am

@keepee
I don't have access to c2 ATM but my thought on how to handle scrolling and such would be to have the canvas' on a fixed layer and just translate the image point positions to the fixed layer. I believe there are some system expressions that can do the conversion. Everything else could be on other layers that scroll and shouldn't need repositioning to paste... I may be wrong as I haven't tried pasting to another layer that has a differing offset. If it doesn't then the falloffs and such will have to be moved before pasting and then moved back after.
B
94
S
33
G
118
Posts: 5,395
Reputation: 75,851

Post » Fri Aug 30, 2013 4:22 am

A zeldaish quadrant style scrolling might work.
Basically after the player gets to a certain x, or y the camera scrolls the length of the viewport, rather than just move a little at a time.
Image ImageImage
B
172
S
50
G
183
Posts: 8,442
Reputation: 115,603

Post » Wed Sep 25, 2013 4:50 am

Is it possible to include a destination in effect on the falloff, which would allow textured objects to be in shadow until the light is over them, rather than just a black space.

That make sense?

If I convert one of the objects in this example, say the star to have multiple colours, it shows up even if there are no lights around.
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
84
S
15
G
7
Posts: 991
Reputation: 11,231

Post » Fri Oct 04, 2013 2:30 am

@R0J0hound

Sorry to bother you, but can you think of a way to have the canvas serve as a destination in effect. I've tried adding it myself but to no effect.

Also, I can't seem to figure out how to put a background texture in the example you've produced. Each time I do, the coloured lights just appear to wash away any detail.

Hope you can help. I've been working on this mini-project for the last couple of days, only to suddenly hit this potential roadblock.

If you'd like to see the capx I've been working on, I can pm it to you?
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
84
S
15
G
7
Posts: 991
Reputation: 11,231

Post » Fri Oct 04, 2013 6:21 am

Sorry, I don't login too much and I miss many posts.

For the first Q you're talking about an object casting shadow and being visible when lit, right? One idea that comes to mind would be to only cast edges facing away from a source. Although it wouldn't work great for concave objects.

For a texture underneath you could reduce the opacity of the gradient sprites. I don't entirely recall what the example does so I'd have to tinker with it. Another idea would be to reduce the opacity of the color fill.
B
94
S
33
G
118
Posts: 5,395
Reputation: 75,851

Post » Sat Oct 05, 2013 2:22 am

Thanks for responding @R0J0hound. Sorry about the delay, I wasn't alerted to your response.

Please find below the version I have been working on:

https://dl.dropboxusercontent.com/u/50465867/Construct/LightTest.capx

This setup allows objects with textures on to be hidden, but this is based on an additional falloff being added and used as an effective mask. This issue I can forsee with this, is if you were to move it up to a solid object, although the light wouldn't go through, and would cast a shadow, the objects on the other side would still be visible.

Also, as CanvasMain is constantly being turned solid black, It prevents me from having a background. Shadows won't appear on objects on a higher layer.

I saw this version (linked below), which only uses 1 canvas, and allows a background, without the need for transparency, etc, however it doesn't work well with multiple light sources.

https://dl.dropboxusercontent.com/u/50465867/Construct/LightTest02.capx

With yours, I like the way the colour bleeds into each other forming different colours, but can't really see why 2 canvas' are required. I've tried altering bits and pieces, but it seems to be an easy thing to break.

However, I have disabled the falloff visibility toggle every tick, as I don't see any difference. I've also added a distance indicator so that shadows aren't drawn on objects that are too far away from lights.

Still, my attempts at combining the two methods have been met with failure. Any ideas?
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
84
S
15
G
7
Posts: 991
Reputation: 11,231

Post » Sat Oct 05, 2013 2:25 am

Oh, and additionally, although I really like the mixed colours, I have a bad feeling that they wash away the texture below them :(

My sprite is made up on 2 solid colours, but with the light on top, both show up as a single solid.
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
84
S
15
G
7
Posts: 991
Reputation: 11,231

Post » Sat Oct 05, 2013 1:03 pm

Amazing @R0J0hound :) very good and fast implementation, why is there no native plugin for this? :) and canvas plugin too! You rock, I thought it wasn't even possible to do do such things in C2.
B
11
S
3
G
5
Posts: 19
Reputation: 3,639

Post » Sun Oct 06, 2013 3:05 am

Hi, I had a quick look at the capx. I also tinkered abit with making objects visible but my implementation of my idea wasn't working right. As to multiple canvas' it's for the additive blending of the lights. Each light casts shadows on its own canvas and then it's additively drawn to the main canvas for blending. I got away with just two canvas' since I can just keep reusing the 2nd canvas for each light. The composition will have to be reworked to incorporate transparency so you can allow textures underneath to show through.

Here's a rough idea how it could be done.
I think it's "destination out" that acts as an erase.
1 draw shadows to canvas c1
2 fill canvas c2 with the light color
3 give c1 the destination out blend and paste it to c2.
C2 will then have the lit areas colored and the shadow areas transparent.
4 paste the falloff sprite to that too and then paste it with an additive blend to canvas c3
Do that go each light.
5 you can then get the shadows again with steps like 2 and 3. The shadows should be now on canvas c4.
The only 2 canvas that should be drawn are c3 for the light and c4 for the shadows.
You could then fiddle with the light canvas opacity to adjust the blend.

There may be some issues with the idea since I haven't tested it.
B
94
S
33
G
118
Posts: 5,395
Reputation: 75,851

Post » Sun Oct 06, 2013 3:24 am

@R0J0hound will try your last post :D if I fail I will ask you to post a little sample file :)
B
11
S
3
G
5
Posts: 19
Reputation: 3,639

PreviousNext

Return to Completed Creations

Who is online

Users browsing this forum: No registered users and 0 guests