implement framebuffer fetch on iOS for bleding

This commit is contained in:
2019-01-08 11:02:07 +01:00
parent 71f79a7fa0
commit 4a1880e22a
2 changed files with 20 additions and 3 deletions

View File

@@ -85,16 +85,27 @@ void App::initShaders()
"}\n";
static const char* shader_blend_f =
SHADER_VERSION
#ifdef __IOS__
"#extension GL_EXT_shader_framebuffer_fetch : enable\n"
#endif
"uniform sampler2D tex;\n"
"uniform sampler2D tex_alpha;\n"
"uniform sampler2D tex_bg;\n"
"uniform mediump float alpha;\n"
"uniform int blend_mode;\n"
"in mediump vec2 uv;\n"
#ifdef __IOS__
"inout mediump vec4 frag;\n"
#else
"out mediump vec4 frag;\n"
#endif
SHADER_FUNCTION_BLEND
"void main() {\n"
#ifdef __IOS__
" mediump vec4 bg = frag;\n"
#else
" mediump vec4 bg = texture(tex_bg, uv);\n"
#endif
" mediump vec4 fg = vec4(texture(tex, uv).rgb, texture(tex_alpha, uv).a);\n"
" if (fg.a == 0.0) { frag = bg; return; }\n"
" mediump float contribution = (1.0 - bg.a) * fg.a;\n"
@@ -338,7 +349,6 @@ void App::initShaders()
SHADER_VERSION
#ifdef __IOS__
"#extension GL_EXT_shader_framebuffer_fetch : enable\n"
// "#extension GL_EXT_shader_image_load_store : enable\n"
#endif
"uniform mediump sampler2D tex;\n"
"uniform mediump sampler2D tex_bg;\n"