summaryrefslogtreecommitdiffstats
path: root/src/GLSLShaderTest/polkadot3d.frag
diff options
context:
space:
mode:
authornobody <nobody@28c7f869-5b4e-e670-f602-82bfaf57f300>2005-08-26 21:18:36 +0000
committernobody <nobody@28c7f869-5b4e-e670-f602-82bfaf57f300>2005-08-26 21:18:36 +0000
commitc70acc013c054d977fc7df0309ae29503e3d43af (patch)
tree679d9535fc0313cba50c499fb92a64bb46999fc7 /src/GLSLShaderTest/polkadot3d.frag
parentd73245421b294f50b9d4728bcbc717876f83d250 (diff)
This commit was manufactured by cvs2svn to create tagexp-1_4_0-build6
'exp-1_4_0-build6'.
Diffstat (limited to 'src/GLSLShaderTest/polkadot3d.frag')
-rw-r--r--src/GLSLShaderTest/polkadot3d.frag48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/GLSLShaderTest/polkadot3d.frag b/src/GLSLShaderTest/polkadot3d.frag
new file mode 100644
index 0000000..b341454
--- /dev/null
+++ b/src/GLSLShaderTest/polkadot3d.frag
@@ -0,0 +1,48 @@
+//
+// Fragment shader for 3 dimensional polka dot shader.
+//
+// Author: Joshua Doss
+//
+// Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
+//
+// See 3Dlabs-License.txt for license information
+//
+varying float LightIntensity;
+varying vec3 MCPosition;
+
+//Create uniform variables so dots can be spaced and scaled by user
+//uniform vec3 Spacing;
+//uniform float DotSize;
+const vec3 Spacing = vec3 (0.314, 0.36, 0.261);
+const float DotSize = 0.123;
+
+//Create colors as uniform variables so they can be easily changed
+//uniform vec3 ModelColor, PolkaDotColor;
+const vec3 ModelColor = vec3 (0.75, 0.2, 0.1);
+const vec3 PolkaDotColor = vec3 (1, 1, 1);
+
+void main(void)
+{
+ float insidesphere, sphereradius, scaledpointlength;
+ vec3 scaledpoint, finalcolor;
+
+ // Scale the coordinate system
+ // The following line of code is not yet implemented in current drivers:
+ // mcpos = mod(Spacing, MCposition);
+ // We will use a workaround found below for now
+ scaledpoint = MCPosition - (Spacing * floor(MCPosition/Spacing));
+
+ // Bring the scaledpoint vector into the center of the scaled coordinate system
+ scaledpoint = scaledpoint - Spacing/2.0;
+
+ // Find the length of the scaledpoint vector and compare it to the dotsize
+ scaledpointlength = length(scaledpoint);
+ insidesphere = step(scaledpointlength,DotSize);
+
+ // Determine final output color before lighting
+ finalcolor = vec3(mix(ModelColor, PolkaDotColor, insidesphere));
+
+ // Output final color and factor in lighting
+ gl_FragColor = clamp((vec4( finalcolor, 1.0 ) * LightIntensity), vec4(0.0), vec4(1.0));
+}
+