Pixel-Composer/shaders/sh_combine_rgb/sh_combine_rgb.fsh

38 lines
981 B
Plaintext
Raw Normal View History

2022-12-27 04:00:50 +01:00
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
2023-01-01 02:06:02 +01:00
uniform int mode;
uniform sampler2D samplerR;
uniform sampler2D samplerG;
uniform sampler2D samplerB;
uniform sampler2D samplerA;
2023-01-01 02:06:02 +01:00
2023-11-27 11:40:28 +01:00
uniform int useR;
uniform int useG;
uniform int useB;
uniform int useA;
2023-12-23 09:39:55 +01:00
uniform vec2 base;
uniform int baseUseSurf;
uniform sampler2D baseSurf;
float sample(vec4 col, int ch) {
2023-11-28 09:42:22 +01:00
if(mode == 0) return (col[0] + col[1] + col[2]) / 3. * col[3];
2023-01-01 02:06:02 +01:00
return col[ch];
}
2022-12-27 04:00:50 +01:00
void main() {
2023-12-23 09:39:55 +01:00
float bse = base.x;
if(baseUseSurf == 1) {
vec4 _vMap = texture2D( baseSurf, v_vTexcoord );
bse = mix(base.x, base.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
}
float r = (useR == 1)? sample(texture2D( samplerR, v_vTexcoord ), 0) : bse;
float g = (useG == 1)? sample(texture2D( samplerG, v_vTexcoord ), 1) : bse;
float b = (useB == 1)? sample(texture2D( samplerB, v_vTexcoord ), 2) : bse;
2023-11-27 11:40:28 +01:00
float a = (useA == 1)? sample(texture2D( samplerA, v_vTexcoord ), 3) : 1.;
2022-12-27 04:00:50 +01:00
2023-01-01 02:06:02 +01:00
gl_FragColor = vec4(r, g, b, a);
2022-12-27 04:00:50 +01:00
}