Help!? FX not quite working as expected

Post your work in progress addons and get feedback

Post » Tue Sep 09, 2014 7:20 pm


I am just getting into writing shaders and I really can't seem to figure out why this doesn't work... (I'm sure some of you may notice it is a modification of setcolor fx bundled with construct 2)

All I want to do is invert the alpha without messing with anything else, but that's not what happens. It works fine on one object but when you layer the objects or have different colored backgrounds it stops working:

// Flip Alpha effect
varying mediump vec2 vTex;
uniform lowp sampler2D samplerFront;
uniform lowp float red;
uniform lowp float green;
uniform lowp float blue;

void main(void)
lowp float a = texture2D(samplerFront, vTex).a;

lowp float r = texture2D(samplerFront, vTex).r;
lowp float g = texture2D(samplerFront, vTex).g;
lowp float b = texture2D(samplerFront, vTex).b;

gl_FragColor = vec4(r,g,b,1.0-a);


<?xml version="1.0" encoding="UTF-8" ?>
<!-- About -->
<id>flipalpha</id> <!-- Never change the ID. Change the name instead -->
<name>Flip Alpha</name>
<description>Invert Alpha Channel</description>

<!-- Settings -->

<!-- Extend the bounding box for effect processing by a number of pixels to show the edges
of effects which go beyond the object edges, e.g. blur and warp. -->

<!-- Set to true if the background is sampled (samplerBack is referenced at all in the shader) -->

<!-- Set to true if the background is not sampled at 1:1 with the foreground (e.g. the
background texture co-ordinates are modified in some way by the shader, as done
by Glass and Lens) -->

<!-- Set to true if the effect changes over time, e.g. Noise or Warp effects. -->

<!-- Parameters -->
<description>Red level to set, from 0 to 100.</description>
<description>Green level to set, from 0 to 100.</description>
<description>Blue level to set, from 0 to 100.</description>

Posts: 563
Reputation: 5,141

Return to Work in Progress Addons

Who is online

Users browsing this forum: No registered users and 0 guests