OpenGL ES Shader help (Blending)
- by Chris
Earlier I required assistance getting to grips with how to retain the alpha channel of a transparent texture in my colourised texture shader program.
Whilst playing with that first version of my program (before obtaining the solution to my first requirement), I managed to enable transparency for the whole texture (effectively blending via GLSL), and I quite liked this, and I would now like to know if and how it is possible to retain this blending effect, on top of the existing output without affecting the original alpha channel - as I don't know how to input this transparency via the parameter that is already being provided with the textures alpha channel.
A basic example of the blending program I am referring to (minus any other functionality) is as follows...
varying vec2 texCoord;
uniform sampler2D texSampler;
void main() {
gl_FragColor = vec4(texture2D(texSampler,texCoord).xyz,0.5);
}
Where 0.5 is the transparency (blending effect) of the whole texture.
This is the current version of my program, which provides the ability to colour a texture according the colour parameter passed to the program, and retains the alpha channel of the original texture.
varying vec2 texCoord;
uniform sampler2D texSampler;
uniform vec3 colour;
void main() {
gl_FragColor = vec4(colour,1)
* vec4(texture2D(texSampler,texCoord).xyz,texture2D(texSampler,texCoord).w);
}
I need to know if it is possible to apply transparency on top this program, without affecting the original alpha channel which I have already preserved.
I hope this makes enough sense, I am sure it is possible, and if so I should imagine it is rather simple, but this has me stumped. Any help much appreachiated.
Cheers, Chris