Page 2 of 2

Re: Canvas and shader issue

Posted: Sat Nov 16, 2019 6:08 pm
by raidho36
Shaders use transparent pixels internally. You can return transparent pixels from shader by setting their alpha values (4th color component) to something smaller than 1.

Re: Canvas and shader issue

Posted: Sat Nov 16, 2019 6:22 pm
by pgimeno
Yeah, remember the last line I recommended? return vec4(c, 0., 0., 1.);

Using vec4(c, 0., 0., c) should give you as much opacity as intensity, which will probably work. Note however that it's not fully transparent near the borders where the shader is still being applied, so you may want to use some formula that makes it zero earlier, for example: return vec4(c, 0., 0., 1.1*c-0.1); or 1.2*c-0.2 or you can play with it until it's satisfactory. The first component could even be 1.0, letting blending do the work.

Re: Canvas and shader issue

Posted: Sun Nov 17, 2019 8:41 am
by Thorkal
Alright, thank you very much to you all, everything works fine now !