mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-26 06:56:45 +01:00
29 lines
710 B
GLSL
29 lines
710 B
GLSL
//
|
|
// Simple passthrough fragment shader
|
|
//
|
|
varying vec2 v_vTexcoord;
|
|
varying vec4 v_vColour;
|
|
|
|
uniform sampler2D mask;
|
|
uniform int useMask;
|
|
uniform int invMask;
|
|
|
|
uniform sampler2D original;
|
|
uniform sampler2D edited;
|
|
uniform float mixRatio;
|
|
|
|
void main() {
|
|
vec4 msk = texture2D( mask, v_vTexcoord );
|
|
vec4 ori = texture2D( original, v_vTexcoord );
|
|
vec4 edt = texture2D( edited, v_vTexcoord );
|
|
|
|
float mskAmo = (msk.r + msk.g + msk.b) / 3. * msk.a;
|
|
if(invMask == 1) mskAmo = 1. - mskAmo;
|
|
|
|
float rat = (useMask == 1? mskAmo : 1.) * mixRatio;
|
|
rat = clamp(rat, 0., 1.);
|
|
|
|
gl_FragColor = mix(ori, edt, rat);
|
|
if(ori.a == 0.) gl_FragColor.rgb = edt.rgb;
|
|
if(edt.a == 0.) gl_FragColor.rgb = ori.rgb;
|
|
}
|