move shaders into .glsl files and add #include feature

This commit is contained in:
2019-02-21 19:26:40 +01:00
parent 16eb9de358
commit eaab9c79e5
47 changed files with 1124 additions and 777 deletions

View File

@@ -0,0 +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() {
#if defined(GL_EXT_shader_framebuffer_fetch)
highp vec4 bg = frag;
#elif defined(GL_ARM_shader_framebuffer_fetch)
highp vec4 bg = gl_LastFragColorARM;
#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; }
mediump vec4 blended = blend(bg, fg, blend_mode);
frag = vec4(blended.rgb, blended.a * alpha);
};