summaryrefslogtreecommitdiff
path: root/shaders
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2011-05-16 22:07:59 -0700
committerEric Anholt <eric@anholt.net>2011-05-16 22:07:59 -0700
commit53df428a12c058578bddb6093c43801a556800f2 (patch)
treec859548b88d40cd587065c9db223bc1dd365d21a /shaders
Initial import.
Diffstat (limited to 'shaders')
-rw-r--r--shaders/gst-gl-bulge.frag43
-rw-r--r--shaders/gst-gl-bumper.frag61
-rw-r--r--shaders/gst-gl-bumper.vert60
-rw-r--r--shaders/gst-gl-convolution.frag55
-rw-r--r--shaders/gst-gl-cube-v.vert62
-rw-r--r--shaders/gst-gl-difference.frag37
-rw-r--r--shaders/gst-gl-fisheye.frag43
-rw-r--r--shaders/gst-gl-glass.frag53
-rw-r--r--shaders/gst-gl-greedyh.frag116
-rw-r--r--shaders/gst-gl-hconv9.frag59
-rw-r--r--shaders/gst-gl-interpolate.frag38
-rw-r--r--shaders/gst-gl-luma-threshold.frag38
-rw-r--r--shaders/gst-gl-luma-to-curve.frag39
-rw-r--r--shaders/gst-gl-mirror.frag42
-rw-r--r--shaders/gst-gl-mosaic-f.frag36
-rw-r--r--shaders/gst-gl-mosaic-v.vert59
-rw-r--r--shaders/gst-gl-multiply.frag38
-rw-r--r--shaders/gst-gl-rgb-to-curve.frag42
-rw-r--r--shaders/gst-gl-sin.frag75
-rw-r--r--shaders/gst-gl-sobel.frag60
-rw-r--r--shaders/gst-gl-square.frag45
-rw-r--r--shaders/gst-gl-squeeze.frag44
-rw-r--r--shaders/gst-gl-sum.frag39
-rw-r--r--shaders/gst-gl-text-download-i420-yv12.frag54
-rw-r--r--shaders/gst-gl-text-download-yuy2-uyvy.frag54
-rw-r--r--shaders/gst-gl-text-upload-ayuv.frag47
-rw-r--r--shaders/gst-gl-text-upload-i420-yv12.frag49
-rw-r--r--shaders/gst-gl-text-upload-yuy2-uyvy.frag51
-rw-r--r--shaders/gst-gl-texture-interp.frag51
-rw-r--r--shaders/gst-gl-tunnel.frag47
-rw-r--r--shaders/gst-gl-twirl.frag46
-rw-r--r--shaders/gst-gl-vconv9.frag52
-rw-r--r--shaders/norsetto-bumptbn_sh_fp.frag68
-rw-r--r--shaders/norsetto-bumptbn_sh_fp.vert45
-rw-r--r--shaders/xonotic-vs-generic-diffuse.vert1309
-rw-r--r--shaders/xreal-lighting-d-omni.frag69
-rw-r--r--shaders/xreal-lighting-d-omni.vert55
-rw-r--r--shaders/xreal-lighting-db-omni.frag72
-rw-r--r--shaders/xreal-lighting-db-omni.vert63
-rw-r--r--shaders/xreal-lighting-dbs-omni.frag86
-rw-r--r--shaders/xreal-lighting-dbs-omni.vert67
41 files changed, 3469 insertions, 0 deletions
diff --git a/shaders/gst-gl-bulge.frag b/shaders/gst-gl-bulge.frag
new file mode 100644
index 0000000..86980c3
--- /dev/null
+++ b/shaders/gst-gl-bulge.frag
@@ -0,0 +1,43 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.10
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+ * GStreamer
+ * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+uniform sampler2DRect tex;
+uniform float width, height;
+void main () {
+ vec2 tex_size = vec2 (width, height);
+ vec2 texturecoord = gl_TexCoord[0].xy;
+ vec2 normcoord;
+ normcoord = texturecoord / tex_size - 1.0;
+ float r = length (normcoord);
+ normcoord *= smoothstep (-0.1, 0.5, r);
+ texturecoord = (normcoord + 1.0) * tex_size;
+ vec4 color = texture2DRect (tex, texturecoord);
+ gl_FragColor = color;
+}
diff --git a/shaders/gst-gl-bumper.frag b/shaders/gst-gl-bumper.frag
new file mode 100644
index 0000000..395428c
--- /dev/null
+++ b/shaders/gst-gl-bumper.frag
@@ -0,0 +1,61 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.10
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+ * GStreamer
+ * Copyright (C) 2008 Cyril Comparon <cyril.comparon@gmail.com>
+ * Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+uniform sampler2DRect texture0;
+uniform sampler2DRect texture1;
+
+varying vec3 vNormal;
+varying vec3 vTangent;
+varying vec3 vVertexToLight0;
+varying vec3 vVertexToLight1;
+
+void main()
+{
+ // get the color of the textures
+ vec4 textureColor = texture2DRect(texture0, gl_TexCoord[0].st);
+ vec3 normalmapItem = texture2DRect(texture1, gl_TexCoord[1].st).xyz * 2.0 - 1.0;
+
+ // calculate matrix that transform from tangent space to normalmap space (contrary of intuition)
+ vec3 binormal = cross(vNormal, vTangent);
+ mat3 tangentSpace2normalmapSpaceMat = mat3(vTangent, binormal, vNormal);
+
+ // disturb the normal
+ vec3 disturbedNormal = tangentSpace2normalmapSpaceMat * normalmapItem;
+
+ // calculate the diffuse term and clamping it to [0;1]
+ float diffuseTerm0 = clamp(dot(disturbedNormal, vVertexToLight0), 0.0, 1.0);
+ float diffuseTerm1 = clamp(dot(disturbedNormal, vVertexToLight1), 0.0, 1.0);
+
+ vec3 irradiance = (diffuseTerm0 * gl_LightSource[0].diffuse.rgb + diffuseTerm1 * gl_LightSource[1].diffuse.rgb);
+
+ // calculate the final color
+ gl_FragColor = vec4(irradiance * textureColor.rgb, textureColor.w);
+}
diff --git a/shaders/gst-gl-bumper.vert b/shaders/gst-gl-bumper.vert
new file mode 100644
index 0000000..ad1560b
--- /dev/null
+++ b/shaders/gst-gl-bumper.vert
@@ -0,0 +1,60 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.10
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+ * GStreamer
+ * Copyright (C) 2008 Cyril Comparon <cyril.comparon@gmail.com>
+ * Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+attribute vec3 aTangent;
+
+varying vec3 vNormal;
+varying vec3 vTangent;
+varying vec3 vVertexToLight0;
+varying vec3 vVertexToLight1;
+
+void main()
+{
+ // transform the vertex
+ gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;
+
+ // transform the normal and the tangent to scene coords
+ vNormal = normalize(gl_NormalMatrix * gl_Normal);
+ vTangent = normalize(gl_NormalMatrix * aTangent);
+
+ // transforming the vertex position to modelview-space
+ //const vec4 vertexInSceneCoords = gl_ModelViewMatrix * gl_Vertex;
+
+ // calculate the vector from the vertex position to the light position
+ vVertexToLight0 = normalize(gl_LightSource[0].position).xyz;
+ vVertexToLight1 = normalize(gl_LightSource[1].position).xyz;
+
+ // transit vertex color
+ gl_FrontColor = gl_BackColor = gl_Color;
+
+ // use the two first sets of texture coordinates in the fragment shader
+ gl_TexCoord[0] = gl_MultiTexCoord0;
+ gl_TexCoord[1] = gl_MultiTexCoord1;
+}
diff --git a/shaders/gst-gl-convolution.frag b/shaders/gst-gl-convolution.frag
new file mode 100644
index 0000000..e21ea7a
--- /dev/null
+++ b/shaders/gst-gl-convolution.frag
@@ -0,0 +1,55 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.20
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+ * GStreamer
+ * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#version 120
+/* The #version was added by anholt in converting to piglit due to the
+ * use of the array constructor.
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+uniform sampler2DRect tex;
+uniform float norm_const;
+uniform float norm_offset;
+uniform float kernel[9];
+void main () {
+ 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, 1.0), vec2( 0.0, 1.0), vec2( 1.0, 1.0) );
+ vec2 texturecoord = gl_TexCoord[0].st;
+ int i;
+ vec4 sum = vec4 (0.0);
+ for (i = 0; i < 9; i++) {
+ if (kernel[i] != 0.0) {
+ vec4 neighbor = texture2DRect(tex, texturecoord + vec2(offset[i]));
+ sum += neighbor * kernel[i]/norm_const;
+ }
+ }
+ gl_FragColor = sum + norm_offset;
+}
diff --git a/shaders/gst-gl-cube-v.vert b/shaders/gst-gl-cube-v.vert
new file mode 100644
index 0000000..411558d
--- /dev/null
+++ b/shaders/gst-gl-cube-v.vert
@@ -0,0 +1,62 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.10
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+ * GStreamer
+ * Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/* This shader appeared under #ifdef OPENGL_ES2, but looked interesting enough
+ * to include in piglit anyway.
+ */
+
+attribute vec4 a_position;
+attribute vec2 a_texCoord;
+uniform mat4 u_matrix;
+uniform float xrot_degree, yrot_degree, zrot_degree;
+varying vec2 v_texCoord;
+void main()
+{
+ float PI = 3.14159265;
+ float xrot = xrot_degree*2.0*PI/360.0;
+ float yrot = yrot_degree*2.0*PI/360.0;
+ float zrot = zrot_degree*2.0*PI/360.0;
+ mat4 matX = mat4 (
+ 1.0, 0.0, 0.0, 0.0,
+ 0.0, cos(xrot), sin(xrot), 0.0,
+ 0.0, -sin(xrot), cos(xrot), 0.0,
+ 0.0, 0.0, 0.0, 1.0 );
+ mat4 matY = mat4 (
+ cos(yrot), 0.0, -sin(yrot), 0.0,
+ 0.0, 1.0, 0.0, 0.0,
+ sin(yrot), 0.0, cos(yrot), 0.0,
+ 0.0, 0.0, 0.0, 1.0 );
+ mat4 matZ = mat4 (
+ cos(zrot), sin(zrot), 0.0, 0.0,
+ -sin(zrot), cos(zrot), 0.0, 0.0,
+ 0.0, 0.0, 1.0, 0.0,
+ 0.0, 0.0, 0.0, 1.0 );
+ gl_Position = u_matrix * matZ * matY * matX * a_position;
+ v_texCoord = a_texCoord;
+}
diff --git a/shaders/gst-gl-difference.frag b/shaders/gst-gl-difference.frag
new file mode 100644
index 0000000..8bd25f4
--- /dev/null
+++ b/shaders/gst-gl-difference.frag
@@ -0,0 +1,37 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.10
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+ * GStreamer
+ * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+uniform sampler2DRect saved;
+uniform sampler2DRect current;
+void main () {
+vec4 savedcolor = texture2DRect (saved, gl_TexCoord[0].st);
+vec4 currentcolor = texture2DRect (current, gl_TexCoord[0].st);
+gl_FragColor = vec4 (step (0.12, length (savedcolor - currentcolor)));
+}
diff --git a/shaders/gst-gl-fisheye.frag b/shaders/gst-gl-fisheye.frag
new file mode 100644
index 0000000..d63a17b
--- /dev/null
+++ b/shaders/gst-gl-fisheye.frag
@@ -0,0 +1,43 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.10
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+ * GStreamer
+ * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+uniform sampler2DRect tex;
+uniform float width, height;
+void main () {
+ vec2 tex_size = vec2 (width, height);
+ vec2 texturecoord = gl_TexCoord[0].xy;
+ vec2 normcoord;
+ normcoord = texturecoord / tex_size - 1.0;
+ float r = length (normcoord);
+ normcoord *= r/sqrt(2.0);
+ texturecoord = (normcoord + 1.0) * tex_size;
+ vec4 color = texture2DRect (tex, texturecoord);
+ gl_FragColor = color;
+}
diff --git a/shaders/gst-gl-glass.frag b/shaders/gst-gl-glass.frag
new file mode 100644
index 0000000..c206012
--- /dev/null
+++ b/shaders/gst-gl-glass.frag
@@ -0,0 +1,53 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.10
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+ * GStreamer
+ * Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
+ * Inspired from http://www.mdk.org.pl/2007/11/17/gl-colorspace-conversions
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+uniform sampler2DRect tex;
+uniform float width, height;
+void main () {
+ float p = 0.0525;
+ float L1 = p*width;
+ float L2 = width - L1;
+ float L3 = height - L1;
+ float w = 1.0;
+ float r = L1;
+ if (gl_TexCoord[0].x < L1 && gl_TexCoord[0].y < L1)
+ r = sqrt( (gl_TexCoord[0].x - L1) * (gl_TexCoord[0].x - L1) + (gl_TexCoord[0].y - L1) * (gl_TexCoord[0].y - L1) );
+ else if (gl_TexCoord[0].x > L2 && gl_TexCoord[0].y < L1)
+ r = sqrt( (gl_TexCoord[0].x - L2) * (gl_TexCoord[0].x - L2) + (gl_TexCoord[0].y - L1) * (gl_TexCoord[0].y - L1) );
+ else if (gl_TexCoord[0].x > L2 && gl_TexCoord[0].y > L3)
+ r = sqrt( (gl_TexCoord[0].x - L2) * (gl_TexCoord[0].x - L2) + (gl_TexCoord[0].y - L3) * (gl_TexCoord[0].y - L3) );
+ else if (gl_TexCoord[0].x < L1 && gl_TexCoord[0].y > L3)
+ r = sqrt( (gl_TexCoord[0].x - L1) * (gl_TexCoord[0].x - L1) + (gl_TexCoord[0].y - L3) * (gl_TexCoord[0].y - L3) );
+ if (r > L1)
+ w = 0.0;
+ vec4 color = texture2DRect (tex, gl_TexCoord[0].st);
+ gl_FragColor = vec4(color.rgb, gl_Color.a * w);
+}
diff --git a/shaders/gst-gl-greedyh.frag b/shaders/gst-gl-greedyh.frag
new file mode 100644
index 0000000..2a0817e
--- /dev/null
+++ b/shaders/gst-gl-greedyh.frag
@@ -0,0 +1,116 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.10
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+ * GStreamer
+ * Copyright (C) 2009 Julien Isorce <julien.isorce@mail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+uniform sampler2DRect tex;
+uniform sampler2DRect tex_prev;
+uniform float max_comb;
+uniform float motion_threshold;
+uniform float motion_sense;
+uniform int width;
+uniform int height;
+
+void main () {
+ vec2 texcoord = gl_TexCoord[0].xy;
+ if (int(mod(texcoord.y, 2.0)) == 0)
+ gl_FragColor = vec4(texture2DRect(tex_prev, texcoord).rgb, 1.0);
+ else {
+ // cannot have __ in a var so __ is replaced by _a
+ vec2 texcoord_L1_a1, texcoord_L3_a1, texcoord_L1, texcoord_L3, texcoord_L1_1, texcoord_L3_1;
+ vec3 L1_a1, L3_a1, L1, L3, L1_1, L3_1;
+
+ texcoord_L1 = vec2(texcoord.x, texcoord.y - 1.0);
+ texcoord_L3 = vec2(texcoord.x, texcoord.y + 1.0);
+ L1 = texture2DRect(tex_prev, texcoord_L1).rgb;
+ L3 = texture2DRect(tex_prev, texcoord_L3).rgb;
+ if (int(ceil(texcoord.x)) == width && int(ceil(texcoord.y)) == height) {
+ L1_1 = L1;
+ L3_1 = L3;
+ } else {
+ texcoord_L1_1 = vec2(texcoord.x + 1.0, texcoord.y - 1.0);
+ texcoord_L3_1 = vec2(texcoord.x + 1.0, texcoord.y + 1.0);
+ L1_1 = texture2DRect(tex_prev, texcoord_L1_1).rgb;
+ L3_1 = texture2DRect(tex_prev, texcoord_L3_1).rgb;
+ }
+ if (int(ceil(texcoord.x + texcoord.y)) == 0) {
+ L1_a1 = L1;
+ L3_a1 = L3;
+ } else {
+ texcoord_L1_a1 = vec2(texcoord.x - 1.0, texcoord.y - 1.0);
+ texcoord_L3_a1 = vec2(texcoord.x - 1.0, texcoord.y + 1.0);
+ L1_a1 = texture2DRect(tex_prev, texcoord_L1_a1).rgb;
+ L3_a1 = texture2DRect(tex_prev, texcoord_L3_a1).rgb;
+ }
+
+ //STEP 1
+ vec3 avg_a1 = (L1_a1 + L3_a1) / 2.0;
+ vec3 avg = (L1 + L3) / 2.0;
+ vec3 avg_1 = (L1_1 + L3_1) / 2.0;
+
+ vec3 avg_s = (avg_a1 + avg_1) / 2.0;
+
+ vec3 avg_sc = (avg_s + avg) / 2.0;
+
+ vec3 L2 = texture2DRect(tex, texcoord).rgb;
+ vec3 LP2 = texture2DRect(tex_prev, texcoord).rgb;
+
+ vec3 best;
+
+ if (abs(L2.r - avg_sc.r) < abs(LP2.r - avg_sc.r)) {
+ best.r = L2.r;
+ } else {
+ best.r = LP2.r;
+ }
+
+ if (abs(L2.g - avg_sc.g) < abs(LP2.g - avg_sc.g)) {
+ best.g = L2.g;
+ } else {
+ best.g = LP2.g;
+ }
+
+ if (abs(L2.b - avg_sc.b) < abs(LP2.b - avg_sc.b)) {
+ best.b = L2.b;
+ } else {
+ best.b = LP2.b;
+ }
+
+ //STEP 2
+ vec3 last;
+ last.r = clamp(best.r, max(min(L1.r, L3.r) - max_comb, 0.0), min(max(L1.r, L3.r) + max_comb, 1.0));
+ last.g = clamp(best.g, max(min(L1.g, L3.g) - max_comb, 0.0), min(max(L1.g, L3.g) + max_comb, 1.0));
+ last.b = clamp(best.b, max(min(L1.b, L3.b) - max_comb, 0.0), min(max(L1.b, L3.b) + max_comb, 1.0));
+
+ //STEP 3
+ const vec3 luma = vec3 (0.299011, 0.586987, 0.114001);
+ float mov = min(max(abs(dot(L2 - LP2, luma)) - motion_threshold, 0.0) * motion_sense, 1.0);
+ last = last * (1.0 - mov) + avg_sc * mov;
+
+ gl_FragColor = vec4(last, 1.0);
+ }
+}
diff --git a/shaders/gst-gl-hconv9.frag b/shaders/gst-gl-hconv9.frag
new file mode 100644
index 0000000..01afa31
--- /dev/null
+++ b/shaders/gst-gl-hconv9.frag
@@ -0,0 +1,59 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.20
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+ * GStreamer
+ * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+uniform sampler2DRect tex;
+uniform float norm_const;
+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); */
+/* don't use array constructor so we don't have to depend on #version 120 */
+ float offset[9];
+ offset[0] = -4.0;
+ offset[1] = -3.0;
+ offset[2] = -2.0;
+ offset[3] = -1.0;
+ offset[4] = 0.0;
+ offset[5] = 1.0;
+ offset[6] = 2.0;
+ offset[7] = 3.0;
+ offset[8] = 4.0;
+ vec2 texturecoord = gl_TexCoord[0].st;
+ int i;
+ vec4 sum = vec4 (0.0);
+ for (i = 0; i < 9; i++) {
+ if (kernel[i] != 0.0) {
+ vec4 neighbor = texture2DRect(tex, vec2(texturecoord.s+offset[i], texturecoord.t));
+ sum += neighbor * kernel[i]/norm_const;
+ }
+ }
+ gl_FragColor = sum + norm_offset;
+}
diff --git a/shaders/gst-gl-interpolate.frag b/shaders/gst-gl-interpolate.frag
new file mode 100644
index 0000000..4402687
--- /dev/null
+++ b/shaders/gst-gl-interpolate.frag
@@ -0,0 +1,38 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.10
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+ * GStreamer
+ * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+uniform sampler2DRect base;
+uniform sampler2DRect blend;
+void main () {
+vec4 basecolor = texture2DRect (base, gl_TexCoord[0].st);
+vec4 blendcolor = texture2DRect (blend, gl_TexCoord[0].st);
+vec4 white = vec4(1.0);
+gl_FragColor = blendcolor + (1.0 - blendcolor.a) * basecolor;
+}
diff --git a/shaders/gst-gl-luma-threshold.frag b/shaders/gst-gl-luma-threshold.frag
new file mode 100644
index 0000000..8b1feae
--- /dev/null
+++ b/shaders/gst-gl-luma-threshold.frag
@@ -0,0 +1,38 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.10
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+ * GStreamer
+ * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+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));
+ gl_FragColor = vec4 (vec3 (smoothstep (0.30, 0.50, luma)), color.a);
+}
diff --git a/shaders/gst-gl-luma-to-curve.frag b/shaders/gst-gl-luma-to-curve.frag
new file mode 100644
index 0000000..6b36af3
--- /dev/null
+++ b/shaders/gst-gl-luma-to-curve.frag
@@ -0,0 +1,39 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.10
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+ * GStreamer
+ * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+uniform sampler2DRect tex;
+uniform sampler1D curve;
+void main () {
+ vec2 texturecoord = gl_TexCoord[0].st;
+ vec4 color = texture2DRect (tex, texturecoord);
+ float luma = dot(color.rgb, vec3(0.2125, 0.7154, 0.0721));
+ color = texture1D(curve, luma);
+ gl_FragColor = color;
+}
diff --git a/shaders/gst-gl-mirror.frag b/shaders/gst-gl-mirror.frag
new file mode 100644
index 0000000..f770fc0
--- /dev/null
+++ b/shaders/gst-gl-mirror.frag
@@ -0,0 +1,42 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.10
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+ * GStreamer
+ * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+uniform sampler2DRect tex;
+uniform float width, height;
+void main () {
+ vec2 tex_size = vec2 (width, height);
+ vec2 texturecoord = gl_TexCoord[0].xy;
+ vec2 normcoord;
+ normcoord = texturecoord / tex_size - 1.0;
+ normcoord.x *= sign (normcoord.x);
+ texturecoord = (normcoord + 1.0) * tex_size;
+ vec4 color = texture2DRect (tex, texturecoord);
+ gl_FragColor = color * gl_Color;
+}
diff --git a/shaders/gst-gl-mosaic-f.frag b/shaders/gst-gl-mosaic-f.frag
new file mode 100644
index 0000000..a7667b4
--- /dev/null
+++ b/shaders/gst-gl-mosaic-f.frag
@@ -0,0 +1,36 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.10
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+ * GStreamer
+ * Copyright (C) 2009 Julien Isorce <julien.isorce@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+uniform sampler2DRect s_texture;
+varying vec2 v_texCoord;
+void main()
+{
+ gl_FragColor = texture2DRect( s_texture, v_texCoord );
+}
diff --git a/shaders/gst-gl-mosaic-v.vert b/shaders/gst-gl-mosaic-v.vert
new file mode 100644
index 0000000..7c64d60
--- /dev/null
+++ b/shaders/gst-gl-mosaic-v.vert
@@ -0,0 +1,59 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.10
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+ * GStreamer
+ * Copyright (C) 2009 Julien Isorce <julien.isorce@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+uniform mat4 u_matrix;
+uniform float xrot_degree, yrot_degree, zrot_degree;
+attribute vec4 a_position;
+attribute vec2 a_texCoord;
+varying vec2 v_texCoord;
+void main()
+{
+ float PI = 3.14159265;
+ float xrot = xrot_degree*2.0*PI/360.0;
+ float yrot = yrot_degree*2.0*PI/360.0;
+ float zrot = zrot_degree*2.0*PI/360.0;
+ mat4 matX = mat4 (
+ 1.0, 0.0, 0.0, 0.0,
+ 0.0, cos(xrot), sin(xrot), 0.0,
+ 0.0, -sin(xrot), cos(xrot), 0.0,
+ 0.0, 0.0, 0.0, 1.0 );
+ mat4 matY = mat4 (
+ cos(yrot), 0.0, -sin(yrot), 0.0,
+ 0.0, 1.0, 0.0, 0.0,
+ sin(yrot), 0.0, cos(yrot), 0.0,
+ 0.0, 0.0, 0.0, 1.0 );
+ mat4 matZ = mat4 (
+ cos(zrot), sin(zrot), 0.0, 0.0,
+ -sin(zrot), cos(zrot), 0.0, 0.0,
+ 0.0, 0.0, 1.0, 0.0,
+ 0.0, 0.0, 0.0, 1.0 );
+ gl_Position = u_matrix * matZ * matY * matX * a_position;
+ v_texCoord = a_texCoord;
+}
diff --git a/shaders/gst-gl-multiply.frag b/shaders/gst-gl-multiply.frag
new file mode 100644
index 0000000..536f066
--- /dev/null
+++ b/shaders/gst-gl-multiply.frag
@@ -0,0 +1,38 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.10
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+ * GStreamer
+ * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+uniform sampler2DRect base;
+uniform sampler2DRect blend;
+uniform float alpha;
+void main () {
+ vec4 basecolor = texture2DRect (base, gl_TexCoord[0].st);
+ vec4 blendcolor = texture2DRect (blend, gl_TexCoord[0].st);
+ gl_FragColor = (1.0 - alpha) * basecolor + alpha * basecolor * blendcolor;
+}
diff --git a/shaders/gst-gl-rgb-to-curve.frag b/shaders/gst-gl-rgb-to-curve.frag
new file mode 100644
index 0000000..1f6b641
--- /dev/null
+++ b/shaders/gst-gl-rgb-to-curve.frag
@@ -0,0 +1,42 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.10
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+ * GStreamer
+ * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+uniform sampler2DRect tex;
+uniform sampler1D curve;
+void main () {
+ vec2 texturecoord = gl_TexCoord[0].st;
+ vec4 color = texture2DRect (tex, texturecoord);
+ vec4 outcolor;
+ outcolor.r = texture1D(curve, color.r).r;
+ outcolor.g = texture1D(curve, color.g).g;
+ outcolor.b = texture1D(curve, color.b).b;
+ outcolor.a = color.a;
+ gl_FragColor = outcolor;
+}
diff --git a/shaders/gst-gl-sin.frag b/shaders/gst-gl-sin.frag
new file mode 100644
index 0000000..4141e82
--- /dev/null
+++ b/shaders/gst-gl-sin.frag
@@ -0,0 +1,75 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.10
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+ * GStreamer
+ * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+uniform sampler2DRect tex;
+vec3 rgb2hsl (vec3 v)
+{
+/* TODO: check this algorythm */
+ float MIN, MAX;
+ float r, g, b;
+ float h, l, s;
+ float delta;
+ h = 0.0; l = 0.0; s = 0.0;
+ r = v.r; g = v.g; b = v.b;
+ MIN = min (r, min (g, b));
+ MAX = max (r, max (g, b));
+ delta = MAX - MIN;
+ l = (MAX + MIN) / 2.0;
+ if ((MAX - MIN) < 0.0001) { h = 0.0; s = 0.0; }
+ else {
+ if (l <= 0.5) s = (MAX - MIN) / (MAX + MIN);
+ else s = (MAX - MIN) / (2.0 - MAX - MIN);
+ if (r == MAX) h = (g - b) / delta;
+ else if (g == MAX) h = 2.0 + (b - r) / delta;
+ else h = 4.0 + (r - g) / delta;
+ h *= 60.0;
+ if (h < 0.0) h += 360.0;
+ }
+ return vec3 (h, l, s);
+}
+
+void main () {
+ vec3 HSL, RGB;
+ vec4 color = texture2DRect (tex, vec2(gl_TexCoord[0].st));
+ float luma = dot(color.rgb, vec3(0.2125, 0.7154, 0.0721));
+ HSL = rgb2hsl (color.rgb);
+/* 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 cosine */
+ 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! */
+/* picked hue is slightly shifted towards violet to prevent this but
+ * still fails.. maybe hsl is not well suited for this */
+ float a = smoothstep (110.0, 150.0, HSL.x);
+ float b = smoothstep (170.0, 210.0, HSL.x);
+ float alpha = a - b;
+ gl_FragColor = color * alpha + luma * (1.0 - alpha);
+}
diff --git a/shaders/gst-gl-sobel.frag b/shaders/gst-gl-sobel.frag
new file mode 100644
index 0000000..fa797e6
--- /dev/null
+++ b/shaders/gst-gl-sobel.frag
@@ -0,0 +1,60 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.20
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+ * GStreamer
+ * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#version 120
+/* The #version was added by anholt in converting to piglit due to the
+ * use of the array constructor.
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+uniform sampler2DRect tex;
+uniform float hkern[9];
+uniform float vkern[9];
+uniform bool invert;
+void main () {
+ 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, 1.0), vec2( 0.0, 1.0), vec2( 1.0, 1.0) );
+ vec2 texturecoord = gl_TexCoord[0].st;
+ int i;
+ float luma;
+ float gx = 0.0;
+ float gy = 0.0 ;
+ for (i = 0; i < 9; i++) {
+ if(hkern[i] != 0.0 || vkern[i] != 0.0) {
+ vec4 neighbor = texture2DRect(tex, texturecoord + vec2(offset[i]));
+ luma = dot(neighbor, vec4(0.2125, 0.7154, 0.0721, neighbor.a));
+ gx += luma * hkern[i];
+ gy += luma * vkern[i];
+ }
+ }
+ float g = sqrt(gx*gx + gy*gy);
+ if (invert) g = 1.0 - g;
+ gl_FragColor = vec4(vec3(g), 1.0);
+}
diff --git a/shaders/gst-gl-square.frag b/shaders/gst-gl-square.frag
new file mode 100644
index 0000000..d6669a8
--- /dev/null
+++ b/shaders/gst-gl-square.frag
@@ -0,0 +1,45 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.10
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+ * GStreamer
+ * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+uniform sampler2DRect tex;
+uniform float width;
+uniform float height;
+void main () {
+ vec2 tex_size = vec2 (width, height);
+ vec2 texturecoord = gl_TexCoord[0].xy;
+ vec2 normcoord;
+ normcoord = texturecoord / tex_size - 1.0;
+ float r = length (normcoord);
+ normcoord *= 1.0 + smoothstep(0.25, 0.5, abs(normcoord));
+ normcoord /= 2.0; /* zoom amount */
+ texturecoord = (normcoord + 1.0) * tex_size;
+ vec4 color = texture2DRect (tex, texturecoord);
+ gl_FragColor = color * gl_Color;
+}
diff --git a/shaders/gst-gl-squeeze.frag b/shaders/gst-gl-squeeze.frag
new file mode 100644
index 0000000..653307d
--- /dev/null
+++ b/shaders/gst-gl-squeeze.frag
@@ -0,0 +1,44 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.10
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+ * GStreamer
+ * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+uniform sampler2DRect tex;
+uniform float width, height;
+void main () {
+ vec2 tex_size = vec2 (width, height);
+ vec2 texturecoord = gl_TexCoord[0].xy;
+ vec2 normcoord;
+ normcoord = texturecoord / tex_size - 1.0;
+ float r = length (normcoord);
+ r = pow(r, 0.40)*1.3;
+ normcoord = normcoord / r;
+ texturecoord = (normcoord + 1.0) * tex_size;
+ vec4 color = texture2DRect (tex, texturecoord);
+ gl_FragColor = color * gl_Color;
+}
diff --git a/shaders/gst-gl-sum.frag b/shaders/gst-gl-sum.frag
new file mode 100644
index 0000000..9737850
--- /dev/null
+++ b/shaders/gst-gl-sum.frag
@@ -0,0 +1,39 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.10
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+ * GStreamer
+ * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+uniform sampler2DRect base;
+uniform sampler2DRect blend;
+uniform float alpha;
+uniform float beta;
+void main () {
+ vec4 basecolor = texture2DRect (base, gl_TexCoord[0].st);
+ vec4 blendcolor = texture2DRect (blend, gl_TexCoord[0].st);
+ gl_FragColor = alpha * basecolor + beta * blendcolor;
+}
diff --git a/shaders/gst-gl-text-download-i420-yv12.frag b/shaders/gst-gl-text-download-i420-yv12.frag
new file mode 100644
index 0000000..65fb18d
--- /dev/null
+++ b/shaders/gst-gl-text-download-i420-yv12.frag
@@ -0,0 +1,54 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.10
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+ * GStreamer
+ * Copyright (C) 2007 David A. Schleef <ds@schleef.org>
+ * Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
+ * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+uniform sampler2DRect tex;
+uniform float w, h;
+void main(void) {
+ float r,g,b,r2,b2,g2,y,u,v;
+ vec2 nxy=gl_TexCoord[0].xy;
+ vec2 nxy2=mod(2.0*nxy, vec2(w, h));
+ r=texture2DRect(tex,nxy).r;
+ g=texture2DRect(tex,nxy).g;
+ b=texture2DRect(tex,nxy).b;
+ r2=texture2DRect(tex,nxy2).r;
+ g2=texture2DRect(tex,nxy2).g;
+ b2=texture2DRect(tex,nxy2).b;
+ y=0.299011*r + 0.586987*g + 0.114001*b;
+ u=-0.148246*r2 -0.29102*g2 + 0.439266*b2;
+ v=0.439271*r2 - 0.367833*g2 - 0.071438*b2 ;
+ y=0.858885*y + 0.0625;
+ u=u + 0.5;
+ v=v + 0.5;
+ gl_FragData[0] = vec4(y, 0.0, 0.0, 1.0);
+ gl_FragData[1] = vec4(u, 0.0, 0.0, 1.0);
+ gl_FragData[2] = vec4(v, 0.0, 0.0, 1.0);
+}
diff --git a/shaders/gst-gl-text-download-yuy2-uyvy.frag b/shaders/gst-gl-text-download-yuy2-uyvy.frag
new file mode 100644
index 0000000..9dbe97b
--- /dev/null
+++ b/shaders/gst-gl-text-download-yuy2-uyvy.frag
@@ -0,0 +1,54 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.10
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+ * GStreamer
+ * Copyright (C) 2007 David A. Schleef <ds@schleef.org>
+ * Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
+ * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+uniform sampler2DRect tex;
+void main(void) {
+ float fx,fy,r,g,b,r2,g2,b2,y1,y2,u,v;
+ fx = gl_TexCoord[0].x;
+ fy = gl_TexCoord[0].y;
+ r=texture2DRect(tex,vec2(fx*2.0,fy)).r;
+ g=texture2DRect(tex,vec2(fx*2.0,fy)).g;
+ b=texture2DRect(tex,vec2(fx*2.0,fy)).b;
+ r2=texture2DRect(tex,vec2(fx*2.0+1.0,fy)).r;
+ g2=texture2DRect(tex,vec2(fx*2.0+1.0,fy)).g;
+ b2=texture2DRect(tex,vec2(fx*2.0+1.0,fy)).b;
+ y1=0.299011*r + 0.586987*g + 0.114001*b;
+ y2=0.299011*r2 + 0.586987*g2 + 0.114001*b2;
+ u=-0.148246*r -0.29102*g + 0.439266*b;
+ v=0.439271*r - 0.367833*g - 0.071438*b ;
+ y1=0.858885*y1 + 0.0625;
+ y2=0.858885*y2 + 0.0625;
+ u=u + 0.5;
+ v=v + 0.5;
+ /* "%s" replaced with "y2,u,y1,v" in conversion to piglit (yuy2 version) */
+ gl_FragColor=vec4(y2,u,y1,v);
+}
diff --git a/shaders/gst-gl-text-upload-ayuv.frag b/shaders/gst-gl-text-upload-ayuv.frag
new file mode 100644
index 0000000..15a59ed
--- /dev/null
+++ b/shaders/gst-gl-text-upload-ayuv.frag
@@ -0,0 +1,47 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.10
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+ * GStreamer
+ * Copyright (C) 2007 David A. Schleef <ds@schleef.org>
+ * Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
+ * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+uniform sampler2DRect tex;
+void main(void) {
+ float r,g,b,y,u,v;
+ vec2 nxy=gl_TexCoord[0].xy;
+ y=texture2DRect(tex,nxy).r;
+ u=texture2DRect(tex,nxy).g;
+ v=texture2DRect(tex,nxy).b;
+ y=1.1643*(y-0.0625);
+ u=u-0.5;
+ v=v-0.5;
+ r=y+1.5958*v;
+ g=y-0.39173*u-0.81290*v;
+ b=y+2.017*u;
+ gl_FragColor=vec4(r,g,b,1.0);
+}
diff --git a/shaders/gst-gl-text-upload-i420-yv12.frag b/shaders/gst-gl-text-upload-i420-yv12.frag
new file mode 100644
index 0000000..f6b798a
--- /dev/null
+++ b/shaders/gst-gl-text-upload-i420-yv12.frag
@@ -0,0 +1,49 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.10
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+ * GStreamer
+ * Copyright (C) 2007 David A. Schleef <ds@schleef.org>
+ * Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
+ * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+uniform sampler2DRect Ytex,Utex,Vtex;
+void main(void) {
+ float r,g,b,y,u,v;
+ vec2 nxy = gl_TexCoord[0].xy;
+ /* %s replaced with "" in conversion to piglit -- non-ATI version */
+ y=texture2DRect(Ytex,nxy).r;
+ /* %s replaced with "*0.5" in conversion to piglit -- non-ATI version */
+ u=texture2DRect(Utex,nxy*0.5).r;
+ v=texture2DRect(Vtex,nxy*0.5).r;
+ y=1.1643*(y-0.0625);
+ u=u-0.5;
+ v=v-0.5;
+ r=y+1.5958*v;
+ g=y-0.39173*u-0.81290*v;
+ b=y+2.017*u;
+ gl_FragColor=vec4(r,g,b,1.0);
+}
diff --git a/shaders/gst-gl-text-upload-yuy2-uyvy.frag b/shaders/gst-gl-text-upload-yuy2-uyvy.frag
new file mode 100644
index 0000000..93280db
--- /dev/null
+++ b/shaders/gst-gl-text-upload-yuy2-uyvy.frag
@@ -0,0 +1,51 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.10
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+ * GStreamer
+ * Copyright (C) 2007 David A. Schleef <ds@schleef.org>
+ * Copyright (C) 2008 Julien Isorce <julien.isorce@gmail.com>
+ * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+uniform sampler2DRect Ytex, UVtex;
+void main(void) {
+ float fx, fy, y, u, v, r, g, b;
+ fx = gl_TexCoord[0].x;
+ fy = gl_TexCoord[0].y;
+ /* %c replaced with 'r' in conversion to piglit -- YUY2 version */
+ y = texture2DRect(Ytex,vec2(fx,fy)).r;
+ /* %c replaced with 'g' in conversion to piglit -- YUY2 version */
+ u = texture2DRect(UVtex,vec2(fx*0.5,fy)).g;
+ /* %c replaced with 'b' in conversion to piglit -- YUY2 version */
+ v = texture2DRect(UVtex,vec2(fx*0.5,fy)).b;
+ y=1.164*(y-0.0627);
+ u=u-0.5;
+ v=v-0.5;
+ r = y+1.5958*v;
+ g = y-0.39173*u-0.81290*v;
+ b = y+2.017*u;
+ gl_FragColor = vec4(r, g, b, 1.0);
+}
diff --git a/shaders/gst-gl-texture-interp.frag b/shaders/gst-gl-texture-interp.frag
new file mode 100644
index 0000000..41bbdba
--- /dev/null
+++ b/shaders/gst-gl-texture-interp.frag
@@ -0,0 +1,51 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.10
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+ * GStreamer
+ * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+uniform sampler2DRect base;
+uniform sampler2DRect blend;
+uniform sampler2DRect alpha;
+uniform float final_width, final_height;
+uniform float base_width, base_height;
+/*
+uniform float blend_width, blend_height;
+uniform float alpha_width, alpha_height;
+*/
+void main () {
+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 alpha_scale = vec2 (alpha_width, alpha_height) / vec2 (final_width, final_height);
+*/
+
+vec4 basecolor = texture2DRect (base, gl_TexCoord[0].st * base_scale);
+vec4 blendcolor = texture2DRect (blend, gl_TexCoord[0].st);
+vec4 alphacolor = texture2DRect (alpha, gl_TexCoord[0].st);
+gl_FragColor = (alphacolor * blendcolor) + (1.0 - alphacolor) * basecolor;
+}
diff --git a/shaders/gst-gl-tunnel.frag b/shaders/gst-gl-tunnel.frag
new file mode 100644
index 0000000..70f80d0
--- /dev/null
+++ b/shaders/gst-gl-tunnel.frag
@@ -0,0 +1,47 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.10
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+ * GStreamer
+ * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+uniform sampler2DRect tex;
+uniform float width, height;
+void main () {
+ vec2 tex_size = vec2 (width, height);
+ vec2 texturecoord = gl_TexCoord[0].xy;
+ vec2 normcoord;
+ /* little trick with normalized coords to obtain a circle */
+ 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? */
+ 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;
+}
diff --git a/shaders/gst-gl-twirl.frag b/shaders/gst-gl-twirl.frag
new file mode 100644
index 0000000..bb75978
--- /dev/null
+++ b/shaders/gst-gl-twirl.frag
@@ -0,0 +1,46 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.10
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+ * GStreamer
+ * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+uniform sampler2DRect tex;
+uniform float width, height;
+void main () {
+ vec2 tex_size = vec2 (width, height);
+ vec2 texturecoord = gl_TexCoord[0].xy;
+ vec2 normcoord;
+ normcoord = texturecoord / tex_size - 1.0;
+ float r = length (normcoord);
+ float phi = atan (normcoord.y, normcoord.x);
+ phi += (1.0 - smoothstep (-0.6, 0.6, r)) * 4.8;
+ normcoord.x = r * cos(phi);
+ normcoord.y = r * sin(phi);
+ texturecoord = (normcoord + 1.0) * tex_size;
+ vec4 color = texture2DRect (tex, texturecoord);
+ gl_FragColor = color;
+}
diff --git a/shaders/gst-gl-vconv9.frag b/shaders/gst-gl-vconv9.frag
new file mode 100644
index 0000000..e6cdeb1
--- /dev/null
+++ b/shaders/gst-gl-vconv9.frag
@@ -0,0 +1,52 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.20
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+ * GStreamer
+ * Copyright (C) 2008 Filippo Argiolas <filippo.argiolas@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#version 120
+/* The #version was added by anholt in converting to piglit due to the
+ * use of the array constructor.
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+uniform sampler2DRect tex;
+uniform float norm_const;
+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);
+ vec2 texturecoord = gl_TexCoord[0].st;
+ int i;
+ vec4 sum = vec4 (0.0);
+ for (i = 0; i < 9; i++) {
+ if (kernel[i] != 0.0) {
+ vec4 neighbor = texture2DRect(tex, vec2(texturecoord.s, texturecoord.t+offset[i]));
+ sum += neighbor * kernel[i]/norm_const;
+ }
+ }
+ gl_FragColor = sum + norm_offset;
+}
diff --git a/shaders/norsetto-bumptbn_sh_fp.frag b/shaders/norsetto-bumptbn_sh_fp.frag
new file mode 100644
index 0000000..ed90545
--- /dev/null
+++ b/shaders/norsetto-bumptbn_sh_fp.frag
@@ -0,0 +1,68 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.10
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+ * bumpTBN_SH_FP.glsl - ambient, diffuse and specular lighting in tangent space
+ * with shadow mapping and 4-samples PCF
+ *
+ * Simple test GLSL shader
+ * Copyright (c) 2007 Cesare Tirabassi <norsetto@ubuntu.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+varying vec3 lvec, vvec;
+
+uniform sampler2D colorMap;
+uniform sampler2D bumpMap;
+uniform sampler2DShadow shadowMap;
+
+const vec2 texmapscale = vec2( 1.0/1024.0, 1.0/1024.0 );
+
+vec4 offset_lookup(sampler2DShadow map, vec4 loc, vec2 offset )
+{
+ return shadow2DProj( map, vec4(loc.xy + offset * texmapscale * loc.w, loc.z, loc.w ) );
+}
+
+void main()
+{
+ vec3 lv = normalize(lvec);
+ vec3 vv = normalize(vvec);
+ vec3 nv = 2.0*texture2D(bumpMap, gl_TexCoord[0].st).rgb-1.0;
+
+ float diff = max(dot(lv, nv), 0.0);
+
+ float spec = 0.0;
+ if (diff != 0.0)
+ spec = pow( max( dot(-normalize(reflect(lv,nv)), vv), 0.0), 64.0 );
+
+ vec4 texture = texture2D(colorMap, gl_TexCoord[0].st);
+
+ vec2 offset = mod(gl_FragCoord.xy, 2.0);
+
+ offset.y += offset.x;
+ if ( offset.y > 1.1)
+ offset.y = 0.0;
+
+ vec4 shadow = ( offset_lookup( shadowMap, gl_TexCoord[1], offset+vec2(-1.5, 0.5) ) +
+ offset_lookup( shadowMap, gl_TexCoord[1], offset+vec2( 0.5, 0.5) ) +
+ offset_lookup( shadowMap, gl_TexCoord[1], offset+vec2(-1.5, -1.5) ) +
+ offset_lookup( shadowMap, gl_TexCoord[1], offset+vec2( 0.5, -1.5) ) )*0.25;
+
+// vec4 shadow = shadow2DProj(shadowMap, gl_TexCoord[1]);
+
+ gl_FragColor = texture*( shadow*( 0.1 + 0.75 * diff + spec * texture.a ) + 0.2 );
+}
diff --git a/shaders/norsetto-bumptbn_sh_fp.vert b/shaders/norsetto-bumptbn_sh_fp.vert
new file mode 100644
index 0000000..bf93986
--- /dev/null
+++ b/shaders/norsetto-bumptbn_sh_fp.vert
@@ -0,0 +1,45 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.10
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+ * bumpTBN_SH_VP.glsl - transforming to tangent space and computing shadow
+ * mapping matrix
+ *
+ * Simple test GLSL shader
+ * Copyright (c) 2007 Cesare Tirabassi <norsetto@ubuntu.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+varying vec3 lvec, vvec;
+attribute vec3 tangent, binormal;
+
+void main()
+{
+ gl_Position = ftransform();
+
+ gl_TexCoord[0] = gl_MultiTexCoord0;
+
+ gl_TexCoord[1] = gl_TextureMatrix[2] * gl_ModelViewMatrix * gl_Vertex;
+
+ mat3 TBN = mat3(tangent, binormal, gl_Normal);
+
+ lvec = (gl_ModelViewMatrixInverse * gl_LightSource[0].position - gl_Vertex).xyz;
+ lvec *= TBN;
+
+ vvec = (gl_ModelViewMatrixInverse[3] - gl_Vertex).xyz;
+ vvec *= TBN;
+}
diff --git a/shaders/xonotic-vs-generic-diffuse.vert b/shaders/xonotic-vs-generic-diffuse.vert
new file mode 100644
index 0000000..039ce6b
--- /dev/null
+++ b/shaders/xonotic-vs-generic-diffuse.vert
@@ -0,0 +1,1309 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.10
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+Copyright (C) 1996-1997 Id Software, Inc.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+
+/* Modification from original source: Pasted in #defines from the C
+ * source by anholt.
+ */
+#define VERTEX_SHADER
+#define MODE_GENERIC
+#define USEDIFFUSE
+
+/* Begin original shader source. */
+// ambient+diffuse+specular+normalmap+attenuation+cubemap+fog shader
+// written by Forest 'LordHavoc' Hale
+// shadowmapping enhancements by Lee 'eihrul' Salzman
+
+#if defined(USEFOGINSIDE) || defined(USEFOGOUTSIDE) || defined(USEFOGHEIGHTTEXTURE)
+# define USEFOG
+#endif
+#if defined(MODE_LIGHTMAP) || defined(MODE_LIGHTDIRECTIONMAP_MODELSPACE) || defined(MODE_LIGHTDIRECTIONMAP_TANGENTSPACE)
+#define USELIGHTMAP
+#endif
+#if defined(USESPECULAR) || defined(USEOFFSETMAPPING) || defined(USEREFLECTCUBE)
+#define USEEYEVECTOR
+#endif
+
+#if defined(USESHADOWMAPRECT) || defined(MODE_DEFERREDLIGHTSOURCE) || defined(USEDEFERREDLIGHTMAP)
+# extension GL_ARB_texture_rectangle : enable
+#endif
+
+#ifdef USESHADOWMAP2D
+# ifdef GL_EXT_gpu_shader4
+# extension GL_EXT_gpu_shader4 : enable
+# endif
+# ifdef GL_ARB_texture_gather
+# extension GL_ARB_texture_gather : enable
+# else
+# ifdef GL_AMD_texture_texture4
+# extension GL_AMD_texture_texture4 : enable
+# endif
+# endif
+#endif
+
+#ifdef USESHADOWMAPCUBE
+# extension GL_EXT_gpu_shader4 : enable
+#endif
+
+//#ifdef USESHADOWSAMPLER
+//# extension GL_ARB_shadow : enable
+//#endif
+
+//#ifdef __GLSL_CG_DATA_TYPES
+//# define myhalf half
+//# define myhalf2 half2
+//# define myhalf3 half3
+//# define myhalf4 half4
+//#else
+# define myhalf float
+# define myhalf2 vec2
+# define myhalf3 vec3
+# define myhalf4 vec4
+//#endif
+
+#ifdef VERTEX_SHADER
+uniform mat4 ModelViewProjectionMatrix;
+#endif
+
+#ifdef MODE_DEPTH_OR_SHADOW
+#ifdef VERTEX_SHADER
+void main(void)
+{
+ gl_Position = ModelViewProjectionMatrix * gl_Vertex;
+}
+#endif
+#else // !MODE_DEPTH_ORSHADOW
+
+
+
+
+#ifdef MODE_SHOWDEPTH
+#ifdef VERTEX_SHADER
+void main(void)
+{
+ gl_Position = ModelViewProjectionMatrix * gl_Vertex;
+ gl_FrontColor = vec4(gl_Position.z, gl_Position.z, gl_Position.z, 1.0);
+}
+#endif
+
+#ifdef FRAGMENT_SHADER
+void main(void)
+{
+ gl_FragColor = gl_Color;
+}
+#endif
+#else // !MODE_SHOWDEPTH
+
+
+
+
+#ifdef MODE_POSTPROCESS
+varying vec2 TexCoord1;
+varying vec2 TexCoord2;
+
+#ifdef VERTEX_SHADER
+void main(void)
+{
+ gl_Position = ModelViewProjectionMatrix * gl_Vertex;
+ TexCoord1 = gl_MultiTexCoord0.xy;
+#ifdef USEBLOOM
+ TexCoord2 = gl_MultiTexCoord4.xy;
+#endif
+}
+#endif
+
+#ifdef FRAGMENT_SHADER
+uniform sampler2D Texture_First;
+#ifdef USEBLOOM
+uniform sampler2D Texture_Second;
+uniform vec4 BloomColorSubtract;
+#endif
+#ifdef USEGAMMARAMPS
+uniform sampler2D Texture_GammaRamps;
+#endif
+#ifdef USESATURATION
+uniform float Saturation;
+#endif
+#ifdef USEVIEWTINT
+uniform vec4 ViewTintColor;
+#endif
+//uncomment these if you want to use them:
+uniform vec4 UserVec1;
+uniform vec4 UserVec2;
+// uniform vec4 UserVec3;
+// uniform vec4 UserVec4;
+// uniform float ClientTime;
+uniform vec2 PixelSize;
+void main(void)
+{
+ gl_FragColor = texture2D(Texture_First, TexCoord1);
+#ifdef USEBLOOM
+ gl_FragColor += max(vec4(0,0,0,0), texture2D(Texture_Second, TexCoord2) - BloomColorSubtract);
+#endif
+#ifdef USEVIEWTINT
+ gl_FragColor = mix(gl_FragColor, ViewTintColor, ViewTintColor.a);
+#endif
+
+#ifdef USEPOSTPROCESSING
+// do r_glsl_dumpshader, edit glsl/default.glsl, and replace this by your own postprocessing if you want
+// this code does a blur with the radius specified in the first component of r_glsl_postprocess_uservec1 and blends it using the second component
+ float sobel = 1.0;
+ // vec2 ts = textureSize(Texture_First, 0);
+ // vec2 px = vec2(1/ts.x, 1/ts.y);
+ vec2 px = PixelSize;
+ vec3 x1 = texture2D(Texture_First, TexCoord1 + vec2(-px.x, px.y)).rgb;
+ vec3 x2 = texture2D(Texture_First, TexCoord1 + vec2(-px.x, 0.0)).rgb;
+ vec3 x3 = texture2D(Texture_First, TexCoord1 + vec2(-px.x,-px.y)).rgb;
+ vec3 x4 = texture2D(Texture_First, TexCoord1 + vec2( px.x, px.y)).rgb;
+ vec3 x5 = texture2D(Texture_First, TexCoord1 + vec2( px.x, 0.0)).rgb;
+ vec3 x6 = texture2D(Texture_First, TexCoord1 + vec2( px.x,-px.y)).rgb;
+ vec3 y1 = texture2D(Texture_First, TexCoord1 + vec2( px.x,-px.y)).rgb;
+ vec3 y2 = texture2D(Texture_First, TexCoord1 + vec2( 0.0,-px.y)).rgb;
+ vec3 y3 = texture2D(Texture_First, TexCoord1 + vec2(-px.x,-px.y)).rgb;
+ vec3 y4 = texture2D(Texture_First, TexCoord1 + vec2( px.x, px.y)).rgb;
+ vec3 y5 = texture2D(Texture_First, TexCoord1 + vec2( 0.0, px.y)).rgb;
+ vec3 y6 = texture2D(Texture_First, TexCoord1 + vec2(-px.x, px.y)).rgb;
+ float px1 = -1.0 * dot(vec3(0.3, 0.59, 0.11), x1);
+ float px2 = -2.0 * dot(vec3(0.3, 0.59, 0.11), x2);
+ float px3 = -1.0 * dot(vec3(0.3, 0.59, 0.11), x3);
+ float px4 = 1.0 * dot(vec3(0.3, 0.59, 0.11), x4);
+ float px5 = 2.0 * dot(vec3(0.3, 0.59, 0.11), x5);
+ float px6 = 1.0 * dot(vec3(0.3, 0.59, 0.11), x6);
+ float py1 = -1.0 * dot(vec3(0.3, 0.59, 0.11), y1);
+ float py2 = -2.0 * dot(vec3(0.3, 0.59, 0.11), y2);
+ float py3 = -1.0 * dot(vec3(0.3, 0.59, 0.11), y3);
+ float py4 = 1.0 * dot(vec3(0.3, 0.59, 0.11), y4);
+ float py5 = 2.0 * dot(vec3(0.3, 0.59, 0.11), y5);
+ float py6 = 1.0 * dot(vec3(0.3, 0.59, 0.11), y6);
+ sobel = 0.25 * abs(px1 + px2 + px3 + px4 + px5 + px6) + 0.25 * abs(py1 + py2 + py3 + py4 + py5 + py6);
+ gl_FragColor += texture2D(Texture_First, TexCoord1 + PixelSize*UserVec1.x*vec2(-0.987688, -0.156434)) * UserVec1.y;
+ gl_FragColor += texture2D(Texture_First, TexCoord1 + PixelSize*UserVec1.x*vec2(-0.156434, -0.891007)) * UserVec1.y;
+ gl_FragColor += texture2D(Texture_First, TexCoord1 + PixelSize*UserVec1.x*vec2( 0.891007, -0.453990)) * UserVec1.y;
+ gl_FragColor += texture2D(Texture_First, TexCoord1 + PixelSize*UserVec1.x*vec2( 0.707107, 0.707107)) * UserVec1.y;
+ gl_FragColor += texture2D(Texture_First, TexCoord1 + PixelSize*UserVec1.x*vec2(-0.453990, 0.891007)) * UserVec1.y;
+ gl_FragColor /= (1.0 + 5.0 * UserVec1.y);
+ gl_FragColor.rgb = gl_FragColor.rgb * (1.0 + UserVec2.x) + vec3(max(0.0, sobel - UserVec2.z))*UserVec2.y;
+#endif
+
+#ifdef USESATURATION
+ //apply saturation BEFORE gamma ramps, so v_glslgamma value does not matter
+ float y = dot(gl_FragColor.rgb, vec3(0.299, 0.587, 0.114));
+ //gl_FragColor = vec3(y) + (gl_FragColor.rgb - vec3(y)) * Saturation;
+ gl_FragColor.rgb = mix(vec3(y), gl_FragColor.rgb, Saturation);
+#endif
+
+#ifdef USEGAMMARAMPS
+ gl_FragColor.r = texture2D(Texture_GammaRamps, vec2(gl_FragColor.r, 0)).r;
+ gl_FragColor.g = texture2D(Texture_GammaRamps, vec2(gl_FragColor.g, 0)).g;
+ gl_FragColor.b = texture2D(Texture_GammaRamps, vec2(gl_FragColor.b, 0)).b;
+#endif
+}
+#endif
+#else // !MODE_POSTPROCESS
+
+
+
+
+#ifdef MODE_GENERIC
+#ifdef USEDIFFUSE
+varying vec2 TexCoord1;
+#endif
+#ifdef USESPECULAR
+varying vec2 TexCoord2;
+#endif
+#ifdef VERTEX_SHADER
+void main(void)
+{
+ gl_FrontColor = gl_Color;
+#ifdef USEDIFFUSE
+ TexCoord1 = gl_MultiTexCoord0.xy;
+#endif
+#ifdef USESPECULAR
+ TexCoord2 = gl_MultiTexCoord1.xy;
+#endif
+ gl_Position = ModelViewProjectionMatrix * gl_Vertex;
+}
+#endif
+
+#ifdef FRAGMENT_SHADER
+#ifdef USEDIFFUSE
+uniform sampler2D Texture_First;
+#endif
+#ifdef USESPECULAR
+uniform sampler2D Texture_Second;
+#endif
+
+void main(void)
+{
+ gl_FragColor = gl_Color;
+#ifdef USEDIFFUSE
+ gl_FragColor *= texture2D(Texture_First, TexCoord1);
+#endif
+
+#ifdef USESPECULAR
+ vec4 tex2 = texture2D(Texture_Second, TexCoord2);
+# ifdef USECOLORMAPPING
+ gl_FragColor *= tex2;
+# endif
+# ifdef USEGLOW
+ gl_FragColor += tex2;
+# endif
+# ifdef USEVERTEXTEXTUREBLEND
+ gl_FragColor = mix(gl_FragColor, tex2, tex2.a);
+# endif
+#endif
+}
+#endif
+#else // !MODE_GENERIC
+
+
+
+
+#ifdef MODE_BLOOMBLUR
+varying TexCoord;
+#ifdef VERTEX_SHADER
+void main(void)
+{
+ gl_FrontColor = gl_Color;
+ TexCoord = gl_MultiTexCoord0.xy;
+ gl_Position = ModelViewProjectionMatrix * gl_Vertex;
+}
+#endif
+
+#ifdef FRAGMENT_SHADER
+uniform sampler2D Texture_First;
+uniform vec4 BloomBlur_Parameters;
+
+void main(void)
+{
+ int i;
+ vec2 tc = TexCoord;
+ vec3 color = texture2D(Texture_First, tc).rgb;
+ tc += BloomBlur_Parameters.xy;
+ for (i = 1;i < SAMPLES;i++)
+ {
+ color += texture2D(Texture_First, tc).rgb;
+ tc += BloomBlur_Parameters.xy;
+ }
+ gl_FragColor = vec4(color * BloomBlur_Parameters.z + vec3(BloomBlur_Parameters.w), 1);
+}
+#endif
+#else // !MODE_BLOOMBLUR
+#ifdef MODE_REFRACTION
+varying vec2 TexCoord;
+varying vec4 ModelViewProjectionPosition;
+uniform mat4 TexMatrix;
+#ifdef VERTEX_SHADER
+
+void main(void)
+{
+ TexCoord = vec2(TexMatrix * gl_MultiTexCoord0);
+ gl_Position = ModelViewProjectionMatrix * gl_Vertex;
+ ModelViewProjectionPosition = gl_Position;
+}
+#endif
+
+#ifdef FRAGMENT_SHADER
+uniform sampler2D Texture_Normal;
+uniform sampler2D Texture_Refraction;
+uniform sampler2D Texture_Reflection;
+
+uniform vec4 DistortScaleRefractReflect;
+uniform vec4 ScreenScaleRefractReflect;
+uniform vec4 ScreenCenterRefractReflect;
+uniform vec4 RefractColor;
+uniform vec4 ReflectColor;
+uniform float ReflectFactor;
+uniform float ReflectOffset;
+
+void main(void)
+{
+ vec2 ScreenScaleRefractReflectIW = ScreenScaleRefractReflect.xy * (1.0 / ModelViewProjectionPosition.w);
+ //vec2 ScreenTexCoord = (ModelViewProjectionPosition.xy + normalize(vec3(texture2D(Texture_Normal, TexCoord)) - vec3(0.5)).xy * DistortScaleRefractReflect.xy * 100) * ScreenScaleRefractReflectIW + ScreenCenterRefractReflect.xy;
+ vec2 SafeScreenTexCoord = ModelViewProjectionPosition.xy * ScreenScaleRefractReflectIW + ScreenCenterRefractReflect.xy;
+ vec2 ScreenTexCoord = SafeScreenTexCoord + vec2(normalize(vec3(texture2D(Texture_Normal, TexCoord)) - vec3(0.5))).xy * DistortScaleRefractReflect.xy;
+ // FIXME temporary hack to detect the case that the reflection
+ // gets blackened at edges due to leaving the area that contains actual
+ // content.
+ // Remove this 'ack once we have a better way to stop this thing from
+ // 'appening.
+ float f = min(1.0, length(texture2D(Texture_Refraction, ScreenTexCoord + vec2(0.01, 0.01)).rgb) / 0.05);
+ f *= min(1.0, length(texture2D(Texture_Refraction, ScreenTexCoord + vec2(0.01, -0.01)).rgb) / 0.05);
+ f *= min(1.0, length(texture2D(Texture_Refraction, ScreenTexCoord + vec2(-0.01, 0.01)).rgb) / 0.05);
+ f *= min(1.0, length(texture2D(Texture_Refraction, ScreenTexCoord + vec2(-0.01, -0.01)).rgb) / 0.05);
+ ScreenTexCoord = mix(SafeScreenTexCoord, ScreenTexCoord, f);
+ gl_FragColor = texture2D(Texture_Refraction, ScreenTexCoord) * RefractColor;
+}
+#endif
+#else // !MODE_REFRACTION
+
+
+
+
+#ifdef MODE_WATER
+varying vec2 TexCoord;
+varying vec3 EyeVector;
+varying vec4 ModelViewProjectionPosition;
+#ifdef VERTEX_SHADER
+uniform vec3 EyePosition;
+uniform mat4 TexMatrix;
+
+void main(void)
+{
+ TexCoord = vec2(TexMatrix * gl_MultiTexCoord0);
+ vec3 EyeVectorModelSpace = EyePosition - gl_Vertex.xyz;
+ EyeVector.x = dot(EyeVectorModelSpace, gl_MultiTexCoord1.xyz);
+ EyeVector.y = dot(EyeVectorModelSpace, gl_MultiTexCoord2.xyz);
+ EyeVector.z = dot(EyeVectorModelSpace, gl_MultiTexCoord3.xyz);
+ gl_Position = ModelViewProjectionMatrix * gl_Vertex;
+ ModelViewProjectionPosition = gl_Position;
+}
+#endif
+
+#ifdef FRAGMENT_SHADER
+uniform sampler2D Texture_Normal;
+uniform sampler2D Texture_Refraction;
+uniform sampler2D Texture_Reflection;
+
+uniform vec4 DistortScaleRefractReflect;
+uniform vec4 ScreenScaleRefractReflect;
+uniform vec4 ScreenCenterRefractReflect;
+uniform vec4 RefractColor;
+uniform vec4 ReflectColor;
+uniform float ReflectFactor;
+uniform float ReflectOffset;
+
+void main(void)
+{
+ vec4 ScreenScaleRefractReflectIW = ScreenScaleRefractReflect * (1.0 / ModelViewProjectionPosition.w);
+ //vec4 ScreenTexCoord = (ModelViewProjectionPosition.xyxy + normalize(vec3(texture2D(Texture_Normal, TexCoord)) - vec3(0.5)).xyxy * DistortScaleRefractReflect * 100) * ScreenScaleRefractReflectIW + ScreenCenterRefractReflect;
+ vec4 SafeScreenTexCoord = ModelViewProjectionPosition.xyxy * ScreenScaleRefractReflectIW + ScreenCenterRefractReflect;
+ //SafeScreenTexCoord = gl_FragCoord.xyxy * vec4(1.0 / 1920.0, 1.0 / 1200.0, 1.0 / 1920.0, 1.0 / 1200.0);
+ vec4 ScreenTexCoord = SafeScreenTexCoord + vec2(normalize(vec3(texture2D(Texture_Normal, TexCoord)) - vec3(0.5))).xyxy * DistortScaleRefractReflect;
+ // FIXME temporary hack to detect the case that the reflection
+ // gets blackened at edges due to leaving the area that contains actual
+ // content.
+ // Remove this 'ack once we have a better way to stop this thing from
+ // 'appening.
+ float f = min(1.0, length(texture2D(Texture_Refraction, ScreenTexCoord.xy + vec2(0.01, 0.01)).rgb) / 0.05);
+ f *= min(1.0, length(texture2D(Texture_Refraction, ScreenTexCoord.xy + vec2(0.01, -0.01)).rgb) / 0.05);
+ f *= min(1.0, length(texture2D(Texture_Refraction, ScreenTexCoord.xy + vec2(-0.01, 0.01)).rgb) / 0.05);
+ f *= min(1.0, length(texture2D(Texture_Refraction, ScreenTexCoord.xy + vec2(-0.01, -0.01)).rgb) / 0.05);
+ ScreenTexCoord.xy = mix(SafeScreenTexCoord.xy, ScreenTexCoord.xy, f);
+ f = min(1.0, length(texture2D(Texture_Reflection, ScreenTexCoord.zw + vec2(0.01, 0.01)).rgb) / 0.05);
+ f *= min(1.0, length(texture2D(Texture_Reflection, ScreenTexCoord.zw + vec2(0.01, -0.01)).rgb) / 0.05);
+ f *= min(1.0, length(texture2D(Texture_Reflection, ScreenTexCoord.zw + vec2(-0.01, 0.01)).rgb) / 0.05);
+ f *= min(1.0, length(texture2D(Texture_Reflection, ScreenTexCoord.zw + vec2(-0.01, -0.01)).rgb) / 0.05);
+ ScreenTexCoord.zw = mix(SafeScreenTexCoord.zw, ScreenTexCoord.zw, f);
+ float Fresnel = pow(min(1.0, 1.0 - float(normalize(EyeVector).z)), 2.0) * ReflectFactor + ReflectOffset;
+ gl_FragColor = mix(texture2D(Texture_Refraction, ScreenTexCoord.xy) * RefractColor, texture2D(Texture_Reflection, ScreenTexCoord.zw) * ReflectColor, Fresnel);
+}
+#endif
+#else // !MODE_WATER
+
+
+
+
+// common definitions between vertex shader and fragment shader:
+
+varying vec2 TexCoord;
+#ifdef USEVERTEXTEXTUREBLEND
+varying vec2 TexCoord2;
+#endif
+#ifdef USELIGHTMAP
+varying vec2 TexCoordLightmap;
+#endif
+
+#ifdef MODE_LIGHTSOURCE
+varying vec3 CubeVector;
+#endif
+
+#if (defined(MODE_LIGHTSOURCE) || defined(MODE_LIGHTDIRECTION)) && defined(USEDIFFUSE)
+varying vec3 LightVector;
+#endif
+
+#ifdef USEEYEVECTOR
+varying vec3 EyeVector;
+#endif
+#ifdef USEFOG
+varying vec4 EyeVectorModelSpaceFogPlaneVertexDist;
+#endif
+
+#if defined(MODE_LIGHTDIRECTIONMAP_MODELSPACE) || defined(MODE_DEFERREDGEOMETRY) || defined(USEREFLECTCUBE)
+varying vec3 VectorS; // direction of S texcoord (sometimes crudely called tangent)
+varying vec3 VectorT; // direction of T texcoord (sometimes crudely called binormal)
+varying vec3 VectorR; // direction of R texcoord (surface normal)
+#endif
+
+#ifdef USEREFLECTION
+varying vec4 ModelViewProjectionPosition;
+#endif
+#ifdef MODE_DEFERREDLIGHTSOURCE
+uniform vec3 LightPosition;
+varying vec4 ModelViewPosition;
+#endif
+
+#ifdef MODE_LIGHTSOURCE
+uniform vec3 LightPosition;
+#endif
+uniform vec3 EyePosition;
+#ifdef MODE_LIGHTDIRECTION
+uniform vec3 LightDir;
+#endif
+uniform vec4 FogPlane;
+
+#ifdef USESHADOWMAPORTHO
+varying vec3 ShadowMapTC;
+#endif
+
+
+
+
+
+// TODO: get rid of tangentt (texcoord2) and use a crossproduct to regenerate it from tangents (texcoord1) and normal (texcoord3), this would require sending a 4 component texcoord1 with W as 1 or -1 according to which side the texcoord2 should be on
+
+// fragment shader specific:
+#ifdef FRAGMENT_SHADER
+
+uniform sampler2D Texture_Normal;
+uniform sampler2D Texture_Color;
+uniform sampler2D Texture_Gloss;
+#ifdef USEGLOW
+uniform sampler2D Texture_Glow;
+#endif
+#ifdef USEVERTEXTEXTUREBLEND
+uniform sampler2D Texture_SecondaryNormal;
+uniform sampler2D Texture_SecondaryColor;
+uniform sampler2D Texture_SecondaryGloss;
+#ifdef USEGLOW
+uniform sampler2D Texture_SecondaryGlow;
+#endif
+#endif
+#ifdef USECOLORMAPPING
+uniform sampler2D Texture_Pants;
+uniform sampler2D Texture_Shirt;
+#endif
+#ifdef USEFOG
+#ifdef USEFOGHEIGHTTEXTURE
+uniform sampler2D Texture_FogHeightTexture;
+#endif
+uniform sampler2D Texture_FogMask;
+#endif
+#ifdef USELIGHTMAP
+uniform sampler2D Texture_Lightmap;
+#endif
+#if defined(MODE_LIGHTDIRECTIONMAP_MODELSPACE) || defined(MODE_LIGHTDIRECTIONMAP_TANGENTSPACE)
+uniform sampler2D Texture_Deluxemap;
+#endif
+#ifdef USEREFLECTION
+uniform sampler2D Texture_Reflection;
+#endif
+
+#ifdef MODE_DEFERREDLIGHTSOURCE
+uniform sampler2D Texture_ScreenDepth;
+uniform sampler2D Texture_ScreenNormalMap;
+#endif
+#ifdef USEDEFERREDLIGHTMAP
+uniform sampler2D Texture_ScreenDiffuse;
+uniform sampler2D Texture_ScreenSpecular;
+#endif
+
+uniform myhalf3 Color_Pants;
+uniform myhalf3 Color_Shirt;
+uniform myhalf3 FogColor;
+
+#ifdef USEFOG
+uniform float FogRangeRecip;
+uniform float FogPlaneViewDist;
+uniform float FogHeightFade;
+vec3 FogVertex(vec3 surfacecolor)
+{
+ vec3 EyeVectorModelSpace = EyeVectorModelSpaceFogPlaneVertexDist.xyz;
+ float FogPlaneVertexDist = EyeVectorModelSpaceFogPlaneVertexDist.w;
+ float fogfrac;
+#ifdef USEFOGHEIGHTTEXTURE
+ vec4 fogheightpixel = texture2D(Texture_FogHeightTexture, vec2(1,1) + vec2(FogPlaneVertexDist, FogPlaneViewDist) * (-2.0 * FogHeightFade));
+ fogfrac = fogheightpixel.a;
+ return mix(fogheightpixel.rgb * FogColor, surfacecolor, texture2D(Texture_FogMask, myhalf2(length(EyeVectorModelSpace)*fogfrac*FogRangeRecip, 0.0)).r);
+#else
+# ifdef USEFOGOUTSIDE
+ fogfrac = min(0.0, FogPlaneVertexDist) / (FogPlaneVertexDist - FogPlaneViewDist) * min(1.0, min(0.0, FogPlaneVertexDist) * FogHeightFade);
+# else
+ fogfrac = FogPlaneViewDist / (FogPlaneViewDist - max(0.0, FogPlaneVertexDist)) * min(1.0, (min(0.0, FogPlaneVertexDist) + FogPlaneViewDist) * FogHeightFade);
+# endif
+ return mix(FogColor, surfacecolor, texture2D(Texture_FogMask, myhalf2(length(EyeVectorModelSpace)*fogfrac*FogRangeRecip, 0.0)).r);
+#endif
+}
+#endif
+
+#ifdef USEOFFSETMAPPING
+uniform float OffsetMapping_Scale;
+vec2 OffsetMapping(vec2 TexCoord)
+{
+#ifdef USEOFFSETMAPPING_RELIEFMAPPING
+ // 14 sample relief mapping: linear search and then binary search
+ // this basically steps forward a small amount repeatedly until it finds
+ // itself inside solid, then jitters forward and back using decreasing
+ // amounts to find the impact
+ //vec3 OffsetVector = vec3(EyeVector.xy * ((1.0 / EyeVector.z) * OffsetMapping_Scale) * vec2(-1, 1), -1);
+ //vec3 OffsetVector = vec3(normalize(EyeVector.xy) * OffsetMapping_Scale * vec2(-1, 1), -1);
+ vec3 OffsetVector = vec3(normalize(EyeVector).xy * OffsetMapping_Scale * vec2(-1, 1), -1);
+ vec3 RT = vec3(TexCoord, 1);
+ OffsetVector *= 0.1;
+ RT += OffsetVector * step(texture2D(Texture_Normal, RT.xy).a, RT.z);
+ RT += OffsetVector * step(texture2D(Texture_Normal, RT.xy).a, RT.z);
+ RT += OffsetVector * step(texture2D(Texture_Normal, RT.xy).a, RT.z);
+ RT += OffsetVector * step(texture2D(Texture_Normal, RT.xy).a, RT.z);
+ RT += OffsetVector * step(texture2D(Texture_Normal, RT.xy).a, RT.z);
+ RT += OffsetVector * step(texture2D(Texture_Normal, RT.xy).a, RT.z);
+ RT += OffsetVector * step(texture2D(Texture_Normal, RT.xy).a, RT.z);
+ RT += OffsetVector * step(texture2D(Texture_Normal, RT.xy).a, RT.z);
+ RT += OffsetVector * step(texture2D(Texture_Normal, RT.xy).a, RT.z);
+ RT += OffsetVector * (step(texture2D(Texture_Normal, RT.xy).a, RT.z) - 0.5);
+ RT += OffsetVector * (step(texture2D(Texture_Normal, RT.xy).a, RT.z) * 0.5 - 0.25);
+ RT += OffsetVector * (step(texture2D(Texture_Normal, RT.xy).a, RT.z) * 0.25 - 0.125);
+ RT += OffsetVector * (step(texture2D(Texture_Normal, RT.xy).a, RT.z) * 0.125 - 0.0625);
+ RT += OffsetVector * (step(texture2D(Texture_Normal, RT.xy).a, RT.z) * 0.0625 - 0.03125);
+ return RT.xy;
+#else
+ // 3 sample offset mapping (only 3 samples because of ATI Radeon 9500-9800/X300 limits)
+ // this basically moves forward the full distance, and then backs up based
+ // on height of samples
+ //vec2 OffsetVector = vec2(EyeVector.xy * ((1.0 / EyeVector.z) * OffsetMapping_Scale) * vec2(-1, 1));
+ //vec2 OffsetVector = vec2(normalize(EyeVector.xy) * OffsetMapping_Scale * vec2(-1, 1));
+ vec2 OffsetVector = vec2(normalize(EyeVector).xy * OffsetMapping_Scale * vec2(-1, 1));
+ TexCoord += OffsetVector;
+ OffsetVector *= 0.333;
+ TexCoord -= OffsetVector * texture2D(Texture_Normal, TexCoord).a;
+ TexCoord -= OffsetVector * texture2D(Texture_Normal, TexCoord).a;
+ TexCoord -= OffsetVector * texture2D(Texture_Normal, TexCoord).a;
+ return TexCoord;
+#endif
+}
+#endif // USEOFFSETMAPPING
+
+#if defined(MODE_LIGHTSOURCE) || defined(MODE_DEFERREDLIGHTSOURCE)
+uniform sampler2D Texture_Attenuation;
+uniform samplerCube Texture_Cube;
+#endif
+
+#if defined(MODE_LIGHTSOURCE) || defined(MODE_DEFERREDLIGHTSOURCE) || defined(USESHADOWMAPORTHO)
+
+#ifdef USESHADOWMAPRECT
+# ifdef USESHADOWSAMPLER
+uniform sampler2DRectShadow Texture_ShadowMapRect;
+# else
+uniform sampler2DRect Texture_ShadowMapRect;
+# endif
+#endif
+
+#ifdef USESHADOWMAP2D
+# ifdef USESHADOWSAMPLER
+uniform sampler2DShadow Texture_ShadowMap2D;
+# else
+uniform sampler2D Texture_ShadowMap2D;
+# endif
+#endif
+
+#ifdef USESHADOWMAPVSDCT
+uniform samplerCube Texture_CubeProjection;
+#endif
+
+#ifdef USESHADOWMAPCUBE
+# ifdef USESHADOWSAMPLER
+uniform samplerCubeShadow Texture_ShadowMapCube;
+# else
+uniform samplerCube Texture_ShadowMapCube;
+# endif
+#endif
+
+#if defined(USESHADOWMAPRECT) || defined(USESHADOWMAP2D) || defined(USESHADOWMAPCUBE)
+uniform vec2 ShadowMap_TextureScale;
+uniform vec4 ShadowMap_Parameters;
+#endif
+
+#if defined(USESHADOWMAPRECT) || defined(USESHADOWMAP2D)
+# ifdef USESHADOWMAPORTHO
+# define GetShadowMapTC2D(dir) (min(dir, ShadowMap_Parameters.xyz))
+# else
+# ifdef USESHADOWMAPVSDCT
+vec3 GetShadowMapTC2D(vec3 dir)
+{
+ vec3 adir = abs(dir);
+ vec2 aparams = ShadowMap_Parameters.xy / max(max(adir.x, adir.y), adir.z);
+ vec4 proj = textureCube(Texture_CubeProjection, dir);
+ return vec3(mix(dir.xy, dir.zz, proj.xy) * aparams.x + proj.zw * ShadowMap_Parameters.z, aparams.y + ShadowMap_Parameters.w);
+}
+# else
+vec3 GetShadowMapTC2D(vec3 dir)
+{
+ vec3 adir = abs(dir);
+ float ma = adir.z;
+ vec4 proj = vec4(dir, 2.5);
+ if (adir.x > ma) { ma = adir.x; proj = vec4(dir.zyx, 0.5); }
+ if (adir.y > ma) { ma = adir.y; proj = vec4(dir.xzy, 1.5); }
+ vec2 aparams = ShadowMap_Parameters.xy / ma;
+ return vec3(proj.xy * aparams.x + vec2(proj.z < 0.0 ? 1.5 : 0.5, proj.w) * ShadowMap_Parameters.z, aparams.y + ShadowMap_Parameters.w);
+}
+# endif
+# endif
+#endif // defined(USESHADOWMAPRECT) || defined(USESHADOWMAP2D)
+
+#ifdef USESHADOWMAPCUBE
+vec4 GetShadowMapTCCube(vec3 dir)
+{
+ vec3 adir = abs(dir);
+ return vec4(dir, ShadowMap_Parameters.w + ShadowMap_Parameters.y / max(max(adir.x, adir.y), adir.z));
+}
+#endif
+
+# ifdef USESHADOWMAPRECT
+float ShadowMapCompare(vec3 dir)
+{
+ vec3 shadowmaptc = GetShadowMapTC2D(dir);
+ float f;
+# ifdef USESHADOWSAMPLER
+
+# ifdef USESHADOWMAPPCF
+# define texval(x, y) shadow2DRect(Texture_ShadowMapRect, shadowmaptc + vec3(x, y, 0.0)).r
+ f = dot(vec4(0.25), vec4(texval(-0.4, 1.0), texval(-1.0, -0.4), texval(0.4, -1.0), texval(1.0, 0.4)));
+# else
+ f = shadow2DRect(Texture_ShadowMapRect, shadowmaptc).r;
+# endif
+
+# else
+
+# ifdef USESHADOWMAPPCF
+# if USESHADOWMAPPCF > 1
+# define texval(x, y) texture2DRect(Texture_ShadowMapRect, center + vec2(x, y)).r
+ vec2 center = shadowmaptc.xy - 0.5, offset = fract(center);
+ vec4 row1 = step(shadowmaptc.z, vec4(texval(-1.0, -1.0), texval( 0.0, -1.0), texval( 1.0, -1.0), texval( 2.0, -1.0)));
+ vec4 row2 = step(shadowmaptc.z, vec4(texval(-1.0, 0.0), texval( 0.0, 0.0), texval( 1.0, 0.0), texval( 2.0, 0.0)));
+ vec4 row3 = step(shadowmaptc.z, vec4(texval(-1.0, 1.0), texval( 0.0, 1.0), texval( 1.0, 1.0), texval( 2.0, 1.0)));
+ vec4 row4 = step(shadowmaptc.z, vec4(texval(-1.0, 2.0), texval( 0.0, 2.0), texval( 1.0, 2.0), texval( 2.0, 2.0)));
+ vec4 cols = row2 + row3 + mix(row1, row4, offset.y);
+ f = dot(mix(cols.xyz, cols.yzw, offset.x), vec3(1.0/9.0));
+# else
+# define texval(x, y) texture2DRect(Texture_ShadowMapRect, shadowmaptc.xy + vec2(x, y)).r
+ vec2 offset = fract(shadowmaptc.xy);
+ vec3 row1 = step(shadowmaptc.z, vec3(texval(-1.0, -1.0), texval( 0.0, -1.0), texval( 1.0, -1.0)));
+ vec3 row2 = step(shadowmaptc.z, vec3(texval(-1.0, 0.0), texval( 0.0, 0.0), texval( 1.0, 0.0)));
+ vec3 row3 = step(shadowmaptc.z, vec3(texval(-1.0, 1.0), texval( 0.0, 1.0), texval( 1.0, 1.0)));
+ vec3 cols = row2 + mix(row1, row3, offset.y);
+ f = dot(mix(cols.xy, cols.yz, offset.x), vec2(0.25));
+# endif
+# else
+ f = step(shadowmaptc.z, texture2DRect(Texture_ShadowMapRect, shadowmaptc.xy).r);
+# endif
+
+# endif
+# ifdef USESHADOWMAPORTHO
+ return mix(ShadowMap_Parameters.w, 1.0, f);
+# else
+ return f;
+# endif
+}
+# endif
+
+# ifdef USESHADOWMAP2D
+float ShadowMapCompare(vec3 dir)
+{
+ vec3 shadowmaptc = GetShadowMapTC2D(dir);
+ float f;
+
+# ifdef USESHADOWSAMPLER
+# ifdef USESHADOWMAPPCF
+# define texval(x, y) shadow2D(Texture_ShadowMap2D, vec3(center + vec2(x, y)*ShadowMap_TextureScale, shadowmaptc.z)).r
+ vec2 center = shadowmaptc.xy*ShadowMap_TextureScale;
+ f = dot(vec4(0.25), vec4(texval(-0.4, 1.0), texval(-1.0, -0.4), texval(0.4, -1.0), texval(1.0, 0.4)));
+# else
+ f = shadow2D(Texture_ShadowMap2D, vec3(shadowmaptc.xy*ShadowMap_TextureScale, shadowmaptc.z)).r;
+# endif
+# else
+# ifdef USESHADOWMAPPCF
+# if defined(GL_ARB_texture_gather) || defined(GL_AMD_texture_texture4)
+# ifdef GL_ARB_texture_gather
+# define texval(x, y) textureGatherOffset(Texture_ShadowMap2D, center, ivec2(x, y))
+# else
+# define texval(x, y) texture4(Texture_ShadowMap2D, center + vec2(x, y)*ShadowMap_TextureScale)
+# endif
+ vec2 offset = fract(shadowmaptc.xy - 0.5), center = (shadowmaptc.xy - offset)*ShadowMap_TextureScale;
+# if USESHADOWMAPPCF > 1
+ vec4 group1 = step(shadowmaptc.z, texval(-2.0, -2.0));
+ vec4 group2 = step(shadowmaptc.z, texval( 0.0, -2.0));
+ vec4 group3 = step(shadowmaptc.z, texval( 2.0, -2.0));
+ vec4 group4 = step(shadowmaptc.z, texval(-2.0, 0.0));
+ vec4 group5 = step(shadowmaptc.z, texval( 0.0, 0.0));
+ vec4 group6 = step(shadowmaptc.z, texval( 2.0, 0.0));
+ vec4 group7 = step(shadowmaptc.z, texval(-2.0, 2.0));
+ vec4 group8 = step(shadowmaptc.z, texval( 0.0, 2.0));
+ vec4 group9 = step(shadowmaptc.z, texval( 2.0, 2.0));
+ vec4 locols = vec4(group1.ab, group3.ab);
+ vec4 hicols = vec4(group7.rg, group9.rg);
+ locols.yz += group2.ab;
+ hicols.yz += group8.rg;
+ vec4 midcols = vec4(group1.rg, group3.rg) + vec4(group7.ab, group9.ab) +
+ vec4(group4.rg, group6.rg) + vec4(group4.ab, group6.ab) +
+ mix(locols, hicols, offset.y);
+ vec4 cols = group5 + vec4(group2.rg, group8.ab);
+ cols.xyz += mix(midcols.xyz, midcols.yzw, offset.x);
+ f = dot(cols, vec4(1.0/25.0));
+# else
+ vec4 group1 = step(shadowmaptc.z, texval(-1.0, -1.0));
+ vec4 group2 = step(shadowmaptc.z, texval( 1.0, -1.0));
+ vec4 group3 = step(shadowmaptc.z, texval(-1.0, 1.0));
+ vec4 group4 = step(shadowmaptc.z, texval( 1.0, 1.0));
+ vec4 cols = vec4(group1.rg, group2.rg) + vec4(group3.ab, group4.ab) +
+ mix(vec4(group1.ab, group2.ab), vec4(group3.rg, group4.rg), offset.y);
+ f = dot(mix(cols.xyz, cols.yzw, offset.x), vec3(1.0/9.0));
+# endif
+# else
+# ifdef GL_EXT_gpu_shader4
+# define texval(x, y) texture2DOffset(Texture_ShadowMap2D, center, ivec2(x, y)).r
+# else
+# define texval(x, y) texture2D(Texture_ShadowMap2D, center + vec2(x, y)*ShadowMap_TextureScale).r
+# endif
+# if USESHADOWMAPPCF > 1
+ vec2 center = shadowmaptc.xy - 0.5, offset = fract(center);
+ center *= ShadowMap_TextureScale;
+ vec4 row1 = step(shadowmaptc.z, vec4(texval(-1.0, -1.0), texval( 0.0, -1.0), texval( 1.0, -1.0), texval( 2.0, -1.0)));
+ vec4 row2 = step(shadowmaptc.z, vec4(texval(-1.0, 0.0), texval( 0.0, 0.0), texval( 1.0, 0.0), texval( 2.0, 0.0)));
+ vec4 row3 = step(shadowmaptc.z, vec4(texval(-1.0, 1.0), texval( 0.0, 1.0), texval( 1.0, 1.0), texval( 2.0, 1.0)));
+ vec4 row4 = step(shadowmaptc.z, vec4(texval(-1.0, 2.0), texval( 0.0, 2.0), texval( 1.0, 2.0), texval( 2.0, 2.0)));
+ vec4 cols = row2 + row3 + mix(row1, row4, offset.y);
+ f = dot(mix(cols.xyz, cols.yzw, offset.x), vec3(1.0/9.0));
+# else
+ vec2 center = shadowmaptc.xy*ShadowMap_TextureScale, offset = fract(shadowmaptc.xy);
+ vec3 row1 = step(shadowmaptc.z, vec3(texval(-1.0, -1.0), texval( 0.0, -1.0), texval( 1.0, -1.0)));
+ vec3 row2 = step(shadowmaptc.z, vec3(texval(-1.0, 0.0), texval( 0.0, 0.0), texval( 1.0, 0.0)));
+ vec3 row3 = step(shadowmaptc.z, vec3(texval(-1.0, 1.0), texval( 0.0, 1.0), texval( 1.0, 1.0)));
+ vec3 cols = row2 + mix(row1, row3, offset.y);
+ f = dot(mix(cols.xy, cols.yz, offset.x), vec2(0.25));
+# endif
+# endif
+# else
+ f = step(shadowmaptc.z, texture2D(Texture_ShadowMap2D, shadowmaptc.xy*ShadowMap_TextureScale).r);
+# endif
+# endif
+# ifdef USESHADOWMAPORTHO
+ return mix(ShadowMap_Parameters.w, 1.0, f);
+# else
+ return f;
+# endif
+}
+# endif
+
+# ifdef USESHADOWMAPCUBE
+float ShadowMapCompare(vec3 dir)
+{
+ // apply depth texture cubemap as light filter
+ vec4 shadowmaptc = GetShadowMapTCCube(dir);
+ float f;
+# ifdef USESHADOWSAMPLER
+ f = shadowCube(Texture_ShadowMapCube, shadowmaptc).r;
+# else
+ f = step(shadowmaptc.w, textureCube(Texture_ShadowMapCube, shadowmaptc.xyz).r);
+# endif
+ return f;
+}
+# endif
+#endif // !defined(MODE_LIGHTSOURCE) && !defined(MODE_DEFERREDLIGHTSOURCE) && !defined(USESHADOWMAPORTHO)
+#endif // FRAGMENT_SHADER
+
+
+
+
+#ifdef MODE_DEFERREDGEOMETRY
+#ifdef VERTEX_SHADER
+uniform mat4 TexMatrix;
+#ifdef USEVERTEXTEXTUREBLEND
+uniform mat4 BackgroundTexMatrix;
+#endif
+uniform mat4 ModelViewMatrix;
+void main(void)
+{
+ TexCoord = vec2(TexMatrix * gl_MultiTexCoord0);
+#ifdef USEVERTEXTEXTUREBLEND
+ gl_FrontColor = gl_Color;
+ TexCoord2 = vec2(BackgroundTexMatrix * gl_MultiTexCoord0);
+#endif
+
+ // transform unnormalized eye direction into tangent space
+#ifdef USEOFFSETMAPPING
+ vec3 EyeVectorModelSpace = EyePosition - gl_Vertex.xyz;
+ EyeVector.x = dot(EyeVectorModelSpace, gl_MultiTexCoord1.xyz);
+ EyeVector.y = dot(EyeVectorModelSpace, gl_MultiTexCoord2.xyz);
+ EyeVector.z = dot(EyeVectorModelSpace, gl_MultiTexCoord3.xyz);
+#endif
+
+ VectorS = (ModelViewMatrix * vec4(gl_MultiTexCoord1.xyz, 0)).xyz;
+ VectorT = (ModelViewMatrix * vec4(gl_MultiTexCoord2.xyz, 0)).xyz;
+ VectorR = (ModelViewMatrix * vec4(gl_MultiTexCoord3.xyz, 0)).xyz;
+ gl_Position = ModelViewProjectionMatrix * gl_Vertex;
+}
+#endif // VERTEX_SHADER
+
+#ifdef FRAGMENT_SHADER
+void main(void)
+{
+#ifdef USEOFFSETMAPPING
+ // apply offsetmapping
+ vec2 TexCoordOffset = OffsetMapping(TexCoord);
+#define TexCoord TexCoordOffset
+#endif
+
+#ifdef USEALPHAKILL
+ if (texture2D(Texture_Color, TexCoord).a < 0.5)
+ discard;
+#endif
+
+#ifdef USEVERTEXTEXTUREBLEND
+ float alpha = texture2D(Texture_Color, TexCoord).a;
+ float terrainblend = clamp(float(gl_Color.a) * alpha * 2.0 - 0.5, float(0.0), float(1.0));
+ //float terrainblend = min(float(gl_Color.a) * alpha * 2.0, float(1.0));
+ //float terrainblend = float(gl_Color.a) * alpha > 0.5;
+#endif
+
+#ifdef USEVERTEXTEXTUREBLEND
+ vec3 surfacenormal = mix(vec3(texture2D(Texture_SecondaryNormal, TexCoord2)), vec3(texture2D(Texture_Normal, TexCoord)), terrainblend) - vec3(0.5, 0.5, 0.5);
+ float a = mix(texture2D(Texture_SecondaryGloss, TexCoord2).a, texture2D(Texture_Gloss, TexCoord).a, terrainblend);
+#else
+ vec3 surfacenormal = vec3(texture2D(Texture_Normal, TexCoord)) - vec3(0.5, 0.5, 0.5);
+ float a = texture2D(Texture_Gloss, TexCoord).a;
+#endif
+
+ gl_FragColor = vec4(normalize(surfacenormal.x * VectorS + surfacenormal.y * VectorT + surfacenormal.z * VectorR) * 0.5 + vec3(0.5, 0.5, 0.5), a);
+}
+#endif // FRAGMENT_SHADER
+#else // !MODE_DEFERREDGEOMETRY
+
+
+
+
+#ifdef MODE_DEFERREDLIGHTSOURCE
+#ifdef VERTEX_SHADER
+uniform mat4 ModelViewMatrix;
+void main(void)
+{
+ ModelViewPosition = ModelViewMatrix * gl_Vertex;
+ gl_Position = ModelViewProjectionMatrix * gl_Vertex;
+}
+#endif // VERTEX_SHADER
+
+#ifdef FRAGMENT_SHADER
+uniform mat4 ViewToLight;
+// ScreenToDepth = vec2(Far / (Far - Near), Far * Near / (Near - Far));
+uniform vec2 ScreenToDepth;
+uniform myhalf3 DeferredColor_Ambient;
+uniform myhalf3 DeferredColor_Diffuse;
+#ifdef USESPECULAR
+uniform myhalf3 DeferredColor_Specular;
+uniform myhalf SpecularPower;
+#endif
+uniform myhalf2 PixelToScreenTexCoord;
+void main(void)
+{
+ // calculate viewspace pixel position
+ vec2 ScreenTexCoord = gl_FragCoord.xy * PixelToScreenTexCoord;
+ vec3 position;
+ position.z = ScreenToDepth.y / (texture2D(Texture_ScreenDepth, ScreenTexCoord).r + ScreenToDepth.x);
+ position.xy = ModelViewPosition.xy * (position.z / ModelViewPosition.z);
+ // decode viewspace pixel normal
+ myhalf4 normalmap = texture2D(Texture_ScreenNormalMap, ScreenTexCoord);
+ myhalf3 surfacenormal = normalize(normalmap.rgb - myhalf3(0.5,0.5,0.5));
+ // surfacenormal = pixel normal in viewspace
+ // LightVector = pixel to light in viewspace
+ // CubeVector = position in lightspace
+ // eyevector = pixel to view in viewspace
+ vec3 CubeVector = vec3(ViewToLight * vec4(position,1));
+ myhalf fade = myhalf(texture2D(Texture_Attenuation, vec2(length(CubeVector), 0.0)));
+#ifdef USEDIFFUSE
+ // calculate diffuse shading
+ myhalf3 lightnormal = myhalf3(normalize(LightPosition - position));
+ myhalf diffuse = myhalf(max(float(dot(surfacenormal, lightnormal)), 0.0));
+#endif
+#ifdef USESPECULAR
+ // calculate directional shading
+ vec3 eyevector = position * -1.0;
+# ifdef USEEXACTSPECULARMATH
+ myhalf specular = pow(myhalf(max(float(dot(reflect(lightnormal, surfacenormal), normalize(eyevector)))*-1.0, 0.0)), SpecularPower * normalmap.a);
+# else
+ myhalf3 specularnormal = normalize(lightnormal + myhalf3(normalize(eyevector)));
+ myhalf specular = pow(myhalf(max(float(dot(surfacenormal, specularnormal)), 0.0)), SpecularPower * normalmap.a);
+# endif
+#endif
+
+#if defined(USESHADOWMAPRECT) || defined(USESHADOWMAPCUBE) || defined(USESHADOWMAP2D)
+ fade *= ShadowMapCompare(CubeVector);
+#endif
+
+#ifdef USEDIFFUSE
+ gl_FragData[0] = vec4((DeferredColor_Ambient + DeferredColor_Diffuse * diffuse) * fade, 1.0);
+#else
+ gl_FragData[0] = vec4(DeferredColor_Ambient * fade, 1.0);
+#endif
+#ifdef USESPECULAR
+ gl_FragData[1] = vec4(DeferredColor_Specular * (specular * fade), 1.0);
+#else
+ gl_FragData[1] = vec4(0.0, 0.0, 0.0, 1.0);
+#endif
+
+# ifdef USECUBEFILTER
+ vec3 cubecolor = textureCube(Texture_Cube, CubeVector).rgb;
+ gl_FragData[0].rgb *= cubecolor;
+ gl_FragData[1].rgb *= cubecolor;
+# endif
+}
+#endif // FRAGMENT_SHADER
+#else // !MODE_DEFERREDLIGHTSOURCE
+
+
+
+
+#ifdef VERTEX_SHADER
+uniform mat4 TexMatrix;
+#ifdef USEVERTEXTEXTUREBLEND
+uniform mat4 BackgroundTexMatrix;
+#endif
+#ifdef MODE_LIGHTSOURCE
+uniform mat4 ModelToLight;
+#endif
+#ifdef USESHADOWMAPORTHO
+uniform mat4 ShadowMapMatrix;
+#endif
+void main(void)
+{
+#if defined(MODE_VERTEXCOLOR) || defined(USEVERTEXTEXTUREBLEND)
+ gl_FrontColor = gl_Color;
+#endif
+ // copy the surface texcoord
+ TexCoord = vec2(TexMatrix * gl_MultiTexCoord0);
+#ifdef USEVERTEXTEXTUREBLEND
+ TexCoord2 = vec2(BackgroundTexMatrix * gl_MultiTexCoord0);
+#endif
+#ifdef USELIGHTMAP
+ TexCoordLightmap = vec2(gl_MultiTexCoord4);
+#endif
+
+#ifdef MODE_LIGHTSOURCE
+ // transform vertex position into light attenuation/cubemap space
+ // (-1 to +1 across the light box)
+ CubeVector = vec3(ModelToLight * gl_Vertex);
+
+# ifdef USEDIFFUSE
+ // transform unnormalized light direction into tangent space
+ // (we use unnormalized to ensure that it interpolates correctly and then
+ // normalize it per pixel)
+ vec3 lightminusvertex = LightPosition - gl_Vertex.xyz;
+ LightVector.x = dot(lightminusvertex, gl_MultiTexCoord1.xyz);
+ LightVector.y = dot(lightminusvertex, gl_MultiTexCoord2.xyz);
+ LightVector.z = dot(lightminusvertex, gl_MultiTexCoord3.xyz);
+# endif
+#endif
+
+#if defined(MODE_LIGHTDIRECTION) && defined(USEDIFFUSE)
+ LightVector.x = dot(LightDir, gl_MultiTexCoord1.xyz);
+ LightVector.y = dot(LightDir, gl_MultiTexCoord2.xyz);
+ LightVector.z = dot(LightDir, gl_MultiTexCoord3.xyz);
+#endif
+
+ // transform unnormalized eye direction into tangent space
+#ifdef USEEYEVECTOR
+ vec3 EyeVectorModelSpace = EyePosition - gl_Vertex.xyz;
+ EyeVector.x = dot(EyeVectorModelSpace, gl_MultiTexCoord1.xyz);
+ EyeVector.y = dot(EyeVectorModelSpace, gl_MultiTexCoord2.xyz);
+ EyeVector.z = dot(EyeVectorModelSpace, gl_MultiTexCoord3.xyz);
+#endif
+
+#ifdef USEFOG
+ EyeVectorModelSpaceFogPlaneVertexDist.xyz = EyePosition - gl_Vertex.xyz;
+ EyeVectorModelSpaceFogPlaneVertexDist.w = dot(FogPlane, gl_Vertex);
+#endif
+
+#if defined(MODE_LIGHTDIRECTIONMAP_MODELSPACE) || defined(USEREFLECTCUBE)
+ VectorS = gl_MultiTexCoord1.xyz;
+ VectorT = gl_MultiTexCoord2.xyz;
+ VectorR = gl_MultiTexCoord3.xyz;
+#endif
+
+ // transform vertex to camera space, using ftransform to match non-VS rendering
+ gl_Position = ModelViewProjectionMatrix * gl_Vertex;
+
+#ifdef USESHADOWMAPORTHO
+ ShadowMapTC = vec3(ShadowMapMatrix * gl_Position);
+#endif
+
+#ifdef USEREFLECTION
+ ModelViewProjectionPosition = gl_Position;
+#endif
+}
+#endif // VERTEX_SHADER
+
+
+
+
+#ifdef FRAGMENT_SHADER
+#ifdef USEDEFERREDLIGHTMAP
+uniform myhalf2 PixelToScreenTexCoord;
+uniform myhalf3 DeferredMod_Diffuse;
+uniform myhalf3 DeferredMod_Specular;
+#endif
+uniform myhalf3 Color_Ambient;
+uniform myhalf3 Color_Diffuse;
+uniform myhalf3 Color_Specular;
+uniform myhalf SpecularPower;
+#ifdef USEGLOW
+uniform myhalf3 Color_Glow;
+#endif
+uniform myhalf Alpha;
+#ifdef USEREFLECTION
+uniform vec4 DistortScaleRefractReflect;
+uniform vec4 ScreenScaleRefractReflect;
+uniform vec4 ScreenCenterRefractReflect;
+uniform myhalf4 ReflectColor;
+#endif
+#ifdef USEREFLECTCUBE
+uniform mat4 ModelToReflectCube;
+uniform sampler2D Texture_ReflectMask;
+uniform samplerCube Texture_ReflectCube;
+#endif
+#ifdef MODE_LIGHTDIRECTION
+uniform myhalf3 LightColor;
+#endif
+#ifdef MODE_LIGHTSOURCE
+uniform myhalf3 LightColor;
+#endif
+void main(void)
+{
+#ifdef USEOFFSETMAPPING
+ // apply offsetmapping
+ vec2 TexCoordOffset = OffsetMapping(TexCoord);
+#define TexCoord TexCoordOffset
+#endif
+
+ // combine the diffuse textures (base, pants, shirt)
+ myhalf4 color = myhalf4(texture2D(Texture_Color, TexCoord));
+#ifdef USEALPHAKILL
+ if (color.a < 0.5)
+ discard;
+#endif
+ color.a *= Alpha;
+#ifdef USECOLORMAPPING
+ color.rgb += myhalf3(texture2D(Texture_Pants, TexCoord)) * Color_Pants + myhalf3(texture2D(Texture_Shirt, TexCoord)) * Color_Shirt;
+#endif
+#ifdef USEVERTEXTEXTUREBLEND
+ myhalf terrainblend = clamp(myhalf(gl_Color.a) * color.a * 2.0 - 0.5, myhalf(0.0), myhalf(1.0));
+ //myhalf terrainblend = min(myhalf(gl_Color.a) * color.a * 2.0, myhalf(1.0));
+ //myhalf terrainblend = myhalf(gl_Color.a) * color.a > 0.5;
+ color.rgb = mix(myhalf3(texture2D(Texture_SecondaryColor, TexCoord2)), color.rgb, terrainblend);
+ color.a = 1.0;
+ //color = mix(myhalf4(1, 0, 0, 1), color, terrainblend);
+#endif
+
+ // get the surface normal
+#ifdef USEVERTEXTEXTUREBLEND
+ myhalf3 surfacenormal = normalize(mix(myhalf3(texture2D(Texture_SecondaryNormal, TexCoord2)), myhalf3(texture2D(Texture_Normal, TexCoord)), terrainblend) - myhalf3(0.5, 0.5, 0.5));
+#else
+ myhalf3 surfacenormal = normalize(myhalf3(texture2D(Texture_Normal, TexCoord)) - myhalf3(0.5, 0.5, 0.5));
+#endif
+
+ // get the material colors
+ myhalf3 diffusetex = color.rgb;
+#if defined(USESPECULAR) || defined(USEDEFERREDLIGHTMAP)
+# ifdef USEVERTEXTEXTUREBLEND
+ myhalf4 glosstex = mix(myhalf4(texture2D(Texture_SecondaryGloss, TexCoord2)), myhalf4(texture2D(Texture_Gloss, TexCoord)), terrainblend);
+# else
+ myhalf4 glosstex = myhalf4(texture2D(Texture_Gloss, TexCoord));
+# endif
+#endif
+
+#ifdef USEREFLECTCUBE
+ vec3 TangentReflectVector = reflect(-EyeVector, surfacenormal);
+ vec3 ModelReflectVector = TangentReflectVector.x * VectorS + TangentReflectVector.y * VectorT + TangentReflectVector.z * VectorR;
+ vec3 ReflectCubeTexCoord = vec3(ModelToReflectCube * vec4(ModelReflectVector, 0));
+ diffusetex += myhalf3(texture2D(Texture_ReflectMask, TexCoord)) * myhalf3(textureCube(Texture_ReflectCube, ReflectCubeTexCoord));
+#endif
+
+
+
+
+#ifdef MODE_LIGHTSOURCE
+ // light source
+#ifdef USEDIFFUSE
+ myhalf3 lightnormal = myhalf3(normalize(LightVector));
+ myhalf diffuse = myhalf(max(float(dot(surfacenormal, lightnormal)), 0.0));
+ color.rgb = diffusetex * (Color_Ambient + diffuse * Color_Diffuse);
+#ifdef USESPECULAR
+#ifdef USEEXACTSPECULARMATH
+ myhalf specular = pow(myhalf(max(float(dot(reflect(lightnormal, surfacenormal), normalize(EyeVector)))*-1.0, 0.0)), SpecularPower * glosstex.a);
+#else
+ myhalf3 specularnormal = normalize(lightnormal + myhalf3(normalize(EyeVector)));
+ myhalf specular = pow(myhalf(max(float(dot(surfacenormal, specularnormal)), 0.0)), SpecularPower * glosstex.a);
+#endif
+ color.rgb += glosstex.rgb * (specular * Color_Specular);
+#endif
+#else
+ color.rgb = diffusetex * Color_Ambient;
+#endif
+ color.rgb *= LightColor;
+ color.rgb *= myhalf(texture2D(Texture_Attenuation, vec2(length(CubeVector), 0.0)));
+#if defined(USESHADOWMAPRECT) || defined(USESHADOWMAPCUBE) || defined(USESHADOWMAP2D)
+ color.rgb *= ShadowMapCompare(CubeVector);
+#endif
+# ifdef USECUBEFILTER
+ color.rgb *= myhalf3(textureCube(Texture_Cube, CubeVector));
+# endif
+#endif // MODE_LIGHTSOURCE
+
+
+
+
+#ifdef MODE_LIGHTDIRECTION
+#define SHADING
+#ifdef USEDIFFUSE
+ myhalf3 lightnormal = myhalf3(normalize(LightVector));
+#endif
+#define lightcolor LightColor
+#endif // MODE_LIGHTDIRECTION
+#ifdef MODE_LIGHTDIRECTIONMAP_MODELSPACE
+#define SHADING
+ // deluxemap lightmapping using light vectors in modelspace (q3map2 -light -deluxe)
+ myhalf3 lightnormal_modelspace = myhalf3(texture2D(Texture_Deluxemap, TexCoordLightmap)) * 2.0 + myhalf3(-1.0, -1.0, -1.0);
+ myhalf3 lightcolor = myhalf3(texture2D(Texture_Lightmap, TexCoordLightmap));
+ // convert modelspace light vector to tangentspace
+ myhalf3 lightnormal;
+ lightnormal.x = dot(lightnormal_modelspace, myhalf3(VectorS));
+ lightnormal.y = dot(lightnormal_modelspace, myhalf3(VectorT));
+ lightnormal.z = dot(lightnormal_modelspace, myhalf3(VectorR));
+ // calculate directional shading (and undoing the existing angle attenuation on the lightmap by the division)
+ // note that q3map2 is too stupid to calculate proper surface normals when q3map_nonplanar
+ // is used (the lightmap and deluxemap coords correspond to virtually random coordinates
+ // on that luxel, and NOT to its center, because recursive triangle subdivision is used
+ // to map the luxels to coordinates on the draw surfaces), which also causes
+ // deluxemaps to be wrong because light contributions from the wrong side of the surface
+ // are added up. To prevent divisions by zero or strong exaggerations, a max()
+ // nudge is done here at expense of some additional fps. This is ONLY needed for
+ // deluxemaps, tangentspace deluxemap avoid this problem by design.
+ lightcolor *= 1.0 / max(0.25, lightnormal.z);
+#endif // MODE_LIGHTDIRECTIONMAP_MODELSPACE
+#ifdef MODE_LIGHTDIRECTIONMAP_TANGENTSPACE
+#define SHADING
+ // deluxemap lightmapping using light vectors in tangentspace (hmap2 -light)
+ myhalf3 lightnormal = myhalf3(texture2D(Texture_Deluxemap, TexCoordLightmap)) * 2.0 + myhalf3(-1.0, -1.0, -1.0);
+ myhalf3 lightcolor = myhalf3(texture2D(Texture_Lightmap, TexCoordLightmap));
+#endif
+
+
+
+
+#ifdef MODE_LIGHTMAP
+ color.rgb = diffusetex * (Color_Ambient + myhalf3(texture2D(Texture_Lightmap, TexCoordLightmap)) * Color_Diffuse);
+#endif // MODE_LIGHTMAP
+#ifdef MODE_VERTEXCOLOR
+ color.rgb = diffusetex * (Color_Ambient + myhalf3(gl_Color.rgb) * Color_Diffuse);
+#endif // MODE_VERTEXCOLOR
+#ifdef MODE_FLATCOLOR
+ color.rgb = diffusetex * Color_Ambient;
+#endif // MODE_FLATCOLOR
+
+
+
+
+#ifdef SHADING
+# ifdef USEDIFFUSE
+ myhalf diffuse = myhalf(max(float(dot(surfacenormal, lightnormal)), 0.0));
+# ifdef USESPECULAR
+# ifdef USEEXACTSPECULARMATH
+ myhalf specular = pow(myhalf(max(float(dot(reflect(lightnormal, surfacenormal), normalize(EyeVector)))*-1.0, 0.0)), SpecularPower * glosstex.a);
+# else
+ myhalf3 specularnormal = normalize(lightnormal + myhalf3(normalize(EyeVector)));
+ myhalf specular = pow(myhalf(max(float(dot(surfacenormal, specularnormal)), 0.0)), SpecularPower * glosstex.a);
+# endif
+ color.rgb = diffusetex * Color_Ambient + (diffusetex * Color_Diffuse * diffuse + glosstex.rgb * Color_Specular * specular) * lightcolor;
+# else
+ color.rgb = diffusetex * (Color_Ambient + Color_Diffuse * diffuse * lightcolor);
+# endif
+# else
+ color.rgb = diffusetex * Color_Ambient;
+# endif
+#endif
+
+#ifdef USESHADOWMAPORTHO
+ color.rgb *= ShadowMapCompare(ShadowMapTC);
+#endif
+
+#ifdef USEDEFERREDLIGHTMAP
+ vec2 ScreenTexCoord = gl_FragCoord.xy * PixelToScreenTexCoord;
+ color.rgb += diffusetex * myhalf3(texture2D(Texture_ScreenDiffuse, ScreenTexCoord)) * DeferredMod_Diffuse;
+ color.rgb += glosstex.rgb * myhalf3(texture2D(Texture_ScreenSpecular, ScreenTexCoord)) * DeferredMod_Specular;
+#endif
+
+#ifdef USEGLOW
+#ifdef USEVERTEXTEXTUREBLEND
+ color.rgb += mix(myhalf3(texture2D(Texture_SecondaryGlow, TexCoord2)), myhalf3(texture2D(Texture_Glow, TexCoord)), terrainblend) * Color_Glow;
+#else
+ color.rgb += myhalf3(texture2D(Texture_Glow, TexCoord)) * Color_Glow;
+#endif
+#endif
+
+#ifdef USEFOG
+ color.rgb = FogVertex(color.rgb);
+#endif
+
+ // reflection must come last because it already contains exactly the correct fog (the reflection render preserves camera distance from the plane, it only flips the side) and ContrastBoost/SceneBrightness
+#ifdef USEREFLECTION
+ vec4 ScreenScaleRefractReflectIW = ScreenScaleRefractReflect * (1.0 / ModelViewProjectionPosition.w);
+ //vec4 ScreenTexCoord = (ModelViewProjectionPosition.xyxy + normalize(myhalf3(texture2D(Texture_Normal, TexCoord)) - myhalf3(0.5)).xyxy * DistortScaleRefractReflect * 100) * ScreenScaleRefractReflectIW + ScreenCenterRefractReflect;
+ vec2 SafeScreenTexCoord = ModelViewProjectionPosition.xy * ScreenScaleRefractReflectIW.zw + ScreenCenterRefractReflect.zw;
+ vec2 ScreenTexCoord = SafeScreenTexCoord + vec3(normalize(myhalf3(texture2D(Texture_Normal, TexCoord)) - myhalf3(0.5))).xy * DistortScaleRefractReflect.zw;
+ // FIXME temporary hack to detect the case that the reflection
+ // gets blackened at edges due to leaving the area that contains actual
+ // content.
+ // Remove this 'ack once we have a better way to stop this thing from
+ // 'appening.
+ float f = min(1.0, length(texture2D(Texture_Reflection, ScreenTexCoord + vec2(0.01, 0.01)).rgb) / 0.05);
+ f *= min(1.0, length(texture2D(Texture_Reflection, ScreenTexCoord + vec2(0.01, -0.01)).rgb) / 0.05);
+ f *= min(1.0, length(texture2D(Texture_Reflection, ScreenTexCoord + vec2(-0.01, 0.01)).rgb) / 0.05);
+ f *= min(1.0, length(texture2D(Texture_Reflection, ScreenTexCoord + vec2(-0.01, -0.01)).rgb) / 0.05);
+ ScreenTexCoord = mix(SafeScreenTexCoord, ScreenTexCoord, f);
+ color.rgb = mix(color.rgb, myhalf3(texture2D(Texture_Reflection, ScreenTexCoord)) * ReflectColor.rgb, ReflectColor.a);
+#endif
+
+ gl_FragColor = vec4(color);
+}
+#endif // FRAGMENT_SHADER
+
+#endif // !MODE_DEFERREDLIGHTSOURCE
+#endif // !MODE_DEFERREDGEOMETRY
+#endif // !MODE_WATER
+#endif // !MODE_REFRACTION
+#endif // !MODE_BLOOMBLUR
+#endif // !MODE_GENERIC
+#endif // !MODE_POSTPROCESS
+#endif // !MODE_SHOWDEPTH
+#endif // !MODE_DEPTH_OR_SHADOW
diff --git a/shaders/xreal-lighting-d-omni.frag b/shaders/xreal-lighting-d-omni.frag
new file mode 100644
index 0000000..e386e5b
--- /dev/null
+++ b/shaders/xreal-lighting-d-omni.frag
@@ -0,0 +1,69 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.10
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+===========================================================================
+Copyright (C) 2006 Robert Beckebans <trebor_7@users.sourceforge.net>
+
+This file is part of XreaL source code.
+
+XreaL source code is free software; you can redistribute it
+and/or modify it under the terms of the GNU General Public License as
+published by the Free Software Foundation; either version 2 of the License,
+or (at your option) any later version.
+
+XreaL source code is distributed in the hope that it will be
+useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with XreaL source code; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+===========================================================================
+*/
+
+uniform sampler2D u_DiffuseMap;
+uniform sampler2D u_AttenuationMapXY;
+uniform sampler2D u_AttenuationMapZ;
+uniform vec3 u_LightOrigin;
+uniform vec3 u_LightColor;
+uniform float u_LightScale;
+
+varying vec3 var_Vertex;
+varying vec3 var_Normal;
+varying vec2 var_TexDiffuse;
+varying vec4 var_TexAtten;
+
+void main()
+{
+ // compute light direction in tangent space
+ vec3 L = normalize(u_LightOrigin - var_Vertex);
+
+ // compute normal in tangent space from normalmap
+ vec3 N = normalize(var_Normal);
+
+ // compute the diffuse term
+ vec4 diffuse = texture2D(u_DiffuseMap, var_TexDiffuse);
+ diffuse.rgb *= u_LightColor * clamp(dot(N, L), 0.0, 1.0);
+
+ // compute attenuation
+// vec3 attenuationXY = texture2D(u_AttenuationMapXY, var_TexAtten.xy).rgb;
+ vec3 attenuationXY = texture2DProj(u_AttenuationMapXY, vec3(var_TexAtten.x, var_TexAtten.y, var_TexAtten.w)).rgb;
+ vec3 attenuationZ = texture2D(u_AttenuationMapZ, vec2(var_TexAtten.z, 0)).rgb;
+
+ // compute final color
+ vec4 color = diffuse;
+ color.rgb *= attenuationXY;
+ color.rgb *= attenuationZ;
+ color.rgb *= u_LightScale;
+
+ gl_FragColor = color;
+}
+
diff --git a/shaders/xreal-lighting-d-omni.vert b/shaders/xreal-lighting-d-omni.vert
new file mode 100644
index 0000000..6571aae
--- /dev/null
+++ b/shaders/xreal-lighting-d-omni.vert
@@ -0,0 +1,55 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.10
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+===========================================================================
+Copyright (C) 2006 Robert Beckebans <trebor_7@users.sourceforge.net>
+
+This file is part of XreaL source code.
+
+XreaL source code is free software; you can redistribute it
+and/or modify it under the terms of the GNU General Public License as
+published by the Free Software Foundation; either version 2 of the License,
+or (at your option) any later version.
+
+XreaL source code is distributed in the hope that it will be
+useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with XreaL source code; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+===========================================================================
+*/
+
+attribute vec4 attr_TexCoord0;
+
+varying vec3 var_Vertex;
+varying vec3 var_Normal;
+varying vec2 var_TexDiffuse;
+varying vec4 var_TexAtten;
+
+void main()
+{
+ // transform vertex position into homogenous clip-space
+ gl_Position = ftransform();
+
+ // assign position in object space
+ var_Vertex = gl_Vertex.xyz;
+
+ // assign normal in object space
+ var_Normal = gl_Normal.xyz;
+
+ // transform diffusemap texcoords
+ var_TexDiffuse = (gl_TextureMatrix[0] * attr_TexCoord0).st;
+
+ // calc light xy,z attenuation in light space
+ var_TexAtten = gl_TextureMatrix[3] * gl_Vertex;
+}
diff --git a/shaders/xreal-lighting-db-omni.frag b/shaders/xreal-lighting-db-omni.frag
new file mode 100644
index 0000000..e6e512f
--- /dev/null
+++ b/shaders/xreal-lighting-db-omni.frag
@@ -0,0 +1,72 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.10
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+===========================================================================
+Copyright (C) 2006 Robert Beckebans <trebor_7@users.sourceforge.net>
+
+This file is part of XreaL source code.
+
+XreaL source code is free software; you can redistribute it
+and/or modify it under the terms of the GNU General Public License as
+published by the Free Software Foundation; either version 2 of the License,
+or (at your option) any later version.
+
+XreaL source code is distributed in the hope that it will be
+useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with XreaL source code; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+===========================================================================
+*/
+
+uniform sampler2D u_DiffuseMap;
+uniform sampler2D u_BumpMap;
+uniform sampler2D u_AttenuationMapXY;
+uniform sampler2D u_AttenuationMapZ;
+uniform vec3 u_LightOrigin;
+uniform vec3 u_LightColor;
+uniform float u_LightScale;
+
+varying vec3 var_Vertex;
+varying vec2 var_TexDiffuse;
+varying vec2 var_TexBump;
+varying vec4 var_TexAtten;
+varying mat3 var_OS2TSMatrix;
+
+void main()
+{
+ // compute light direction in tangent space
+ vec3 L = normalize(var_OS2TSMatrix * (u_LightOrigin - var_Vertex));
+
+ // compute normal in tangent space from bumpmap
+ vec3 N = 2.0 * (texture2D(u_BumpMap, var_TexBump).xyz - 0.5);
+ N = normalize(N);
+
+ // compute the diffuse term
+ vec4 diffuse = texture2D(u_DiffuseMap, var_TexDiffuse);
+ diffuse.rgb *= u_LightColor * clamp(dot(N, L), 0.0, 1.0);
+
+ // compute attenuation
+// vec3 attenuationXY = texture2D(u_AttenuationMapXY, var_TexAtten.xy).rgb;
+ vec3 attenuationXY = texture2DProj(u_AttenuationMapXY, vec3(var_TexAtten.x, var_TexAtten.y, var_TexAtten.w)).rgb;
+ vec3 attenuationZ = texture2D(u_AttenuationMapZ, vec2(var_TexAtten.z, 0)).rgb;
+
+ // compute final color
+ vec4 color = diffuse;
+ color.rgb *= attenuationXY;
+ color.rgb *= attenuationZ;
+ color.rgb *= u_LightScale;
+
+ gl_FragColor = color;
+}
+
diff --git a/shaders/xreal-lighting-db-omni.vert b/shaders/xreal-lighting-db-omni.vert
new file mode 100644
index 0000000..d6c78da
--- /dev/null
+++ b/shaders/xreal-lighting-db-omni.vert
@@ -0,0 +1,63 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.10
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+===========================================================================
+Copyright (C) 2006 Robert Beckebans <trebor_7@users.sourceforge.net>
+
+This file is part of XreaL source code.
+
+XreaL source code is free software; you can redistribute it
+and/or modify it under the terms of the GNU General Public License as
+published by the Free Software Foundation; either version 2 of the License,
+or (at your option) any later version.
+
+XreaL source code is distributed in the hope that it will be
+useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with XreaL source code; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+===========================================================================
+*/
+
+attribute vec4 attr_TexCoord0;
+attribute vec3 attr_Tangent;
+attribute vec3 attr_Binormal;
+
+varying vec3 var_Vertex;
+varying vec2 var_TexDiffuse;
+varying vec2 var_TexBump;
+varying vec4 var_TexAtten;
+varying mat3 var_OS2TSMatrix;
+
+void main()
+{
+ // transform vertex position into homogenous clip-space
+ gl_Position = ftransform();
+
+ // assign position in object space
+ var_Vertex = gl_Vertex.xyz;
+
+ // transform diffusemap texcoords
+ var_TexDiffuse = (gl_TextureMatrix[0] * attr_TexCoord0).st;
+
+ // transform bumpmap texcoords
+ var_TexBump = (gl_TextureMatrix[1] * attr_TexCoord0).st;
+
+ // calc light xy,z attenuation in light space
+ var_TexAtten = gl_TextureMatrix[3] * gl_Vertex;
+
+ // construct object-space-to-tangent-space 3x3 matrix
+ var_OS2TSMatrix = mat3( attr_Tangent.x, attr_Binormal.x, gl_Normal.x,
+ attr_Tangent.y, attr_Binormal.y, gl_Normal.y,
+ attr_Tangent.z, attr_Binormal.z, gl_Normal.z );
+}
diff --git a/shaders/xreal-lighting-dbs-omni.frag b/shaders/xreal-lighting-dbs-omni.frag
new file mode 100644
index 0000000..5e08797
--- /dev/null
+++ b/shaders/xreal-lighting-dbs-omni.frag
@@ -0,0 +1,86 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.10
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+===========================================================================
+Copyright (C) 2006 Robert Beckebans <trebor_7@users.sourceforge.net>
+
+This file is part of XreaL source code.
+
+XreaL source code is free software; you can redistribute it
+and/or modify it under the terms of the GNU General Public License as
+published by the Free Software Foundation; either version 2 of the License,
+or (at your option) any later version.
+
+XreaL source code is distributed in the hope that it will be
+useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with XreaL source code; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+===========================================================================
+*/
+
+uniform sampler2D u_DiffuseMap;
+uniform sampler2D u_BumpMap;
+uniform sampler2D u_SpecularMap;
+uniform sampler2D u_AttenuationMapXY;
+uniform sampler2D u_AttenuationMapZ;
+uniform vec3 u_ViewOrigin;
+uniform vec3 u_LightOrigin;
+uniform vec3 u_LightColor;
+uniform float u_LightScale;
+uniform float u_SpecularExponent;
+
+varying vec3 var_Vertex;
+varying vec2 var_TexDiffuse;
+varying vec2 var_TexBump;
+varying vec2 var_TexSpecular;
+varying vec4 var_TexAtten;
+varying mat3 var_OS2TSMatrix;
+
+void main()
+{
+ // compute view direction in tangent space
+ vec3 V = normalize(var_OS2TSMatrix * (u_ViewOrigin - var_Vertex));
+
+ // compute light direction in tangent space
+ vec3 L = normalize(var_OS2TSMatrix * (u_LightOrigin - var_Vertex));
+
+ // compute half angle in tangent space
+ vec3 H = normalize(L + V);
+
+ // compute normal in tangent space from bumpmap
+ vec3 N = 2.0 * (texture2D(u_BumpMap, var_TexBump).xyz - 0.5);
+ N = normalize(N);
+
+ // compute the diffuse term
+ vec4 diffuse = texture2D(u_DiffuseMap, var_TexDiffuse);
+ diffuse.rgb *= u_LightColor * clamp(dot(N, L), 0.0, 1.0);
+
+ // compute the specular term
+ vec3 specular = texture2D(u_SpecularMap, var_TexSpecular).rgb * u_LightColor * pow(clamp(dot(N, H), 0.0, 1.0), u_SpecularExponent);
+
+ // compute attenuation
+// vec3 attenuationXY = texture2D(u_AttenuationMapXY, var_TexAtten.xy).rgb;
+ vec3 attenuationXY = texture2DProj(u_AttenuationMapXY, vec3(var_TexAtten.x, var_TexAtten.y, var_TexAtten.w)).rgb;
+ vec3 attenuationZ = texture2D(u_AttenuationMapZ, vec2(var_TexAtten.z, 0)).rgb;
+
+ // compute final color
+ vec4 color = diffuse;
+ color.rgb += specular;
+ color.rgb *= attenuationXY;
+ color.rgb *= attenuationZ;
+ color.rgb *= u_LightScale;
+
+ gl_FragColor = color;
+}
+
diff --git a/shaders/xreal-lighting-dbs-omni.vert b/shaders/xreal-lighting-dbs-omni.vert
new file mode 100644
index 0000000..c1a0284
--- /dev/null
+++ b/shaders/xreal-lighting-dbs-omni.vert
@@ -0,0 +1,67 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.10
+//
+// # NOTE: Config section was auto-generated from file
+// # NOTE: 'glslparser.tests' at git revision
+// # NOTE: 6cc17ae70b70d150aa1751f8e28db7b2a9bd50f0
+// [end config]
+
+/*
+===========================================================================
+Copyright (C) 2006 Robert Beckebans <trebor_7@users.sourceforge.net>
+
+This file is part of XreaL source code.
+
+XreaL source code is free software; you can redistribute it
+and/or modify it under the terms of the GNU General Public License as
+published by the Free Software Foundation; either version 2 of the License,
+or (at your option) any later version.
+
+XreaL source code is distributed in the hope that it will be
+useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with XreaL source code; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+===========================================================================
+*/
+
+attribute vec4 attr_TexCoord0;
+attribute vec3 attr_Tangent;
+attribute vec3 attr_Binormal;
+
+varying vec3 var_Vertex;
+varying vec2 var_TexDiffuse;
+varying vec2 var_TexBump;
+varying vec2 var_TexSpecular;
+varying vec4 var_TexAtten;
+varying mat3 var_OS2TSMatrix;
+
+void main()
+{
+ // transform vertex position into homogenous clip-space
+ gl_Position = ftransform();
+
+ // assign position in object space
+ var_Vertex = gl_Vertex.xyz;
+
+ // transform diffusemap texcoords
+ var_TexDiffuse = (gl_TextureMatrix[0] * attr_TexCoord0).st;
+
+ // transform bumpmap texcoords
+ var_TexBump = (gl_TextureMatrix[1] * attr_TexCoord0).st;
+
+ // transform specularmap texture coords
+ var_TexSpecular = (gl_TextureMatrix[2] * attr_TexCoord0).st;
+
+ // calc light xy,z attenuation in light space
+ var_TexAtten = gl_TextureMatrix[3] * gl_Vertex;
+
+ // construct object-space-to-tangent-space 3x3 matrix
+ var_OS2TSMatrix = mat3( attr_Tangent.x, attr_Binormal.x, gl_Normal.x,
+ attr_Tangent.y, attr_Binormal.y, gl_Normal.y,
+ attr_Tangent.z, attr_Binormal.z, gl_Normal.z );
+}