epfl-archive/cs440-acg/ext/nanogui/resources/imageview_fragment.gles
2022-04-07 18:46:57 +02:00

18 lines
574 B
Plaintext

precision highp float;
varying vec2 uv;
varying vec2 position_background;
uniform sampler2D image;
uniform vec4 background_color;
void main() {
vec2 frac = position_background - floor(position_background);
float checkerboard = ((frac.x > .5) == (frac.y > .5)) ? 0.4 : 0.5;
vec4 background = (1.0 - background_color.a) * vec4(vec3(checkerboard), 1.0) +
background_color.a * vec4(background_color.rgb, 1.0);
vec4 value = texture2D(image, uv);
gl_FragColor = (1.0 - value.a) * background + value.a * vec4(value.rgb, 1.0);
}