mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-21 23:29:59 +01:00
31 lines
1007 B
GLSL
31 lines
1007 B
GLSL
#version 330 core
|
|
|
|
out vec4 FragColor;
|
|
|
|
in vec4 vertexColor;
|
|
in vec2 vertexUV;
|
|
|
|
uniform sampler2D iChannel0; // input channel (texture id).
|
|
uniform sampler2D iChannel1; // input mask
|
|
uniform vec3 iResolution; // viewport resolution (in pixels)
|
|
|
|
uniform vec4 color;
|
|
uniform float stipple;
|
|
|
|
void main()
|
|
{
|
|
// color is a mix of texture (manipulated with brightness & contrast), vertex and uniform colors
|
|
vec4 textureColor = texture(iChannel0, vertexUV);
|
|
vec3 RGB = textureColor.rgb * vertexColor.rgb * color.rgb;
|
|
|
|
// alpha is a mix of texture alpha, vertex alpha, and uniform alpha affected by stippling
|
|
vec4 maskColor = texture(iChannel1, vertexUV);
|
|
float maskIntensity = (maskColor.r + maskColor.g + maskColor.b) / 3.0;
|
|
|
|
float A = textureColor.a * vertexColor.a * color.a * maskIntensity;
|
|
A -= stipple * ( int(gl_FragCoord.x + gl_FragCoord.y) % 2 > 0 ? 0.05 : 0.95 );
|
|
|
|
// output RGBA
|
|
FragColor = vec4(RGB, clamp(A, 0.0, 1.0) );
|
|
}
|