fix shaders format

This commit is contained in:
2019-02-21 21:51:55 +01:00
parent 78ca0ee6ad
commit 39ee7289c5
26 changed files with 390 additions and 176 deletions

View File

@@ -1,29 +1,38 @@
[[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_alpha;
uniform sampler2D tex_bg;
uniform mediump float alpha;
uniform int blend_mode;
in mediump vec2 uv;
#if defined(GL_EXT_shader_framebuffer_fetch)
inout highp vec4 frag;
#else
out mediump vec4 frag;
#endif
void main() {
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)
@@ -31,8 +40,13 @@ void main() {
#else
mediump vec4 bg = texture(tex_bg, uv);
#endif
mediump vec4 fg = vec4(texture(tex, uv).rgb, texture(tex_alpha, uv).a);
if (fg.a == 0.0) { frag = bg; return; }
if (fg.a == 0.0)
{
frag = bg;
return;
}
mediump vec4 blended = blend(bg, fg, blend_mode);
frag = vec4(blended.rgb, blended.a * alpha);
};
}