[SOLVED] Canvas and shader issue

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Canvas and shader issue

Post 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.
User avatar
pgimeno
Party member
Posts: 3655
Joined: Sun Oct 18, 2015 2:58 pm

Re: Canvas and shader issue

Post 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.
Thorkal
Prole
Posts: 11
Joined: Tue Aug 06, 2019 4:42 pm

Re: Canvas and shader issue

Post by Thorkal »

Alright, thank you very much to you all, everything works fine now !
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Majestic-12 [Bot] and 2 guests