[[vertex]] uniform mat4 mvp; in vec4 pos; in vec2 uvs; out vec2 uv; void main() { uv = uvs; gl_Position = mvp * vec4(pos.xyz, 1.0); } [[fragment]] #include "include/ext-fb-fetch.glsl" #include "include/blend.glsl" uniform sampler2D tex; uniform sampler2D tex_bg; uniform highp float alpha; uniform int blend_mode; in highp vec2 uv; #if defined(GL_EXT_shader_framebuffer_fetch) inout highp vec4 frag; #else out highp vec4 frag; #endif void main() { // if available use the extension #if defined(GL_EXT_shader_framebuffer_fetch) highp vec4 bg = frag; #elif defined(GL_ARM_shader_framebuffer_fetch) highp vec4 bg = gl_LastFragColorARM; #else highp vec4 bg = texture(tex_bg, uv); #endif highp vec4 fg = texture(tex, uv); if (fg.a == 0.0) { frag = bg; return; } highp vec4 blended = blend(bg, fg, blend_mode); frag = vec4(blended.rgb, blended.a * alpha); }