heightmap mask and multiple lights

Post your own tutorials, guides and demos.

Post » Tue Aug 21, 2012 6:38 pm

Hey,

there`s another one coming:

Problem:

You want to render a scene containing multiple radial lights including heightmaps. When you apply a heightmap effect to the texture, there`s only one light, so multiple superposed lights will fail to render correctly.

Solution:

Create a layer with the diffuse/ compiled texture, then below a layer with the heightmap. The light sprite incorperates the following shaders:

1.

A shader that grabs the pixels two layers below the current sprite
(e.g. the global variable texture viewer in fisholith`s shader pack: http://www.scirra.com/forum/topic46099_post288721.html#288721)

2.

A shader that shapes the sprites to an ellipse with smooth transition.
(e.g. the one made by Tulamide http://www.scirra.com/forum/effect-ellipse_topic51611.html)

3.

the heightmap shader with light position information.

Applying the shaders in this order the sprite will use the heightmap below the diffuse texture, blend it over in ellipse shape and renders the lighting on the heightmap information.

Additionally, for every light in the scene/ on the level or map, you can center the light x/y. to have the light rays radiating from the center of the source.

Heightmap blend:




Final composition:



The render techniques are quite expensive, but this is probably the closest thing you`ll get to a realistic lighting engine in Construct with a somewhat marginal effort.

Grab the example cap here: http://www.schade-blog.de/schade-studios/bumplights.zip

I included the effects that accomplish this in the zip, hopefully by their creator`s leave.

Credits go out to fisholith, Tulamide and Jorge Fuente-Alba.

Cheers,
the ColonelColonel Justice2012-08-21 18:40:03
Image
B
13
S
4
G
1
Posts: 113
Reputation: 1,712

Post » Tue Aug 28, 2012 5:48 pm

Hey Colonel,
pretty smart approach you got there, congrats!
I'd like to understand your concept, because i thought about pretty much the same idea the last days... so a few questions arise:
- How do you handle pixel perfect light postions on a layout bigger than DisplayWidth? I think in the current cap the lights are tied to the viewport.
- Do you see any chance colorizing the lightsources?

thanks!
B
59
S
7
G
2
Posts: 93
Reputation: 4,228

Post » Wed Aug 29, 2012 10:56 am

Hey,

it`s true, I have to tinker a formula for the lights position relative to viewport and layout size. Best way would be probably to do it through a shader variable.

The light sources can be colored easily, just append a coloring shader to the pipeline, like NouvoFill or something else.

Cheers!
Image
B
13
S
4
G
1
Posts: 113
Reputation: 1,712


Return to Your tutorials & example files

Who is online

Users browsing this forum: No registered users and 1 guest