[Effect] : 2D Dynamic Lighting

Share your Construct 2 effect files

Post » Wed Oct 24, 2012 4:19 pm

I decided to port Matt Greer's work with 2D dynamic lighting for 2D games to C2 (I modded a bit the original shader to conform to C2's IDE).



The yellow square is the ligh source.

The work is described here : http://www.mattgreer.org/post/4dynamicLightingShadows

The idea is to use a Sprite, like this one :

and put another one on top of it, with normals "baked in" :

(don't forget to put everything not colord in that normal image to transparent !)

You can then apply the effect to the normal image, to get the effect you can see in the top screenshot.


The parameters of the image are the "Image Color" (you need to set all 3 channels to the same color for the moment), higher-value = darker shadows.
You can set the light direction with the same values as in the example.
The (x,y,z) vector set the postion of the light over the texture.
lower Z = ligther shadows.

You can set the value for the (X,Y,Z) position of the light like in the example :

Here, the light is going to follow the mouse, always facing the center of the image.
For that, I use a invisible Sprite, in red in the following screenshot, in the center of the scene. The light is always going to face it.



You can, if you want have several "Points Of Origins" in your scene, and change the POI the light is facing dynamically in your game, to have nice effects !

The demo : https://dl.dropbox.com/u/1412774/LightingDemo/index.html
The effect (decompress it in the 'effects' folder !) : https://dl.dropbox.com/u/1412774/LightingDemo/pode_dynamic_lighting.1.0.zip
The .capx : https://dl.dropbox.com/u/1412774/LightingDemo/LightingDemo.capx
B
33
S
9
G
6
Posts: 709
Reputation: 6,704

Post » Wed Oct 24, 2012 5:11 pm

Wow, high-tech!
B
106
S
27
G
8
Posts: 209
Reputation: 12,525

Post » Wed Oct 24, 2012 6:05 pm

Very nice!
Moar examples please!
B
36
S
10
G
6
Posts: 948
Reputation: 11,101

Post » Wed Oct 24, 2012 7:48 pm

Great I like too see combined with shadows
B
60
S
9
G
7
Posts: 176
Reputation: 8,794

Post » Wed Oct 24, 2012 9:25 pm

Cool effect Pode,
I used Blender and your example to make this:
http://dl.dropbox.com/u/5426011/examples15/marble_monkey.capx

Here is the .blend file I used to make it:
http://dl.dropbox.com/u/5426011/examples15/normal_map.blend
B
79
S
24
G
54
Posts: 4,738
Reputation: 40,739

Post » Thu Oct 25, 2012 3:35 am

That's really awesome
B
96
S
25
G
20
Posts: 3,052
Reputation: 22,638

Post » Thu Oct 25, 2012 5:22 am

Oh ! So Nice ! Son it word on mobile svices ?
B
21
S
9
G
4
Posts: 197
Reputation: 4,105

Post » Thu Oct 25, 2012 6:59 am

@R0J0hound : nice demo !
@Laurent : only if there's a WebLG implementation on that mobile platform (so, for example, not iOS).
B
33
S
9
G
6
Posts: 709
Reputation: 6,704

Post » Thu Oct 25, 2012 9:47 am

[QUOTE=Pode] @R0J0hound : nice demo !
@Laurent : only if there's a WebLG implementation on that mobile platform (so, for example, not iOS).[/QUOTE]

I tested it on my Playbook, it looks like a glitch, but it's up to RIM, when they release BB10, i hope WebGL looks nice on the mobiles.
B
96
S
25
G
20
Posts: 3,052
Reputation: 22,638

Post » Thu Oct 25, 2012 9:54 am

A quick question...

Is possible to add drop shadow like that video from the author link?
B
96
S
25
G
20
Posts: 3,052
Reputation: 22,638

Next

Return to Effects

Who is online

Users browsing this forum: No registered users and 0 guests