diff options
author | 2015-02-26 01:40:18 +0100 | |
---|---|---|
committer | 2015-02-26 01:40:18 +0100 | |
commit | eb8144a3bb8f5d443b5062b13e3e18b6b8e8c43c (patch) | |
tree | 0dbb6487e5cc7db623f2d9acd9d2db3efa792aca /src/osd/modules/opengl/shader | |
parent | 2c2994aeb52b700c206ca6c94513a92601097bdb (diff) |
Moved opengl related stuff to modules/opengl
Diffstat (limited to 'src/osd/modules/opengl/shader')
17 files changed, 586 insertions, 0 deletions
diff --git a/src/osd/modules/opengl/shader/genc.sh b/src/osd/modules/opengl/shader/genc.sh new file mode 100644 index 00000000000..2c676e62f9b --- /dev/null +++ b/src/osd/modules/opengl/shader/genc.sh @@ -0,0 +1,46 @@ +#! /bin/sh + +## +## VSH +## + +echo "const char glsl_general_vsh_src[] =" > glsl_general.vsh.c +sed -e 's/^/"/g' -e 's/$/\\n"/g' glsl_general.vsh >> glsl_general.vsh.c +echo ";" >> glsl_general.vsh.c + +## +## IDX16 FSH +## + +echo "const char glsl_plain_idx16_lut_fsh_src[] =" > glsl_plain_idx16_lut.fsh.c +sed -e 's/^/"/g' -e 's/$/\\n"/g' glsl_plain_idx16_lut.fsh >> glsl_plain_idx16_lut.fsh.c +echo ";" >> glsl_plain_idx16_lut.fsh.c + +echo "const char glsl_bilinear_idx16_lut_fsh_src[] =" > glsl_bilinear_idx16_lut.fsh.c +sed -e 's/^/"/g' -e 's/$/\\n"/g' glsl_bilinear_idx16_lut.fsh >> glsl_bilinear_idx16_lut.fsh.c +echo ";" >> glsl_bilinear_idx16_lut.fsh.c + +## +## RGB 32 FSH LUT +## + +echo "const char glsl_plain_rgb32_lut_fsh_src[] =" > glsl_plain_rgb32_lut.fsh.c +sed -e 's/^/"/g' -e 's/$/\\n"/g' glsl_plain_rgb32_lut.fsh >> glsl_plain_rgb32_lut.fsh.c +echo ";" >> glsl_plain_rgb32_lut.fsh.c + +echo "const char glsl_bilinear_rgb32_lut_fsh_src[] =" > glsl_bilinear_rgb32_lut.fsh.c +sed -e 's/^/"/g' -e 's/$/\\n"/g' glsl_bilinear_rgb32_lut.fsh >> glsl_bilinear_rgb32_lut.fsh.c +echo ";" >> glsl_bilinear_rgb32_lut.fsh.c + +## +## RGB 32 FSH DIRECT +## + +echo "const char glsl_plain_rgb32_dir_fsh_src[] =" > glsl_plain_rgb32_dir.fsh.c +sed -e 's/^/"/g' -e 's/$/\\n"/g' glsl_plain_rgb32_dir.fsh >> glsl_plain_rgb32_dir.fsh.c +echo ";" >> glsl_plain_rgb32_dir.fsh.c + +echo "const char glsl_bilinear_rgb32_dir_fsh_src[] =" > glsl_bilinear_rgb32_dir.fsh.c +sed -e 's/^/"/g' -e 's/$/\\n"/g' glsl_bilinear_rgb32_dir.fsh >> glsl_bilinear_rgb32_dir.fsh.c +echo ";" >> glsl_bilinear_rgb32_dir.fsh.c + diff --git a/src/osd/modules/opengl/shader/glsl_bilinear.vsh b/src/osd/modules/opengl/shader/glsl_bilinear.vsh new file mode 100644 index 00000000000..22df6221997 --- /dev/null +++ b/src/osd/modules/opengl/shader/glsl_bilinear.vsh @@ -0,0 +1,7 @@ + +void main() +{ + gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; + gl_Position = ftransform(); +} + diff --git a/src/osd/modules/opengl/shader/glsl_bilinear_idx16_lut.fsh b/src/osd/modules/opengl/shader/glsl_bilinear_idx16_lut.fsh new file mode 100644 index 00000000000..ef0030b7519 --- /dev/null +++ b/src/osd/modules/opengl/shader/glsl_bilinear_idx16_lut.fsh @@ -0,0 +1,55 @@ + +#pragma optimize (on) +#pragma debug (off) + +uniform sampler2D color_texture; +uniform sampler2D colortable_texture; +uniform vec2 colortable_sz; // ct size +uniform vec2 colortable_pow2_sz; // pow2 ct size +uniform vec2 color_texture_pow2_sz; // pow2 tex size + +vec4 lutTex2D(in vec2 texcoord) +{ + vec4 color_tex; + vec2 color_map_coord; + + // normalized texture coordinates .. + color_tex = texture2D(color_texture, texcoord); + + // GL_UNSIGNED_SHORT GL_ALPHA in ALPHA16 conversion: + // general: f = c / ((2*N)-1), c color bitfield, N number of bits + // ushort: c = ((2**16)-1)*f; + color_map_coord.x = floor( 65535.0 * color_tex.a + 0.5 ); + + // map it to the 2D lut table + color_map_coord.y = floor(color_map_coord.x/colortable_sz.x); + color_map_coord.x = mod(color_map_coord.x,colortable_sz.x); + + return texture2D(colortable_texture, (color_map_coord+vec2(0.5)) / colortable_pow2_sz); +} + +void main() +{ + vec2 xy = gl_TexCoord[0].st; + + // mix(x,y,a): x*(1-a) + y*a + // + // bilinear filtering includes 2 mix: + // + // pix1 = tex[x0][y0] * ( 1 - u_ratio ) + tex[x1][y0] * u_ratio + // pix2 = tex[x0][y1] * ( 1 - u_ratio ) + tex[x1][y1] * u_ratio + // fin = pix1 * ( 1 - v_ratio ) + pix2 * v_ratio + // + // so we can use the build in mix function for these 2 computations ;-) + // + vec2 uv_ratio = fract(xy*color_texture_pow2_sz); // xy*color_texture_pow2_sz - floor(xy*color_texture_pow2_sz); + vec2 one = 1.0/color_texture_pow2_sz; + + vec4 col1, col2; + + col1 = mix( lutTex2D(xy ), lutTex2D(xy + vec2(one.x, 0.0)), uv_ratio.x); + col2 = mix( lutTex2D(xy + vec2(0.0, one.y)), lutTex2D(xy + one ), uv_ratio.x); + + gl_FragColor = mix ( col1, col2, uv_ratio.y ); +} + diff --git a/src/osd/modules/opengl/shader/glsl_bilinear_idx16_lut.fsh.c b/src/osd/modules/opengl/shader/glsl_bilinear_idx16_lut.fsh.c new file mode 100644 index 00000000000..62844692cbe --- /dev/null +++ b/src/osd/modules/opengl/shader/glsl_bilinear_idx16_lut.fsh.c @@ -0,0 +1,57 @@ +const char glsl_bilinear_idx16_lut_fsh_src[] = +"\n" +"#pragma optimize (on)\n" +"#pragma debug (off)\n" +"\n" +"uniform sampler2D color_texture;\n" +"uniform sampler2D colortable_texture;\n" +"uniform vec2 colortable_sz; // ct size\n" +"uniform vec2 colortable_pow2_sz; // pow2 ct size\n" +"uniform vec2 color_texture_pow2_sz; // pow2 tex size\n" +"\n" +"vec4 lutTex2D(in vec2 texcoord)\n" +"{\n" +" vec4 color_tex;\n" +" vec2 color_map_coord;\n" +"\n" +" // normalized texture coordinates ..\n" +" color_tex = texture2D(color_texture, texcoord);\n" +"\n" +" // GL_UNSIGNED_SHORT GL_ALPHA in ALPHA16 conversion:\n" +" // general: f = c / ((2*N)-1), c color bitfield, N number of bits\n" +" // ushort: c = ((2**16)-1)*f;\n" +" color_map_coord.x = floor( 65535.0 * color_tex.a + 0.5 );\n" +"\n" +" // map it to the 2D lut table\n" +" color_map_coord.y = floor(color_map_coord.x/colortable_sz.x);\n" +" color_map_coord.x = mod(color_map_coord.x,colortable_sz.x);\n" +"\n" +" return texture2D(colortable_texture, (color_map_coord+vec2(0.5)) / colortable_pow2_sz);\n" +"}\n" +"\n" +"void main()\n" +"{\n" +" vec2 xy = gl_TexCoord[0].st;\n" +"\n" +" // mix(x,y,a): x*(1-a) + y*a\n" +" //\n" +" // bilinear filtering includes 2 mix:\n" +" //\n" +" // pix1 = tex[x0][y0] * ( 1 - u_ratio ) + tex[x1][y0] * u_ratio\n" +" // pix2 = tex[x0][y1] * ( 1 - u_ratio ) + tex[x1][y1] * u_ratio\n" +" // fin = pix1 * ( 1 - v_ratio ) + pix2 * v_ratio\n" +" //\n" +" // so we can use the build in mix function for these 2 computations ;-)\n" +" //\n" +" vec2 uv_ratio = fract(xy*color_texture_pow2_sz); // xy*color_texture_pow2_sz - floor(xy*color_texture_pow2_sz);\n" +" vec2 one = 1.0/color_texture_pow2_sz;\n" +"\n" +" vec4 col1, col2;\n" +"\n" +" col1 = mix( lutTex2D(xy ), lutTex2D(xy + vec2(one.x, 0.0)), uv_ratio.x);\n" +" col2 = mix( lutTex2D(xy + vec2(0.0, one.y)), lutTex2D(xy + one ), uv_ratio.x);\n" +"\n" +" gl_FragColor = mix ( col1, col2, uv_ratio.y );\n" +"}\n" +"\n" +; diff --git a/src/osd/modules/opengl/shader/glsl_bilinear_rgb32_dir.fsh b/src/osd/modules/opengl/shader/glsl_bilinear_rgb32_dir.fsh new file mode 100644 index 00000000000..c739c16934e --- /dev/null +++ b/src/osd/modules/opengl/shader/glsl_bilinear_rgb32_dir.fsh @@ -0,0 +1,54 @@ + +#pragma optimize (on) +#pragma debug (off) + +uniform sampler2D color_texture; +uniform vec2 color_texture_pow2_sz; // pow2 tex size +uniform vec4 vid_attributes; // gamma, contrast, brightness + +// #define DO_GAMMA 1 // 'pow' is very slow on old hardware, i.e. pre R600 and 'slow' in general + +#define TEX2D(v) texture2D(color_texture,(v)) + +void main() +{ + vec2 xy = gl_TexCoord[0].st; + + // mix(x,y,a): x*(1-a) + y*a + // + // bilinear filtering includes 2 mix: + // + // pix1 = tex[x0][y0] * ( 1 - u_ratio ) + tex[x1][y0] * u_ratio + // pix2 = tex[x0][y1] * ( 1 - u_ratio ) + tex[x1][y1] * u_ratio + // fin = pix1 * ( 1 - v_ratio ) + pix2 * v_ratio + // + // so we can use the build in mix function for these 2 computations ;-) + // + vec2 uv_ratio = fract(xy*color_texture_pow2_sz); // xy*color_texture_pow2_sz - floor(xy*color_texture_pow2_sz); + vec2 one = 1.0/color_texture_pow2_sz; + +#if 1 + vec4 col, col2; + + col = mix( TEX2D(xy ), TEX2D(xy + vec2(one.x, 0.0)), uv_ratio.x); + col2 = mix( TEX2D(xy + vec2(0.0, one.y)), TEX2D(xy + one ), uv_ratio.x); + col = mix ( col, col2, uv_ratio.y ); +#else + // doesn't work on MacOSX GLSL engine .. + // + vec4 col = mix ( mix( TEX2D(xy ), TEX2D(xy + vec2(one.x, 0.0)), uv_ratio.x), + mix( TEX2D(xy + vec2(0.0, one.y)), TEX2D(xy + one ), uv_ratio.x), uv_ratio.y ); +#endif + + // gamma, contrast, brightness equation from: rendutil.h / apply_brightness_contrast_gamma_fp + +#ifdef DO_GAMMA + // gamma/contrast/brightness + vec4 gamma = vec4(1.0 / vid_attributes.r, 1.0 / vid_attributes.r, 1.0 / vid_attributes.r, 0.0); + gl_FragColor = ( pow ( col, gamma ) * vid_attributes.g) + vid_attributes.b - 1.0; +#else + // contrast/brightness + gl_FragColor = ( col * vid_attributes.g) + vid_attributes.b - 1.0; +#endif +} + diff --git a/src/osd/modules/opengl/shader/glsl_bilinear_rgb32_dir.fsh.c b/src/osd/modules/opengl/shader/glsl_bilinear_rgb32_dir.fsh.c new file mode 100644 index 00000000000..d6265b8905b --- /dev/null +++ b/src/osd/modules/opengl/shader/glsl_bilinear_rgb32_dir.fsh.c @@ -0,0 +1,56 @@ +const char glsl_bilinear_rgb32_dir_fsh_src[] = +"\n" +"#pragma optimize (on)\n" +"#pragma debug (off)\n" +"\n" +"uniform sampler2D color_texture;\n" +"uniform vec2 color_texture_pow2_sz; // pow2 tex size\n" +"uniform vec4 vid_attributes; // gamma, contrast, brightness\n" +"\n" +"// #define DO_GAMMA 1 // 'pow' is very slow on old hardware, i.e. pre R600 and 'slow' in general\n" +"\n" +"#define TEX2D(v) texture2D(color_texture,(v))\n" +"\n" +"void main()\n" +"{\n" +" vec2 xy = gl_TexCoord[0].st;\n" +"\n" +" // mix(x,y,a): x*(1-a) + y*a\n" +" //\n" +" // bilinear filtering includes 2 mix:\n" +" //\n" +" // pix1 = tex[x0][y0] * ( 1 - u_ratio ) + tex[x1][y0] * u_ratio\n" +" // pix2 = tex[x0][y1] * ( 1 - u_ratio ) + tex[x1][y1] * u_ratio\n" +" // fin = pix1 * ( 1 - v_ratio ) + pix2 * v_ratio\n" +" //\n" +" // so we can use the build in mix function for these 2 computations ;-)\n" +" //\n" +" vec2 uv_ratio = fract(xy*color_texture_pow2_sz); // xy*color_texture_pow2_sz - floor(xy*color_texture_pow2_sz);\n" +" vec2 one = 1.0/color_texture_pow2_sz;\n" +"\n" +"#if 1\n" +" vec4 col, col2;\n" +"\n" +" col = mix( TEX2D(xy ), TEX2D(xy + vec2(one.x, 0.0)), uv_ratio.x);\n" +" col2 = mix( TEX2D(xy + vec2(0.0, one.y)), TEX2D(xy + one ), uv_ratio.x);\n" +" col = mix ( col, col2, uv_ratio.y );\n" +"#else\n" +" // doesn't work on MacOSX GLSL engine ..\n" +" //\n" +" vec4 col = mix ( mix( TEX2D(xy ), TEX2D(xy + vec2(one.x, 0.0)), uv_ratio.x),\n" +" mix( TEX2D(xy + vec2(0.0, one.y)), TEX2D(xy + one ), uv_ratio.x), uv_ratio.y );\n" +"#endif\n" +"\n" +" // gamma, contrast, brightness equation from: rendutil.h / apply_brightness_contrast_gamma_fp\n" +"\n" +"#ifdef DO_GAMMA\n" +" // gamma/contrast/brightness\n" +" vec4 gamma = vec4(1.0 / vid_attributes.r, 1.0 / vid_attributes.r, 1.0 / vid_attributes.r, 0.0);\n" +" gl_FragColor = ( pow ( col, gamma ) * vid_attributes.g) + vid_attributes.b - 1.0;\n" +"#else\n" +" // contrast/brightness\n" +" gl_FragColor = ( col * vid_attributes.g) + vid_attributes.b - 1.0;\n" +"#endif\n" +"}\n" +"\n" +; diff --git a/src/osd/modules/opengl/shader/glsl_bilinear_rgb32_lut.fsh b/src/osd/modules/opengl/shader/glsl_bilinear_rgb32_lut.fsh new file mode 100644 index 00000000000..d6c9f5e7f59 --- /dev/null +++ b/src/osd/modules/opengl/shader/glsl_bilinear_rgb32_lut.fsh @@ -0,0 +1,58 @@ + +#pragma optimize (on) +#pragma debug (off) + +uniform sampler2D color_texture; +uniform sampler2D colortable_texture; +uniform vec2 colortable_sz; // orig size +uniform vec2 colortable_pow2_sz; // pow2 ct size +uniform vec2 color_texture_pow2_sz; // pow2 tex size + +vec4 lutTex2D(in vec2 texcoord) +{ + vec4 color_tex; + vec2 color_map_coord; + vec4 color0; + float colortable_scale = (colortable_sz.x/3.0) / colortable_pow2_sz.x; + + // normalized texture coordinates .. + color_tex = texture2D(color_texture, texcoord) * ((colortable_sz.x/3.0)-1.0)/colortable_pow2_sz.x;// lookup space + + color_map_coord.x = color_tex.b; + color0.b = texture2D(colortable_texture, color_map_coord).b; + + color_map_coord.x = color_tex.g + colortable_scale; + color0.g = texture2D(colortable_texture, color_map_coord).g; + + color_map_coord.x = color_tex.r + 2.0 * colortable_scale; + color0.r = texture2D(colortable_texture, color_map_coord).r; + + return color0; +} + +void main() +{ + vec2 xy = gl_TexCoord[0].st; + + // mix(x,y,a): x*(1-a) + y*a + // + // bilinear filtering includes 2 mix: + // + // pix1 = tex[x0][y0] * ( 1 - u_ratio ) + tex[x1][y0] * u_ratio + // pix2 = tex[x0][y1] * ( 1 - u_ratio ) + tex[x1][y1] * u_ratio + // fin = pix1 * ( 1 - v_ratio ) + pix2 * v_ratio + // + // so we can use the build in mix function for these 2 computations ;-) + // + vec2 uv_ratio = fract(xy*color_texture_pow2_sz); // xy*color_texture_pow2_sz - floor(xy*color_texture_pow2_sz); + vec2 one = 1.0/color_texture_pow2_sz; + + vec4 col1, col2; + + col1 = mix( lutTex2D(xy ), lutTex2D(xy + vec2(one.x, 0.0)), uv_ratio.x); + col2 = mix( lutTex2D(xy + vec2(0.0, one.y)), lutTex2D(xy + one ), uv_ratio.x); + + gl_FragColor = mix ( col1, col2, uv_ratio.y ); +} + + diff --git a/src/osd/modules/opengl/shader/glsl_bilinear_rgb32_lut.fsh.c b/src/osd/modules/opengl/shader/glsl_bilinear_rgb32_lut.fsh.c new file mode 100644 index 00000000000..a5a67bdbf94 --- /dev/null +++ b/src/osd/modules/opengl/shader/glsl_bilinear_rgb32_lut.fsh.c @@ -0,0 +1,60 @@ +const char glsl_bilinear_rgb32_lut_fsh_src[] = +"\n" +"#pragma optimize (on)\n" +"#pragma debug (off)\n" +"\n" +"uniform sampler2D color_texture;\n" +"uniform sampler2D colortable_texture;\n" +"uniform vec2 colortable_sz; // orig size\n" +"uniform vec2 colortable_pow2_sz; // pow2 ct size\n" +"uniform vec2 color_texture_pow2_sz; // pow2 tex size\n" +"\n" +"vec4 lutTex2D(in vec2 texcoord)\n" +"{\n" +" vec4 color_tex;\n" +" vec2 color_map_coord;\n" +" vec4 color0;\n" +" float colortable_scale = (colortable_sz.x/3.0) / colortable_pow2_sz.x;\n" +"\n" +" // normalized texture coordinates ..\n" +" color_tex = texture2D(color_texture, texcoord) * ((colortable_sz.x/3.0)-1.0)/colortable_pow2_sz.x;// lookup space \n" +"\n" +" color_map_coord.x = color_tex.b;\n" +" color0.b = texture2D(colortable_texture, color_map_coord).b;\n" +"\n" +" color_map_coord.x = color_tex.g + colortable_scale;\n" +" color0.g = texture2D(colortable_texture, color_map_coord).g;\n" +"\n" +" color_map_coord.x = color_tex.r + 2.0 * colortable_scale;\n" +" color0.r = texture2D(colortable_texture, color_map_coord).r;\n" +"\n" +" return color0;\n" +"}\n" +"\n" +"void main()\n" +"{\n" +" vec2 xy = gl_TexCoord[0].st;\n" +"\n" +" // mix(x,y,a): x*(1-a) + y*a\n" +" //\n" +" // bilinear filtering includes 2 mix:\n" +" //\n" +" // pix1 = tex[x0][y0] * ( 1 - u_ratio ) + tex[x1][y0] * u_ratio\n" +" // pix2 = tex[x0][y1] * ( 1 - u_ratio ) + tex[x1][y1] * u_ratio\n" +" // fin = pix1 * ( 1 - v_ratio ) + pix2 * v_ratio\n" +" //\n" +" // so we can use the build in mix function for these 2 computations ;-)\n" +" //\n" +" vec2 uv_ratio = fract(xy*color_texture_pow2_sz); // xy*color_texture_pow2_sz - floor(xy*color_texture_pow2_sz);\n" +" vec2 one = 1.0/color_texture_pow2_sz;\n" +"\n" +" vec4 col1, col2;\n" +"\n" +" col1 = mix( lutTex2D(xy ), lutTex2D(xy + vec2(one.x, 0.0)), uv_ratio.x);\n" +" col2 = mix( lutTex2D(xy + vec2(0.0, one.y)), lutTex2D(xy + one ), uv_ratio.x);\n" +"\n" +" gl_FragColor = mix ( col1, col2, uv_ratio.y );\n" +"}\n" +"\n" +"\n" +; diff --git a/src/osd/modules/opengl/shader/glsl_general.vsh b/src/osd/modules/opengl/shader/glsl_general.vsh new file mode 100644 index 00000000000..22df6221997 --- /dev/null +++ b/src/osd/modules/opengl/shader/glsl_general.vsh @@ -0,0 +1,7 @@ + +void main() +{ + gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; + gl_Position = ftransform(); +} + diff --git a/src/osd/modules/opengl/shader/glsl_general.vsh.c b/src/osd/modules/opengl/shader/glsl_general.vsh.c new file mode 100644 index 00000000000..d0bf6eb8a68 --- /dev/null +++ b/src/osd/modules/opengl/shader/glsl_general.vsh.c @@ -0,0 +1,9 @@ +const char glsl_general_vsh_src[] = +"\n" +"void main()\n" +"{\n" +" gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;\n" +" gl_Position = ftransform();\n" +"}\n" +"\n" +; diff --git a/src/osd/modules/opengl/shader/glsl_plain.vsh b/src/osd/modules/opengl/shader/glsl_plain.vsh new file mode 100644 index 00000000000..22df6221997 --- /dev/null +++ b/src/osd/modules/opengl/shader/glsl_plain.vsh @@ -0,0 +1,7 @@ + +void main() +{ + gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; + gl_Position = ftransform(); +} + diff --git a/src/osd/modules/opengl/shader/glsl_plain_idx16_lut.fsh b/src/osd/modules/opengl/shader/glsl_plain_idx16_lut.fsh new file mode 100644 index 00000000000..465aa610d59 --- /dev/null +++ b/src/osd/modules/opengl/shader/glsl_plain_idx16_lut.fsh @@ -0,0 +1,30 @@ + +#pragma optimize (on) +#pragma debug (off) + +uniform sampler2D color_texture; +uniform sampler2D colortable_texture; +uniform vec2 colortable_sz; // ct size +uniform vec2 colortable_pow2_sz; // pow2 ct size + +void main() +{ + vec4 color_tex; + vec2 color_map_coord; + + // normalized texture coordinates .. + color_tex = texture2D(color_texture, gl_TexCoord[0].st); + + // GL_UNSIGNED_SHORT GL_ALPHA in ALPHA16 conversion: + // general: f = c / ((2*N)-1), c color bitfield, N number of bits + // ushort: c = ((2**16)-1)*f; + color_map_coord.x = floor( 65535.0 * color_tex.a + 0.5 ); + + // map it to the 2D lut table + color_map_coord.y = floor(color_map_coord.x/colortable_sz.x); + color_map_coord.x = mod(color_map_coord.x,colortable_sz.x); + + gl_FragColor = texture2D(colortable_texture, (color_map_coord+vec2(0.5)) / colortable_pow2_sz); +} + + diff --git a/src/osd/modules/opengl/shader/glsl_plain_idx16_lut.fsh.c b/src/osd/modules/opengl/shader/glsl_plain_idx16_lut.fsh.c new file mode 100644 index 00000000000..f9f18b615e6 --- /dev/null +++ b/src/osd/modules/opengl/shader/glsl_plain_idx16_lut.fsh.c @@ -0,0 +1,32 @@ +const char glsl_plain_idx16_lut_fsh_src[] = +"\n" +"#pragma optimize (on)\n" +"#pragma debug (off)\n" +"\n" +"uniform sampler2D color_texture;\n" +"uniform sampler2D colortable_texture;\n" +"uniform vec2 colortable_sz; // ct size\n" +"uniform vec2 colortable_pow2_sz; // pow2 ct size\n" +"\n" +"void main()\n" +"{\n" +" vec4 color_tex;\n" +" vec2 color_map_coord;\n" +"\n" +" // normalized texture coordinates ..\n" +" color_tex = texture2D(color_texture, gl_TexCoord[0].st);\n" +"\n" +" // GL_UNSIGNED_SHORT GL_ALPHA in ALPHA16 conversion:\n" +" // general: f = c / ((2*N)-1), c color bitfield, N number of bits\n" +" // ushort: c = ((2**16)-1)*f;\n" +" color_map_coord.x = floor( 65535.0 * color_tex.a + 0.5 );\n" +"\n" +" // map it to the 2D lut table\n" +" color_map_coord.y = floor(color_map_coord.x/colortable_sz.x);\n" +" color_map_coord.x = mod(color_map_coord.x,colortable_sz.x);\n" +"\n" +" gl_FragColor = texture2D(colortable_texture, (color_map_coord+vec2(0.5)) / colortable_pow2_sz);\n" +"}\n" +"\n" +"\n" +; diff --git a/src/osd/modules/opengl/shader/glsl_plain_rgb32_dir.fsh b/src/osd/modules/opengl/shader/glsl_plain_rgb32_dir.fsh new file mode 100644 index 00000000000..0e5a4605ac8 --- /dev/null +++ b/src/osd/modules/opengl/shader/glsl_plain_rgb32_dir.fsh @@ -0,0 +1,24 @@ + +#pragma optimize (on) +#pragma debug (off) + +uniform sampler2D color_texture; +uniform vec4 vid_attributes; // gamma, contrast, brightness + +// #define DO_GAMMA 1 // 'pow' is very slow on old hardware, i.e. pre R600 and 'slow' in general + +void main() +{ +#ifdef DO_GAMMA + vec4 gamma = vec4( 1.0 / vid_attributes.r, 1.0 / vid_attributes.r, 1.0 / vid_attributes.r, 0.0); + + // gamma, contrast, brightness equation from: rendutil.h / apply_brightness_contrast_gamma_fp + vec4 color = pow( texture2D(color_texture, gl_TexCoord[0].st) , gamma); +#else + vec4 color = texture2D(color_texture, gl_TexCoord[0].st); +#endif + + // contrast/brightness + gl_FragColor = (color * vid_attributes.g) + vid_attributes.b - 1.0; +} + diff --git a/src/osd/modules/opengl/shader/glsl_plain_rgb32_dir.fsh.c b/src/osd/modules/opengl/shader/glsl_plain_rgb32_dir.fsh.c new file mode 100644 index 00000000000..1e206d671cd --- /dev/null +++ b/src/osd/modules/opengl/shader/glsl_plain_rgb32_dir.fsh.c @@ -0,0 +1,26 @@ +const char glsl_plain_rgb32_dir_fsh_src[] = +"\n" +"#pragma optimize (on)\n" +"#pragma debug (off)\n" +"\n" +"uniform sampler2D color_texture;\n" +"uniform vec4 vid_attributes; // gamma, contrast, brightness\n" +"\n" +"// #define DO_GAMMA 1 // 'pow' is very slow on old hardware, i.e. pre R600 and 'slow' in general\n" +"\n" +"void main()\n" +"{\n" +"#ifdef DO_GAMMA\n" +" vec4 gamma = vec4( 1.0 / vid_attributes.r, 1.0 / vid_attributes.r, 1.0 / vid_attributes.r, 0.0);\n" +"\n" +" // gamma, contrast, brightness equation from: rendutil.h / apply_brightness_contrast_gamma_fp\n" +" vec4 color = pow( texture2D(color_texture, gl_TexCoord[0].st) , gamma);\n" +"#else\n" +" vec4 color = texture2D(color_texture, gl_TexCoord[0].st);\n" +"#endif\n" +"\n" +" // contrast/brightness\n" +" gl_FragColor = (color * vid_attributes.g) + vid_attributes.b - 1.0;\n" +"}\n" +"\n" +; diff --git a/src/osd/modules/opengl/shader/glsl_plain_rgb32_lut.fsh b/src/osd/modules/opengl/shader/glsl_plain_rgb32_lut.fsh new file mode 100644 index 00000000000..14c05aaa844 --- /dev/null +++ b/src/osd/modules/opengl/shader/glsl_plain_rgb32_lut.fsh @@ -0,0 +1,28 @@ + +#pragma optimize (on) +#pragma debug (off) + +uniform sampler2D color_texture; +uniform sampler2D colortable_texture; +uniform vec2 colortable_sz; // orig size for full bgr +uniform vec2 colortable_pow2_sz; // orig size for full bgr + +void main() +{ + vec4 color_tex; + vec2 color_map_coord; + float colortable_scale = (colortable_sz.x/3.0) / colortable_pow2_sz.x; + + // normalized texture coordinates .. + color_tex = texture2D(color_texture, gl_TexCoord[0].st) * ((colortable_sz.x/3.0)-1.0)/colortable_pow2_sz.x;// lookup space + + color_map_coord.x = color_tex.b; + gl_FragColor.b = texture2D(colortable_texture, color_map_coord).b; + + color_map_coord.x = color_tex.g + colortable_scale; + gl_FragColor.g = texture2D(colortable_texture, color_map_coord).g; + + color_map_coord.x = color_tex.r + 2.0 * colortable_scale; + gl_FragColor.r = texture2D(colortable_texture, color_map_coord).r; +} + diff --git a/src/osd/modules/opengl/shader/glsl_plain_rgb32_lut.fsh.c b/src/osd/modules/opengl/shader/glsl_plain_rgb32_lut.fsh.c new file mode 100644 index 00000000000..d1263ea6864 --- /dev/null +++ b/src/osd/modules/opengl/shader/glsl_plain_rgb32_lut.fsh.c @@ -0,0 +1,30 @@ +const char glsl_plain_rgb32_lut_fsh_src[] = +"\n" +"#pragma optimize (on)\n" +"#pragma debug (off)\n" +"\n" +"uniform sampler2D color_texture;\n" +"uniform sampler2D colortable_texture;\n" +"uniform vec2 colortable_sz; // orig size for full bgr\n" +"uniform vec2 colortable_pow2_sz; // orig size for full bgr\n" +"\n" +"void main()\n" +"{\n" +" vec4 color_tex;\n" +" vec2 color_map_coord;\n" +" float colortable_scale = (colortable_sz.x/3.0) / colortable_pow2_sz.x;\n" +"\n" +" // normalized texture coordinates ..\n" +" color_tex = texture2D(color_texture, gl_TexCoord[0].st) * ((colortable_sz.x/3.0)-1.0)/colortable_pow2_sz.x;// lookup space \n" +"\n" +" color_map_coord.x = color_tex.b;\n" +" gl_FragColor.b = texture2D(colortable_texture, color_map_coord).b;\n" +"\n" +" color_map_coord.x = color_tex.g + colortable_scale;\n" +" gl_FragColor.g = texture2D(colortable_texture, color_map_coord).g;\n" +"\n" +" color_map_coord.x = color_tex.r + 2.0 * colortable_scale;\n" +" gl_FragColor.r = texture2D(colortable_texture, color_map_coord).r;\n" +"}\n" +"\n" +; |