color management

This commit is contained in:
Devin Bayer 2020-07-14 17:01:25 +00:00
parent 842df2bd6c
commit 10bf68b928
13 changed files with 401 additions and 59 deletions

View file

@ -56,33 +56,51 @@ const GLchar tex_vertex_src[] =
" }\n"
"}\n";
const GLchar tex_fragment_src_rgba[] =
static const GLchar tex_fragment_head[] =
"#extension GL_OES_texture_3D : require\n"
"\n"
"precision mediump float;\n"
"varying vec2 v_texcoord;\n"
"uniform sampler2D tex;\n"
"uniform float alpha;\n"
"\n"
"void main() {\n"
" gl_FragColor = texture2D(tex, v_texcoord) * alpha;\n"
"}\n";
"uniform float alpha;\n";
const GLchar tex_fragment_src_rgbx[] =
"precision mediump float;\n"
"varying vec2 v_texcoord;\n"
"uniform sampler2D tex;\n"
"uniform float alpha;\n"
static const GLchar tex_fragment_util[] =
"uniform mediump sampler3D color_table;\n"
"uniform bool color_enable;\n"
"#define offset " COLOR_OFFSET "\n"
"\n"
"void main() {\n"
" gl_FragColor = vec4(texture2D(tex, v_texcoord).rgb, 1.0) * alpha;\n"
"}\n";
"#ifdef GL_OES_texture_3D\n"
"vec4 lookup(vec4 c) {\n"
" if(! color_enable)\n"
" return c;\n"
" vec4 m = texture3D(color_table, offset + c.rgb * (1.0 - offset*2.0));\n"
" return vec4(m.rgb, c.a);\n"
"}\n"
"#else\n"
"#define lookup(c) c\n"
"#endif\n"
;
const GLchar tex_fragment_src_external[] =
"#extension GL_OES_EGL_image_external : require\n\n"
"precision mediump float;\n"
"varying vec2 v_texcoord;\n"
"uniform samplerExternalOES texture0;\n"
"uniform float alpha;\n"
"\n"
"void main() {\n"
" gl_FragColor = texture2D(texture0, v_texcoord) * alpha;\n"
"}\n";
struct wlr_gles2_tex_shader tex_fragment_src_rgba = {
.head = tex_fragment_head,
.util = tex_fragment_util,
.main = "gl_FragColor = lookup(texture2D(tex, v_texcoord)) * alpha;"
};
struct wlr_gles2_tex_shader tex_fragment_src_rgbx = {
.head = tex_fragment_head,
.util = tex_fragment_util,
.main = "gl_FragColor = lookup(vec4(texture2D(tex, v_texcoord).rgb, 1.0)) * alpha;"
};
struct wlr_gles2_tex_shader tex_fragment_src_external = {
.head = "#extension GL_OES_EGL_image_external : require\n"
"#extension GL_OES_texture_3D : enable\n"
"\n"
"precision mediump float;\n"
"varying vec2 v_texcoord;\n"
"uniform samplerExternalOES texture0;\n"
"uniform float alpha;\n",
.util = tex_fragment_util,
.main = "gl_FragColor = lookup(texture2D(texture0, v_texcoord)) * alpha;\n"
};