mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-01 06:01:04 +00:00
[418/906] effects: disable gst-indent in the sources
Fix some crazy formatting caused by gst-indent previous runs and disable the script for this file. The best would be to move shaders into separate files and load them at runtime or hardcode them at compile time.
This commit is contained in:
parent
e42b3eddbf
commit
4ff22b2c67
1 changed files with 367 additions and 320 deletions
|
@ -24,417 +24,464 @@
|
||||||
/* A common file for sources is needed since shader sources can be
|
/* A common file for sources is needed since shader sources can be
|
||||||
* generic and reused by several effects */
|
* generic and reused by several effects */
|
||||||
|
|
||||||
|
/* FIXME */
|
||||||
|
/* Move sooner or later into single .frag .vert files and either bake
|
||||||
|
* them into a c file at compile time or load them at run time */
|
||||||
|
|
||||||
|
/* *INDENT-OFF* */
|
||||||
|
|
||||||
/* Vertex shader */
|
/* Vertex shader */
|
||||||
const gchar *vertex_shader_source =
|
const gchar *vertex_shader_source =
|
||||||
"attribute vec4 a_position;"
|
"attribute vec4 a_position;"
|
||||||
"attribute vec2 a_texCoord;"
|
"attribute vec2 a_texCoord;"
|
||||||
"varying vec2 v_texCoord;"
|
"varying vec2 v_texCoord;"
|
||||||
"void main()"
|
"void main()"
|
||||||
"{"
|
"{"
|
||||||
" gl_Position = a_position;"
|
" gl_Position = a_position;"
|
||||||
" v_texCoord = a_texCoord;"
|
" v_texCoord = a_texCoord;"
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
/* Identity effect */
|
/* Identity effect */
|
||||||
const gchar *identity_fragment_source =
|
const gchar *identity_fragment_source =
|
||||||
"precision mediump float;"
|
"precision mediump float;"
|
||||||
"varying vec2 v_texCoord;"
|
"varying vec2 v_texCoord;"
|
||||||
"uniform sampler2D tex;"
|
"uniform sampler2D tex;"
|
||||||
"void main()"
|
"void main()"
|
||||||
"{"
|
"{"
|
||||||
" gl_FragColor = texture2D(tex, v_texCoord);"
|
" gl_FragColor = texture2D(tex, v_texCoord);"
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
/* Mirror effect */
|
/* Mirror effect */
|
||||||
const gchar *mirror_fragment_source =
|
const gchar *mirror_fragment_source =
|
||||||
#ifndef OPENGL_ES2
|
#ifndef OPENGL_ES2
|
||||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||||
"uniform sampler2DRect tex;"
|
"uniform sampler2DRect tex;"
|
||||||
"uniform float width, height;"
|
"uniform float width, height;"
|
||||||
#else
|
#else
|
||||||
"precision mediump float;"
|
"precision mediump float;"
|
||||||
"varying vec2 v_texCoord;"
|
"varying vec2 v_texCoord;"
|
||||||
"uniform sampler2D tex;"
|
"uniform sampler2D tex;"
|
||||||
#endif
|
#endif
|
||||||
"void main () {"
|
"void main () {"
|
||||||
#ifndef OPENGL_ES2
|
#ifndef OPENGL_ES2
|
||||||
" vec2 tex_size = vec2 (width, height);"
|
" vec2 tex_size = vec2 (width, height);"
|
||||||
" vec2 texturecoord = gl_TexCoord[0].xy;"
|
" vec2 texturecoord = gl_TexCoord[0].xy;"
|
||||||
" vec2 normcoord;"
|
" vec2 normcoord;"
|
||||||
" normcoord = texturecoord / tex_size - 1.0;"
|
" normcoord = texturecoord / tex_size - 1.0;"
|
||||||
" normcoord.x *= sign (normcoord.x);"
|
" normcoord.x *= sign (normcoord.x);"
|
||||||
" texturecoord = (normcoord + 1.0) * tex_size;"
|
" texturecoord = (normcoord + 1.0) * tex_size;"
|
||||||
" vec4 color = texture2DRect (tex, texturecoord);"
|
" vec4 color = texture2DRect (tex, texturecoord);"
|
||||||
" gl_FragColor = color * gl_Color;"
|
" gl_FragColor = color * gl_Color;"
|
||||||
#else
|
#else
|
||||||
" vec2 texturecoord = v_texCoord.xy;"
|
" vec2 texturecoord = v_texCoord.xy;"
|
||||||
" float normcoord = texturecoord.x - 0.5;"
|
" float normcoord = texturecoord.x - 0.5;"
|
||||||
" normcoord *= sign (normcoord);"
|
" normcoord *= sign (normcoord);"
|
||||||
" texturecoord.x = (normcoord + 0.5);"
|
" texturecoord.x = (normcoord + 0.5);"
|
||||||
" gl_FragColor = texture2D (tex, texturecoord);"
|
" gl_FragColor = texture2D (tex, texturecoord);"
|
||||||
#endif
|
#endif
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
|
|
||||||
/* Squeeze effect */
|
/* Squeeze effect */
|
||||||
const gchar *squeeze_fragment_source =
|
const gchar *squeeze_fragment_source =
|
||||||
#ifndef OPENGL_ES2
|
#ifndef OPENGL_ES2
|
||||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||||
"uniform sampler2DRect tex;"
|
"uniform sampler2DRect tex;"
|
||||||
"uniform float width, height;"
|
"uniform float width, height;"
|
||||||
#else
|
#else
|
||||||
"precision mediump float;"
|
"precision mediump float;"
|
||||||
"varying vec2 v_texCoord;"
|
"varying vec2 v_texCoord;"
|
||||||
"uniform sampler2D tex;"
|
"uniform sampler2D tex;"
|
||||||
#endif
|
#endif
|
||||||
"void main () {"
|
"void main () {"
|
||||||
#ifndef OPENGL_ES2
|
#ifndef OPENGL_ES2
|
||||||
" vec2 tex_size = vec2 (width, height);"
|
" vec2 tex_size = vec2 (width, height);"
|
||||||
" vec2 texturecoord = gl_TexCoord[0].xy;"
|
" vec2 texturecoord = gl_TexCoord[0].xy;"
|
||||||
" vec2 normcoord;"
|
" vec2 normcoord;"
|
||||||
" normcoord = texturecoord / tex_size - 1.0; "
|
" normcoord = texturecoord / tex_size - 1.0; "
|
||||||
" float r = length (normcoord);"
|
" float r = length (normcoord);"
|
||||||
" r = pow(r, 0.40)*1.3;"
|
" r = pow(r, 0.40)*1.3;"
|
||||||
" normcoord = normcoord / r;"
|
" normcoord = normcoord / r;"
|
||||||
" texturecoord = (normcoord + 1.0) * tex_size;"
|
" texturecoord = (normcoord + 1.0) * tex_size;"
|
||||||
" vec4 color = texture2DRect (tex, texturecoord); "
|
" vec4 color = texture2DRect (tex, texturecoord); "
|
||||||
" gl_FragColor = color * gl_Color;"
|
" gl_FragColor = color * gl_Color;"
|
||||||
#else
|
#else
|
||||||
" vec2 texturecoord = v_texCoord.xy;"
|
" vec2 texturecoord = v_texCoord.xy;"
|
||||||
" vec2 normcoord = texturecoord - 0.5;"
|
" vec2 normcoord = texturecoord - 0.5;"
|
||||||
" float r = length (normcoord);"
|
" float r = length (normcoord);"
|
||||||
" r = pow(r, 0.40)*1.3;"
|
" r = pow(r, 0.40)*1.3;"
|
||||||
" normcoord = normcoord / r;"
|
" normcoord = normcoord / r;"
|
||||||
" texturecoord = (normcoord + 0.5);"
|
" texturecoord = (normcoord + 0.5);"
|
||||||
" gl_FragColor = texture2D (tex, texturecoord);"
|
" gl_FragColor = texture2D (tex, texturecoord);"
|
||||||
#endif
|
#endif
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
|
|
||||||
/* Stretch Effect */
|
/* Stretch Effect */
|
||||||
const gchar *stretch_fragment_source =
|
const gchar *stretch_fragment_source =
|
||||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||||
"uniform sampler2DRect tex;"
|
"uniform sampler2DRect tex;"
|
||||||
"uniform float width, height;"
|
"uniform float width, height;"
|
||||||
"void main () {"
|
"void main () {"
|
||||||
" vec2 tex_size = vec2 (width, height);"
|
" vec2 tex_size = vec2 (width, height);"
|
||||||
" vec2 texturecoord = gl_TexCoord[0].xy;"
|
" vec2 texturecoord = gl_TexCoord[0].xy;"
|
||||||
" vec2 normcoord;"
|
" vec2 normcoord;"
|
||||||
" normcoord = texturecoord / tex_size - 1.0;"
|
" normcoord = texturecoord / tex_size - 1.0;"
|
||||||
" float r = length (normcoord);"
|
" float r = length (normcoord);"
|
||||||
" normcoord *= 2.0 - smoothstep(0.0, 0.7, r);"
|
" normcoord *= 2.0 - smoothstep(0.0, 0.7, r);"
|
||||||
" texturecoord = (normcoord + 1.0) * tex_size;"
|
" texturecoord = (normcoord + 1.0) * tex_size;"
|
||||||
" vec4 color = texture2DRect (tex, texturecoord);"
|
" vec4 color = texture2DRect (tex, texturecoord);"
|
||||||
" gl_FragColor = color * gl_Color;" "}";
|
" gl_FragColor = color * gl_Color;"
|
||||||
|
"}";
|
||||||
|
|
||||||
/* Light Tunnel effect */
|
/* Light Tunnel effect */
|
||||||
const gchar *tunnel_fragment_source =
|
const gchar *tunnel_fragment_source =
|
||||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||||
"uniform sampler2DRect tex;"
|
"uniform sampler2DRect tex;"
|
||||||
"uniform float width, height;"
|
"uniform float width, height;"
|
||||||
"void main () {"
|
"void main () {"
|
||||||
" vec2 tex_size = vec2 (width, height);"
|
" vec2 tex_size = vec2 (width, height);"
|
||||||
" vec2 texturecoord = gl_TexCoord[0].xy;" " vec2 normcoord;"
|
" vec2 texturecoord = gl_TexCoord[0].xy;"
|
||||||
/* little trick with normalized coords to obtain a circle */
|
" vec2 normcoord;"
|
||||||
" normcoord = texturecoord / tex_size.x - tex_size / tex_size.x;" " float r = length(normcoord);" " float phi = atan(normcoord.y, normcoord.x);" " r = clamp (r, 0.0, 0.5);" /* is there a way to do this without polars? */
|
/* little trick with normalized coords to obtain a circle */
|
||||||
" normcoord.x = r * cos(phi);"
|
" normcoord = texturecoord / tex_size.x - tex_size / tex_size.x;"
|
||||||
" normcoord.y = r * sin(phi); "
|
" float r = length(normcoord);"
|
||||||
" texturecoord = (normcoord + tex_size/tex_size.x) * tex_size.x;"
|
" float phi = atan(normcoord.y, normcoord.x);"
|
||||||
" vec4 color = texture2DRect (tex, texturecoord); "
|
" r = clamp (r, 0.0, 0.5);" /* is there a way to do this without polars? */
|
||||||
" gl_FragColor = color;" "}";
|
" normcoord.x = r * cos(phi);"
|
||||||
|
" normcoord.y = r * sin(phi); "
|
||||||
|
" texturecoord = (normcoord + tex_size/tex_size.x) * tex_size.x;"
|
||||||
|
" vec4 color = texture2DRect (tex, texturecoord); "
|
||||||
|
" gl_FragColor = color;"
|
||||||
|
"}";
|
||||||
|
|
||||||
/* FishEye effect */
|
/* FishEye effect */
|
||||||
const gchar *fisheye_fragment_source =
|
const gchar *fisheye_fragment_source =
|
||||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||||
"uniform sampler2DRect tex;"
|
"uniform sampler2DRect tex;"
|
||||||
"uniform float width, height;"
|
"uniform float width, height;"
|
||||||
"void main () {"
|
"void main () {"
|
||||||
" vec2 tex_size = vec2 (width, height);"
|
" vec2 tex_size = vec2 (width, height);"
|
||||||
" vec2 texturecoord = gl_TexCoord[0].xy;"
|
" vec2 texturecoord = gl_TexCoord[0].xy;"
|
||||||
" vec2 normcoord;"
|
" vec2 normcoord;"
|
||||||
" normcoord = texturecoord / tex_size - 1.0;"
|
" normcoord = texturecoord / tex_size - 1.0;"
|
||||||
" float r = length (normcoord);"
|
" float r = length (normcoord);"
|
||||||
" normcoord *= r/sqrt(2.0);"
|
" normcoord *= r/sqrt(2.0);"
|
||||||
" texturecoord = (normcoord + 1.0) * tex_size;"
|
" texturecoord = (normcoord + 1.0) * tex_size;"
|
||||||
" vec4 color = texture2DRect (tex, texturecoord);"
|
" vec4 color = texture2DRect (tex, texturecoord);"
|
||||||
" gl_FragColor = color;" "}";
|
" gl_FragColor = color;"
|
||||||
|
"}";
|
||||||
|
|
||||||
|
|
||||||
/* Twirl effect */
|
/* Twirl effect */
|
||||||
const gchar *twirl_fragment_source =
|
const gchar *twirl_fragment_source =
|
||||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||||
"uniform sampler2DRect tex;"
|
"uniform sampler2DRect tex;"
|
||||||
"uniform float width, height;"
|
"uniform float width, height;"
|
||||||
"void main () {"
|
"void main () {"
|
||||||
" vec2 tex_size = vec2 (width, height);"
|
" vec2 tex_size = vec2 (width, height);"
|
||||||
" vec2 texturecoord = gl_TexCoord[0].xy;"
|
" vec2 texturecoord = gl_TexCoord[0].xy;"
|
||||||
" vec2 normcoord;"
|
" vec2 normcoord;"
|
||||||
" normcoord = texturecoord / tex_size - 1.0;"
|
" normcoord = texturecoord / tex_size - 1.0;"
|
||||||
" float r = length (normcoord);"
|
" float r = length (normcoord);"
|
||||||
" float phi = atan (normcoord.y, normcoord.x);"
|
" float phi = atan (normcoord.y, normcoord.x);"
|
||||||
" phi += (1.0 - smoothstep (-0.6, 0.6, r)) * 4.8;"
|
" phi += (1.0 - smoothstep (-0.6, 0.6, r)) * 4.8;"
|
||||||
" normcoord.x = r * cos(phi);"
|
" normcoord.x = r * cos(phi);"
|
||||||
" normcoord.y = r * sin(phi);"
|
" normcoord.y = r * sin(phi);"
|
||||||
" texturecoord = (normcoord + 1.0) * tex_size;"
|
" texturecoord = (normcoord + 1.0) * tex_size;"
|
||||||
" vec4 color = texture2DRect (tex, texturecoord); "
|
" vec4 color = texture2DRect (tex, texturecoord); "
|
||||||
" gl_FragColor = color;" "}";
|
" gl_FragColor = color;"
|
||||||
|
"}";
|
||||||
|
|
||||||
|
|
||||||
/* Bulge effect */
|
/* Bulge effect */
|
||||||
const gchar *bulge_fragment_source =
|
const gchar *bulge_fragment_source =
|
||||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||||
"uniform sampler2DRect tex;"
|
"uniform sampler2DRect tex;"
|
||||||
"uniform float width, height;"
|
"uniform float width, height;"
|
||||||
"void main () {"
|
"void main () {"
|
||||||
" vec2 tex_size = vec2 (width, height);"
|
" vec2 tex_size = vec2 (width, height);"
|
||||||
" vec2 texturecoord = gl_TexCoord[0].xy;"
|
" vec2 texturecoord = gl_TexCoord[0].xy;"
|
||||||
" vec2 normcoord;"
|
" vec2 normcoord;"
|
||||||
" normcoord = texturecoord / tex_size - 1.0;"
|
" normcoord = texturecoord / tex_size - 1.0;"
|
||||||
" float r = length (normcoord);"
|
" float r = length (normcoord);"
|
||||||
" normcoord *= smoothstep (-0.1, 0.5, r);"
|
" normcoord *= smoothstep (-0.1, 0.5, r);"
|
||||||
" texturecoord = (normcoord + 1.0) * tex_size;"
|
" texturecoord = (normcoord + 1.0) * tex_size;"
|
||||||
" vec4 color = texture2DRect (tex, texturecoord);"
|
" vec4 color = texture2DRect (tex, texturecoord);"
|
||||||
" gl_FragColor = color;" "}";
|
" gl_FragColor = color;"
|
||||||
|
"}";
|
||||||
|
|
||||||
|
|
||||||
/* Square Effect */
|
/* Square Effect */
|
||||||
const gchar *square_fragment_source =
|
const gchar *square_fragment_source =
|
||||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||||
"uniform sampler2DRect tex;"
|
"uniform sampler2DRect tex;"
|
||||||
"uniform float width;"
|
"uniform float width;"
|
||||||
"uniform float height;"
|
"uniform float height;"
|
||||||
"void main () {"
|
"void main () {"
|
||||||
" vec2 tex_size = vec2 (width, height);"
|
" vec2 tex_size = vec2 (width, height);"
|
||||||
" vec2 texturecoord = gl_TexCoord[0].xy;"
|
" vec2 texturecoord = gl_TexCoord[0].xy;"
|
||||||
" vec2 normcoord;"
|
" vec2 normcoord;"
|
||||||
" normcoord = texturecoord / tex_size - 1.0;"
|
" normcoord = texturecoord / tex_size - 1.0;"
|
||||||
" float r = length (normcoord);"
|
" float r = length (normcoord);"
|
||||||
" normcoord *= 1.0 + smoothstep(0.25, 0.5, abs(normcoord));"
|
" normcoord *= 1.0 + smoothstep(0.25, 0.5, abs(normcoord));"
|
||||||
" normcoord /= 2.0; /* zoom amount */"
|
" normcoord /= 2.0; /* zoom amount */"
|
||||||
" texturecoord = (normcoord + 1.0) * tex_size;"
|
" texturecoord = (normcoord + 1.0) * tex_size;"
|
||||||
" vec4 color = texture2DRect (tex, texturecoord);"
|
" vec4 color = texture2DRect (tex, texturecoord);"
|
||||||
" gl_FragColor = color * gl_Color;" "}";
|
" gl_FragColor = color * gl_Color;"
|
||||||
|
"}";
|
||||||
|
|
||||||
|
|
||||||
const gchar *luma_threshold_fragment_source = "#extension GL_ARB_texture_rectangle : enable\n" "uniform sampler2DRect tex;" "void main () {" " vec2 texturecoord = gl_TexCoord[0].st;" " int i;" " vec4 color = texture2DRect(tex, texturecoord);" " float luma = dot(color.rgb, vec3(0.2125, 0.7154, 0.0721));" /* BT.709 (from orange book) */
|
const gchar *luma_threshold_fragment_source =
|
||||||
" gl_FragColor = vec4 (vec3 (smoothstep (0.30, 0.50, luma)), color.a);"
|
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||||
"}";
|
"uniform sampler2DRect tex;"
|
||||||
|
"void main () {"
|
||||||
|
" vec2 texturecoord = gl_TexCoord[0].st;"
|
||||||
|
" int i;"
|
||||||
|
" vec4 color = texture2DRect(tex, texturecoord);"
|
||||||
|
" float luma = dot(color.rgb, vec3(0.2125, 0.7154, 0.0721));" /* BT.709 (from orange book) */
|
||||||
|
" gl_FragColor = vec4 (vec3 (smoothstep (0.30, 0.50, luma)), color.a);"
|
||||||
|
"}";
|
||||||
|
|
||||||
const gchar *sobel_fragment_source =
|
const gchar *sobel_fragment_source =
|
||||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||||
"uniform sampler2DRect tex;"
|
"uniform sampler2DRect tex;"
|
||||||
"uniform float hkern[9];"
|
"uniform float hkern[9];"
|
||||||
"uniform float vkern[9];"
|
"uniform float vkern[9];"
|
||||||
"uniform bool invert;"
|
"uniform bool invert;"
|
||||||
"void main () {"
|
"void main () {"
|
||||||
" vec2 offset[9] = vec2[9] ( vec2(-1.0,-1.0), vec2( 0.0,-1.0), vec2( 1.0,-1.0),"
|
" vec2 offset[9] = vec2[9] ( vec2(-1.0,-1.0), vec2( 0.0,-1.0), vec2( 1.0,-1.0),"
|
||||||
" vec2(-1.0, 0.0), vec2( 0.0, 0.0), vec2( 1.0, 0.0),"
|
" vec2(-1.0, 0.0), vec2( 0.0, 0.0), vec2( 1.0, 0.0),"
|
||||||
" vec2(-1.0, 1.0), vec2( 0.0, 1.0), vec2( 1.0, 1.0) );"
|
" vec2(-1.0, 1.0), vec2( 0.0, 1.0), vec2( 1.0, 1.0) );"
|
||||||
" vec2 texturecoord = gl_TexCoord[0].st;"
|
" vec2 texturecoord = gl_TexCoord[0].st;"
|
||||||
" int i;"
|
" int i;"
|
||||||
" float luma;"
|
" float luma;"
|
||||||
" float gx = 0.0;"
|
" float gx = 0.0;"
|
||||||
" float gy = 0.0 ;"
|
" float gy = 0.0 ;"
|
||||||
" for (i = 0; i < 9; i++) { "
|
" for (i = 0; i < 9; i++) { "
|
||||||
" if(hkern[i] != 0.0 || vkern[i] != 0.0) {"
|
" if(hkern[i] != 0.0 || vkern[i] != 0.0) {"
|
||||||
" vec4 neighbor = texture2DRect(tex, texturecoord + vec2(offset[i])); "
|
" vec4 neighbor = texture2DRect(tex, texturecoord + vec2(offset[i])); "
|
||||||
" luma = dot(neighbor, vec4(0.2125, 0.7154, 0.0721, neighbor.a));"
|
" luma = dot(neighbor, vec4(0.2125, 0.7154, 0.0721, neighbor.a));"
|
||||||
" gx += luma * hkern[i]; "
|
" gx += luma * hkern[i]; "
|
||||||
" gy += luma * vkern[i]; "
|
" gy += luma * vkern[i]; "
|
||||||
" }"
|
" }"
|
||||||
" }"
|
" }"
|
||||||
" float g = sqrt(gx*gx + gy*gy);"
|
" float g = sqrt(gx*gx + gy*gy);"
|
||||||
" if (invert) g = 1.0 - g;" " gl_FragColor = vec4(vec3(g), 1.0);" "}";
|
" if (invert) g = 1.0 - g;"
|
||||||
|
" gl_FragColor = vec4(vec3(g), 1.0);"
|
||||||
|
"}";
|
||||||
|
|
||||||
|
|
||||||
/* horizontal convolution */
|
/* horizontal convolution */
|
||||||
const gchar *hconv9_fragment_source =
|
const gchar *hconv9_fragment_source =
|
||||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||||
"uniform sampler2DRect tex;"
|
"uniform sampler2DRect tex;"
|
||||||
"uniform float norm_const;"
|
"uniform float norm_const;"
|
||||||
"uniform float norm_offset;" "uniform float kernel[9];" "void main () {"
|
"uniform float norm_offset;"
|
||||||
|
"uniform float kernel[9];"
|
||||||
|
"void main () {"
|
||||||
/* "float offset[9] = float[9] (-4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0);" */
|
/* "float offset[9] = float[9] (-4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0);" */
|
||||||
/* don't use array constructor so we don't have to depend on #version 120 */
|
/* don't use array constructor so we don't have to depend on #version 120 */
|
||||||
" float offset[9];"
|
" float offset[9];"
|
||||||
" offset[0] = -4.0;"
|
" offset[0] = -4.0;"
|
||||||
" offset[1] = -3.0;"
|
" offset[1] = -3.0;"
|
||||||
" offset[2] = -2.0;"
|
" offset[2] = -2.0;"
|
||||||
" offset[3] = -1.0;"
|
" offset[3] = -1.0;"
|
||||||
" offset[4] = 0.0;"
|
" offset[4] = 0.0;"
|
||||||
" offset[5] = 1.0;"
|
" offset[5] = 1.0;"
|
||||||
" offset[6] = 2.0;"
|
" offset[6] = 2.0;"
|
||||||
" offset[7] = 3.0;"
|
" offset[7] = 3.0;"
|
||||||
" offset[8] = 4.0;"
|
" offset[8] = 4.0;"
|
||||||
" vec2 texturecoord = gl_TexCoord[0].st;"
|
" vec2 texturecoord = gl_TexCoord[0].st;"
|
||||||
" int i;"
|
" int i;"
|
||||||
" vec4 sum = vec4 (0.0);"
|
" vec4 sum = vec4 (0.0);"
|
||||||
" for (i = 0; i < 9; i++) { "
|
" for (i = 0; i < 9; i++) { "
|
||||||
" if (kernel[i] != 0.0) {"
|
" if (kernel[i] != 0.0) {"
|
||||||
" vec4 neighbor = texture2DRect(tex, vec2(texturecoord.s+offset[i], texturecoord.t)); "
|
" vec4 neighbor = texture2DRect(tex, vec2(texturecoord.s+offset[i], texturecoord.t)); "
|
||||||
" sum += neighbor * kernel[i]/norm_const; "
|
" sum += neighbor * kernel[i]/norm_const; "
|
||||||
" }" " }" " gl_FragColor = sum + norm_offset;" "}";
|
" }"
|
||||||
|
" }"
|
||||||
|
" gl_FragColor = sum + norm_offset;"
|
||||||
|
"}";
|
||||||
|
|
||||||
/* vertical convolution */
|
/* vertical convolution */
|
||||||
const gchar *vconv9_fragment_source =
|
const gchar *vconv9_fragment_source =
|
||||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||||
"uniform sampler2DRect tex;"
|
"uniform sampler2DRect tex;"
|
||||||
"uniform float norm_const;"
|
"uniform float norm_const;"
|
||||||
"uniform float norm_offset;" "uniform float kernel[9];" "void main () {"
|
"uniform float norm_offset;"
|
||||||
|
"uniform float kernel[9];"
|
||||||
|
"void main () {"
|
||||||
/* "float offset[9] = float[9] (-4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0);" */
|
/* "float offset[9] = float[9] (-4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0);" */
|
||||||
/* don't use array constructor so we don't have to depend on #version 120 */
|
/* don't use array constructor so we don't have to depend on #version 120 */
|
||||||
" float offset[9];"
|
" float offset[9];"
|
||||||
" offset[0] = -4.0;"
|
" offset[0] = -4.0;"
|
||||||
" offset[1] = -3.0;"
|
" offset[1] = -3.0;"
|
||||||
" offset[2] = -2.0;"
|
" offset[2] = -2.0;"
|
||||||
" offset[3] = -1.0;"
|
" offset[3] = -1.0;"
|
||||||
" offset[4] = 0.0;"
|
" offset[4] = 0.0;"
|
||||||
" offset[5] = 1.0;"
|
" offset[5] = 1.0;"
|
||||||
" offset[6] = 2.0;"
|
" offset[6] = 2.0;"
|
||||||
" offset[7] = 3.0;"
|
" offset[7] = 3.0;"
|
||||||
" offset[8] = 4.0;"
|
" offset[8] = 4.0;"
|
||||||
" vec2 texturecoord = gl_TexCoord[0].st;"
|
" vec2 texturecoord = gl_TexCoord[0].st;"
|
||||||
" int i;"
|
" int i;"
|
||||||
" vec4 sum = vec4 (0.0);"
|
" vec4 sum = vec4 (0.0);"
|
||||||
" for (i = 0; i < 9; i++) { "
|
" for (i = 0; i < 9; i++) { "
|
||||||
" if (kernel[i] != 0.0) {"
|
" if (kernel[i] != 0.0) {"
|
||||||
" vec4 neighbor = texture2DRect(tex, vec2(texturecoord.s, texturecoord.t+offset[i])); "
|
" vec4 neighbor = texture2DRect(tex, vec2(texturecoord.s, texturecoord.t+offset[i])); "
|
||||||
" sum += neighbor * kernel[i]/norm_const; "
|
" sum += neighbor * kernel[i]/norm_const; "
|
||||||
" }" " }" " gl_FragColor = sum + norm_offset;" "}";
|
" }"
|
||||||
|
" }"
|
||||||
|
" gl_FragColor = sum + norm_offset;"
|
||||||
|
"}";
|
||||||
|
|
||||||
|
|
||||||
/* TODO: support several blend modes */
|
/* TODO: support several blend modes */
|
||||||
const gchar *sum_fragment_source =
|
const gchar *sum_fragment_source =
|
||||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||||
"uniform sampler2DRect base;"
|
"uniform sampler2DRect base;"
|
||||||
"uniform sampler2DRect blend;"
|
"uniform sampler2DRect blend;"
|
||||||
"uniform float alpha;"
|
"uniform float alpha;"
|
||||||
"uniform float beta;"
|
"uniform float beta;"
|
||||||
"void main () {"
|
"void main () {"
|
||||||
" vec4 basecolor = texture2DRect (base, gl_TexCoord[0].st);"
|
" vec4 basecolor = texture2DRect (base, gl_TexCoord[0].st);"
|
||||||
" vec4 blendcolor = texture2DRect (blend, gl_TexCoord[0].st);"
|
" vec4 blendcolor = texture2DRect (blend, gl_TexCoord[0].st);"
|
||||||
" gl_FragColor = alpha * basecolor + beta * blendcolor;" "}";
|
" gl_FragColor = alpha * basecolor + beta * blendcolor;"
|
||||||
|
"}";
|
||||||
|
|
||||||
const gchar *multiply_fragment_source =
|
const gchar *multiply_fragment_source =
|
||||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||||
"uniform sampler2DRect base;"
|
"uniform sampler2DRect base;"
|
||||||
"uniform sampler2DRect blend;"
|
"uniform sampler2DRect blend;"
|
||||||
"uniform float alpha;"
|
"uniform float alpha;"
|
||||||
"void main () {"
|
"void main () {"
|
||||||
" vec4 basecolor = texture2DRect (base, gl_TexCoord[0].st);"
|
" vec4 basecolor = texture2DRect (base, gl_TexCoord[0].st);"
|
||||||
" vec4 blendcolor = texture2DRect (blend, gl_TexCoord[0].st);"
|
" vec4 blendcolor = texture2DRect (blend, gl_TexCoord[0].st);"
|
||||||
" gl_FragColor = (1 - alpha) * basecolor + alpha * basecolor * blendcolor;"
|
" gl_FragColor = (1 - alpha) * basecolor + alpha * basecolor * blendcolor;"
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
/* lut operations, map luma to tex1d, see orange book (chapter 19) */
|
/* lut operations, map luma to tex1d, see orange book (chapter 19) */
|
||||||
const gchar *luma_to_curve_fragment_source =
|
const gchar *luma_to_curve_fragment_source =
|
||||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||||
"uniform sampler2DRect tex;"
|
"uniform sampler2DRect tex;"
|
||||||
"uniform sampler1D curve;"
|
"uniform sampler1D curve;"
|
||||||
"void main () {"
|
"void main () {"
|
||||||
" vec2 texturecoord = gl_TexCoord[0].st;"
|
" vec2 texturecoord = gl_TexCoord[0].st;"
|
||||||
" vec4 color = texture2DRect (tex, texturecoord);"
|
" vec4 color = texture2DRect (tex, texturecoord);"
|
||||||
" float luma = dot(color.rgb, vec3(0.2125, 0.7154, 0.0721));"
|
" float luma = dot(color.rgb, vec3(0.2125, 0.7154, 0.0721));"
|
||||||
" color = texture1D(curve, luma);" " gl_FragColor = color;" "}";
|
" color = texture1D(curve, luma);"
|
||||||
|
" gl_FragColor = color;"
|
||||||
|
"}";
|
||||||
|
|
||||||
|
|
||||||
/* lut operations, map rgb to tex1d, see orange book (chapter 19) */
|
/* lut operations, map rgb to tex1d, see orange book (chapter 19) */
|
||||||
const gchar *rgb_to_curve_fragment_source =
|
const gchar *rgb_to_curve_fragment_source =
|
||||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||||
"uniform sampler2DRect tex;"
|
"uniform sampler2DRect tex;"
|
||||||
"uniform sampler1D curve;"
|
"uniform sampler1D curve;"
|
||||||
"void main () {"
|
"void main () {"
|
||||||
" vec2 texturecoord = gl_TexCoord[0].st;"
|
" vec2 texturecoord = gl_TexCoord[0].st;"
|
||||||
" vec4 color = texture2DRect (tex, texturecoord);"
|
" vec4 color = texture2DRect (tex, texturecoord);"
|
||||||
" vec4 outcolor;"
|
" vec4 outcolor;"
|
||||||
" outcolor.r = texture1D(curve, color.r).r;"
|
" outcolor.r = texture1D(curve, color.r).r;"
|
||||||
" outcolor.g = texture1D(curve, color.g).g;"
|
" outcolor.g = texture1D(curve, color.g).g;"
|
||||||
" outcolor.b = texture1D(curve, color.b).b;"
|
" outcolor.b = texture1D(curve, color.b).b;"
|
||||||
" outcolor.a = color.a;" " gl_FragColor = outcolor;" "}";
|
" outcolor.a = color.a;"
|
||||||
|
" gl_FragColor = outcolor;"
|
||||||
|
"}";
|
||||||
|
|
||||||
const gchar *sin_fragment_source =
|
const gchar *sin_fragment_source =
|
||||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||||
"uniform sampler2DRect tex;" "vec3 rgb2hsl (vec3 v) " "{"
|
"uniform sampler2DRect tex;"
|
||||||
|
"vec3 rgb2hsl (vec3 v)"
|
||||||
|
"{"
|
||||||
/* TODO: check this algorythm */
|
/* TODO: check this algorythm */
|
||||||
" float MIN, MAX;"
|
" float MIN, MAX;"
|
||||||
" float r, g, b;"
|
" float r, g, b;"
|
||||||
" float h, l, s;"
|
" float h, l, s;"
|
||||||
" float delta;"
|
" float delta;"
|
||||||
" h = 0.0; l = 0.0; s = 0.0;"
|
" h = 0.0; l = 0.0; s = 0.0;"
|
||||||
" r = v.r; g = v.g; b = v.b;"
|
" r = v.r; g = v.g; b = v.b;"
|
||||||
" MIN = min (r, min (g, b));"
|
" MIN = min (r, min (g, b));"
|
||||||
" MAX = max (r, max (g, b));"
|
" MAX = max (r, max (g, b));"
|
||||||
" delta = MAX - MIN;"
|
" delta = MAX - MIN;"
|
||||||
" l = (MAX + MIN) / 2.0;"
|
" l = (MAX + MIN) / 2.0;"
|
||||||
" if ((MAX - MIN) < 0.0001) { h = 0.0; s = 0.0; }"
|
" if ((MAX - MIN) < 0.0001) { h = 0.0; s = 0.0; }"
|
||||||
" else {"
|
" else {"
|
||||||
" if (l <= 0.5) s = (MAX - MIN) / (MAX + MIN);"
|
" if (l <= 0.5) s = (MAX - MIN) / (MAX + MIN);"
|
||||||
" else s = (MAX - MIN) / (2.0 - MAX - MIN);"
|
" else s = (MAX - MIN) / (2.0 - MAX - MIN);"
|
||||||
" if (r == MAX) h = (g - b) / delta;"
|
" if (r == MAX) h = (g - b) / delta;"
|
||||||
" else if (g == MAX) h = 2.0 + (b - r) / delta;"
|
" else if (g == MAX) h = 2.0 + (b - r) / delta;"
|
||||||
" else h = 4.0 + (r - g) / delta;"
|
" else h = 4.0 + (r - g) / delta;"
|
||||||
" h *= 60.0;"
|
" h *= 60.0;"
|
||||||
" if (h < 0.0) h += 360.0;"
|
" if (h < 0.0) h += 360.0;"
|
||||||
" }"
|
" }"
|
||||||
" return vec3 (h, l, s);"
|
" return vec3 (h, l, s);"
|
||||||
"}"
|
"}"
|
||||||
"void main () {"
|
"void main () {"
|
||||||
" vec3 HSL, RGB;"
|
" vec3 HSL, RGB;"
|
||||||
" vec4 color = texture2DRect (tex, vec2(gl_TexCoord[0].st));"
|
" vec4 color = texture2DRect (tex, vec2(gl_TexCoord[0].st));"
|
||||||
" float luma = dot(color.rgb, vec3(0.2125, 0.7154, 0.0721));"
|
" float luma = dot(color.rgb, vec3(0.2125, 0.7154, 0.0721));"
|
||||||
" HSL = rgb2hsl (color.rgb);"
|
" HSL = rgb2hsl (color.rgb);"
|
||||||
/* move hls discontinuity away from the desired red zone so we can use
|
/* move hls discontinuity away from the desired red zone so we can use
|
||||||
* smoothstep.. to try: convert degrees in radiants, divide by 2 and
|
* smoothstep.. to try: convert degrees in radiants, divide by 2 and
|
||||||
* smoothstep cosine */
|
* smoothstep cosine */
|
||||||
" HSL.x += 180.0;" " if ((HSL.x) > 360.0) HSL.x -= 360.0;"
|
" HSL.x += 180.0;"
|
||||||
|
" if ((HSL.x) > 360.0) HSL.x -= 360.0;"
|
||||||
/* damn, it is extremely hard to get rid of human face reds! */
|
/* damn, it is extremely hard to get rid of human face reds! */
|
||||||
/* picked hue is slightly shifted towards violet to prevent this but
|
/* picked hue is slightly shifted towards violet to prevent this but
|
||||||
* still fails.. maybe hsl is not well suited for this */
|
* still fails.. maybe hsl is not well suited for this */
|
||||||
" float a = smoothstep (110.0, 150.0, HSL.x);"
|
" float a = smoothstep (110.0, 150.0, HSL.x);"
|
||||||
" float b = smoothstep (170.0, 210.0, HSL.x);"
|
" float b = smoothstep (170.0, 210.0, HSL.x);"
|
||||||
" float alpha = a - b;"
|
" float alpha = a - b;"
|
||||||
" gl_FragColor = color * alpha + luma * (1.0 - alpha);" "}";
|
" gl_FragColor = color * alpha + luma * (1.0 - alpha);"
|
||||||
|
"}";
|
||||||
|
|
||||||
const gchar *interpolate_fragment_source =
|
const gchar *interpolate_fragment_source =
|
||||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||||
"uniform sampler2DRect base;"
|
"uniform sampler2DRect base;"
|
||||||
"uniform sampler2DRect blend;"
|
"uniform sampler2DRect blend;"
|
||||||
"void main () {"
|
"void main () {"
|
||||||
"vec4 basecolor = texture2DRect (base, gl_TexCoord[0].st);"
|
"vec4 basecolor = texture2DRect (base, gl_TexCoord[0].st);"
|
||||||
"vec4 blendcolor = texture2DRect (blend, gl_TexCoord[0].st);"
|
"vec4 blendcolor = texture2DRect (blend, gl_TexCoord[0].st);"
|
||||||
"vec4 white = vec4(1.0);"
|
"vec4 white = vec4(1.0);"
|
||||||
"gl_FragColor = blendcolor + (1.0 - blendcolor.a) * basecolor;" "}";
|
"gl_FragColor = blendcolor + (1.0 - blendcolor.a) * basecolor;"
|
||||||
|
"}";
|
||||||
|
|
||||||
const gchar *texture_interp_fragment_source =
|
const gchar *texture_interp_fragment_source =
|
||||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||||
"uniform sampler2DRect base;"
|
"uniform sampler2DRect base;"
|
||||||
"uniform sampler2DRect blend;"
|
"uniform sampler2DRect blend;"
|
||||||
"uniform sampler2DRect alpha;"
|
"uniform sampler2DRect alpha;"
|
||||||
"uniform float final_width, final_height;"
|
"uniform float final_width, final_height;"
|
||||||
"uniform float base_width, base_height;"
|
"uniform float base_width, base_height;"
|
||||||
/*
|
/*
|
||||||
"uniform float blend_width, blend_height;"
|
"uniform float blend_width, blend_height;"
|
||||||
"uniform float alpha_width, alpha_height;"
|
"uniform float alpha_width, alpha_height;"
|
||||||
*/
|
*/
|
||||||
"void main () {"
|
"void main () {"
|
||||||
"vec2 base_scale = vec2 (base_width, base_height) / vec2 (final_width, final_height);"
|
"vec2 base_scale = vec2 (base_width, base_height) / vec2 (final_width, final_height);"
|
||||||
/*
|
/*
|
||||||
"vec2 blend_scale = vec2 (blend_width, blend_height) / vec2 (final_width, final_height);"
|
"vec2 blend_scale = vec2 (blend_width, blend_height) / vec2 (final_width, final_height);"
|
||||||
"vec2 alpha_scale = vec2 (alpha_width, alpha_height) / vec2 (final_width, final_height);"
|
"vec2 alpha_scale = vec2 (alpha_width, alpha_height) / vec2 (final_width, final_height);"
|
||||||
*/
|
*/
|
||||||
|
|
||||||
"vec4 basecolor = texture2DRect (base, gl_TexCoord[0].st * base_scale);"
|
"vec4 basecolor = texture2DRect (base, gl_TexCoord[0].st * base_scale);"
|
||||||
"vec4 blendcolor = texture2DRect (blend, gl_TexCoord[0].st);"
|
"vec4 blendcolor = texture2DRect (blend, gl_TexCoord[0].st);"
|
||||||
"vec4 alphacolor = texture2DRect (alpha, gl_TexCoord[0].st);"
|
"vec4 alphacolor = texture2DRect (alpha, gl_TexCoord[0].st);"
|
||||||
// "gl_FragColor = alphacolor;"
|
// "gl_FragColor = alphacolor;"
|
||||||
"gl_FragColor = (alphacolor * blendcolor) + (1.0 - alphacolor) * basecolor;"
|
"gl_FragColor = (alphacolor * blendcolor) + (1.0 - alphacolor) * basecolor;"
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
const gchar *difference_fragment_source =
|
const gchar *difference_fragment_source =
|
||||||
"#extension GL_ARB_texture_rectangle : enable\n"
|
"#extension GL_ARB_texture_rectangle : enable\n"
|
||||||
"uniform sampler2DRect saved;"
|
"uniform sampler2DRect saved;"
|
||||||
"uniform sampler2DRect current;"
|
"uniform sampler2DRect current;"
|
||||||
"void main () {"
|
"void main () {"
|
||||||
"vec4 savedcolor = texture2DRect (saved, gl_TexCoord[0].st);"
|
"vec4 savedcolor = texture2DRect (saved, gl_TexCoord[0].st);"
|
||||||
"vec4 currentcolor = texture2DRect (current, gl_TexCoord[0].st);"
|
"vec4 currentcolor = texture2DRect (current, gl_TexCoord[0].st);"
|
||||||
"gl_FragColor = vec4 (step (0.12, length (savedcolor - currentcolor)));"
|
"gl_FragColor = vec4 (step (0.12, length (savedcolor - currentcolor)));"
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
|
/* *INDENT-ON* */
|
||||||
|
|
Loading…
Reference in a new issue