summaryrefslogtreecommitdiff
path: root/tests/glslparsertest/glsl2/xreal-lighting-d-omni.frag
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2010-04-13 13:50:37 -0700
committerEric Anholt <eric@anholt.net>2010-04-13 13:50:57 -0700
commitf72ba22ec12a1f635bbe07b8b7eb2be64658476c (patch)
tree48a9da418ca792263b852e25de2ac2e7fecbeea3 /tests/glslparsertest/glsl2/xreal-lighting-d-omni.frag
parentd36b0d32fd0986ff145f5ad55c93803cd51fa280 (diff)
Add some GPLv2 shaders found in XReal for GLSL parse testing.
Diffstat (limited to 'tests/glslparsertest/glsl2/xreal-lighting-d-omni.frag')
-rw-r--r--tests/glslparsertest/glsl2/xreal-lighting-d-omni.frag60
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/glslparsertest/glsl2/xreal-lighting-d-omni.frag b/tests/glslparsertest/glsl2/xreal-lighting-d-omni.frag
new file mode 100644
index 000000000..4380fc086
--- /dev/null
+++ b/tests/glslparsertest/glsl2/xreal-lighting-d-omni.frag
@@ -0,0 +1,60 @@
+/*
+===========================================================================
+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;
+}
+