[REQUEST] LightCaster, aka 'Inverted ShadowCaster'

Post your work in progress addons and get feedback

Post » Sun Jun 14, 2015 2:30 pm

I have been running into the same problem that I've seen other users on this forum also have before me, and that is the lack of support for multiple light sources within Construct 2. I am talking about the ShadowCaster object, which in it's own right works - but only if you're willing to have a singular light source in your game, or several spaced apart from each other. It's a real downer, and it's something I've tried to find a work around for the last few days.

My first attempts included layer-effect-shading magic, but to no avail. Around here I realized that the object not only should be fully transparent where the shadows usually are from the default ShadowCaster - but it also have to be transparent all together, most desirably with the alpha mask being a radial gradient, on top of being cleared where shadows usually appear. The Polygon and Canvas plugins have gotten me on the right track, but far away from anything that actually ... well, works.

And that's why I am proposing this:
Could one 'reverse engineer' the ShadowCaster object/plugin to render it's polygon on the "inside" where the "light" is, rather than the "outside" where the shadows are?

The plugin itself is already well capable of all the raycasting you'd need to achieve this, the other main thing would be the alpha ... But that could surely - worst case scenario - be handled using a webgl effect that calculates every pixel's alpha depending on the distance it has to the origin. And then you'd slap a tint effect onto that for different colored lights. I also believe it would even run smoother than default (if I understand it's internal mechanics correctly) in that, instead of rendering several arbitrary polygons in one tick, it would only render one.

I've made an image trying to better describe what I'm trying to achieve here. I am certain that this will not only suffice for my own interests, but also for many others.

Image

As you might be able to tell, it should all be pretty straight forward what I would like to accomplish here. But - since I lack any actual knowledge with javascript, nor the will to start taking apart the ShadowCaster's runtime.js without actually knowing anything about it in the first place - I'm asking any kind soul to consider my request, point me to a working alternative or workaround I have missed, or kindly tell me why this isn't actually possible.

Thank you for your time

Edit: Oh, and if there's any question whether you'd like to be paid for your work, we could discuss that aswell.

Edit 2: Am I doing this correctly? I guess not, huh?
B
7
S
1
Posts: 21
Reputation: 475

Post » Tue Jun 16, 2015 6:12 pm

IDK, I think the idea of a mega-polygon (Carmack, is that you? :ugeek: ) is kind of interesting, though, it seems like if you had a lot of onscreen shadowcasters the complexity of the polygon might become a problem.

However, the light/shadow system was quite a bit of work, and I'd be surprised if Ashley didn't try something like this along the way, as I've read about other implements before that did something similar to what you are suggesting.

I suspect this would gobble up a lot more fill rate as well, since rendering the 'inside' means overdrawing substantially more pixels. Which is a problem for perf on desktop, unless you want to ignore the massive number of people rocking iGPU's only (wish we could, but... :roll: ).

Anyway, I'm going to shut up now, because I'm starting to get way out of my depth... :mrgreen:
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,202

Post » Tue Sep 15, 2015 9:08 pm

i think its already possible ...
B
77
S
23
G
69
Posts: 1,353
Reputation: 43,958

Post » Tue Sep 15, 2015 10:27 pm

I took a moment and managed to make the effect you're going for.
Image
here's the capx
http://1drv.ms/1Ke6Oi7
B
45
S
21
G
65
Posts: 1,115
Reputation: 38,221


Return to Work in Progress Addons

Who is online

Users browsing this forum: No registered users and 1 guest