Blend mode issues

Get help using Construct 2

Post » Sun Sep 16, 2012 2:41 am

Hello all!

I have a texture (tiled background) that will cover the whole layout (so I only need one of them). I want to be able to specify where it is seen using masking. However, I run into a situation where the masking object's transparent background has a different effect than having none of the object.

Here's what I mean. There's a single circular mask in the middle, so I want to be able to mask out ALL the orange except the circle. However, you can see the masking effect not work outside the boundaries of the masking image. I guess this makes sense, but what can i do here?

I'm aware I could just use a different blend mode and mask where the texture is not, however there are two issues with this.

1. Since the masked shapes are pretty simple, masking where the texture is 'not' is much more complex and will use many more sprites.

2. I'm also using the mask as a collision detector. This could save a lot of time and objects.

Let me know if you have any ideas?
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Sun Sep 16, 2012 3:29 pm

I think this is just one of the few cases you need a large area of transparency around the mask image.

You could also try playing with some other blend modes, like 'destination out' to cut a hole in a layer, and 'force own texture' on the layer to ensure it is drawn separately then copied to the main display. With some creative tricks you can sometimes make the same visual thing a different way.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Sun Sep 16, 2012 6:26 pm

Set Mask to blend mode normal
Put Texture on top in the same layer
Set Texture to source-in

Only the orange inside the circle will appear.

The only issue with that technic is that you will see the black circle when it's out of the orange texture.

The solution I came up with was to create a shader that set pure black pixels to transparent and apply it to the layer. If there's pure black in your the texture you want to in place of the orange, you should just set them to 1% instead of 0% grayscale.

capx
Black To Alpha fx
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Sun Sep 16, 2012 6:36 pm

@Yann

Brilliant, mate! Never thought of applying the effect to the texture.
Thanks for going the extra mile with that black to alpha effect, however it's not necessary as the texture always will cover the whole screen.

Thanks again!

EDIT: Just applied it to the game, works like a charm ;)
Now I only need one type of object, and 10 times as less :Dsqiddster2012-09-16 18:45:03
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Sun Sep 16, 2012 11:33 pm

@Yann nice one, clever solution!
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544


Return to How do I....?

Who is online

Users browsing this forum: Mirlas, TELLES0808 and 20 guests