How do I apply a shader on multiple layouts? [RESOLVED]

Get help using Construct 2

Post » Fri Oct 31, 2014 10:58 pm

Hello,

Here is my issue : I have several shaders for my game.
My game works with a lot of different layouts (one for each room).
If I want to have the same visual result, I have to add the shaders needed in EACH layout.
If I have 100 rooms, and I need to replace a shader by a better one or just adding a cool fullscreen effect for the entire game, I will have to do it 100 times.

Am I wrong?

Tell me there's a easier way please! :)
Last edited by KaMiZoTo on Sat Nov 01, 2014 10:01 am, edited 1 time in total.
B
73
S
21
G
12
Posts: 314
Reputation: 12,148

Post » Fri Oct 31, 2014 11:14 pm

Can't you call the shader from an event sheet that you include in each room?
B
35
S
9
G
3
Posts: 493
Reputation: 4,092

Post » Fri Oct 31, 2014 11:32 pm

If a shader is not in the effects list of the layout, I can do nothing.
And I don't see any action to 'call' or 'create' dynamically a shader. :(
B
73
S
21
G
12
Posts: 314
Reputation: 12,148

Post » Sat Nov 01, 2014 12:27 am

Perhaps you could take advantage of global layers? You'll need to add an empty layer named "Shader" or something to every layout. Then in one layout, (maybe a test room if you have one,) set that layer to global and add all the effects you need. Then it should be automatically mirrored to every layer with that name throughout the entire project. That way you only need to set it up once and any changes you make later won't need to be repeated.
B
35
S
9
G
4
Posts: 201
Reputation: 5,182

Post » Sat Nov 01, 2014 12:48 am

@Ahr Ech Well it won't work as my fx are applied on the layout, not just one layer.
If I put, for example, a deformation shader on a layer, only that layer will be affected, not the other ones.

Or I mainly use full screen shaders that need to affect all the screen. :(
B
73
S
21
G
12
Posts: 314
Reputation: 12,148

Post » Sat Nov 01, 2014 3:51 am

In some cases you can get around that. Like if the effects you want to use don't work as masks but you need them to, you can sort of piggyback them on an effect that that does so it applies to everything underneath it.
Image
So here I have a single empty layer on top. It has a noise mask with it's intensity set to 0 because all I want is it's mask property, and the other two effects ordered under it so they process last on top of the mask. As you can see, the warp effect gets applied to everything.

It's not the most efficient solution but I hope you can adapt that to your needs. If it'll work you also have the added benefit of being able to apply your shader underneath any UI elements if you want so they remain un-obscured.
B
35
S
9
G
4
Posts: 201
Reputation: 5,182

Post » Sat Nov 01, 2014 10:01 am

@Ahr Ech Wow!!!! Thank you for the trick! It works. :)
That will save me a lot of time!!!

(I'm wondering if setting 0 to the NoiseMask is equal to no CPU use for that 'empty' shader?)
B
73
S
21
G
12
Posts: 314
Reputation: 12,148

Post » Sat Nov 01, 2014 6:45 pm

Happy to help!
KaMiZoTo wrote:(I'm wondering if setting 0 to the NoiseMask is equal to no CPU use for that 'empty' shader?)

On that I have no idea, but I suspect the CPU use doesn't change. That's why I use Noise for this, because I assume it doesn't take much to begin with.
B
35
S
9
G
4
Posts: 201
Reputation: 5,182

Post » Fri Nov 14, 2014 7:39 pm

Damn, since R187 (same in R188 but I never tried the R186), my shaders using this trick don't work anymore.
I have to work on the R185 to keep it working. :(

Anyone else have noticed changes?
B
73
S
21
G
12
Posts: 314
Reputation: 12,148

Post » Fri Nov 14, 2014 7:52 pm

Ok I've found where it comes from :

R187 :" The renderer now experimentally skips rendering layers with zero instances on them,.."

So we just need to add a sprite (or anything else) somewhere outside the layout and it works again! :)
B
73
S
21
G
12
Posts: 314
Reputation: 12,148


Return to How do I....?

Who is online

Users browsing this forum: avatar45 and 8 guests