aboutsummaryrefslogtreecommitdiffstats
path: root/src/GLSLShaderTest/dimple.frag
diff options
context:
space:
mode:
authornobody <nobody@28c7f869-5b4e-e670-f602-82bfaf57f300>2005-10-17 21:17:15 +0000
committernobody <nobody@28c7f869-5b4e-e670-f602-82bfaf57f300>2005-10-17 21:17:15 +0000
commit96a50f0092524c823a31d2e6b2882d9b9f098292 (patch)
treefacc740ba800f3a3f68e0fb585965b22f78b653c /src/GLSLShaderTest/dimple.frag
parentd73245421b294f50b9d4728bcbc717876f83d250 (diff)
This commit was manufactured by cvs2svn to create tagpostmerge-1_4-1_3_3-A
'postmerge-1_4-1_3_3-A'.
Diffstat (limited to 'src/GLSLShaderTest/dimple.frag')
-rw-r--r--src/GLSLShaderTest/dimple.frag57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/GLSLShaderTest/dimple.frag b/src/GLSLShaderTest/dimple.frag
new file mode 100644
index 0000000..70d2982
--- /dev/null
+++ b/src/GLSLShaderTest/dimple.frag
@@ -0,0 +1,57 @@
+
+//
+// dimple.frag: Fragment shader for bump mapping dimples (bumps)
+//
+// author: John Kessenich
+//
+// Copyright (c) 2002: 3Dlabs, Inc.
+//
+//
+varying vec3 LightDir;
+varying vec3 EyeDir;
+varying vec3 Normal;
+
+const vec3 color = vec3(0.7, 0.6, 0.18);
+
+//const float Density = 16.0;
+//const float Size = 0.25;
+
+//uniform float Density;
+//uniform float Size;
+float Density = 27.6;
+float Size = 0.13025;
+
+
+//uniform float Scale;
+
+const float SpecularFactor = 0.5;
+
+void main (void)
+{
+ vec3 litColor;
+
+ vec2 c = Density * (gl_TexCoord[0].xy);
+ vec2 p = fract(c) - vec2(0.5);
+ float d = (p.x * p.x) + (p.y * p.y);
+ if (d >= Size)
+ p = vec2(0.0);
+
+ vec3 normDelta = vec3(-p.x, -p.y, 1.0);
+
+ litColor = color * max(0.0, dot(normDelta, LightDir));
+
+ float t = 2.0 * dot(LightDir, normDelta);
+ vec3 reflectDir = t * normDelta;
+ reflectDir = LightDir - reflectDir;
+
+// vec3 reflectDir = LightDir - 2.0 * dot(LightDir, normDelta) * normDelta;
+
+ float spec = max(dot(EyeDir, reflectDir), 0.0);
+ spec = spec * spec;
+ spec = spec * spec;
+ spec *= SpecularFactor;
+
+ litColor = min(litColor + spec, vec3(1.0));
+ gl_FragColor = vec4(litColor, 1.0);
+// gl_FragColor = vec4(Scale);
+}