summaryrefslogtreecommitdiffstats
path: root/progs/glsl/CH06-brick.frag
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2008-08-16 09:36:46 -0600
committerBrian Paul <[email protected]>2008-08-16 09:36:46 -0600
commitc0dd9122fdedd4bcab5bc0b3bbb490e6b62fac83 (patch)
treeac114b79c5790b10c0a8904ca79dfea5480c5617 /progs/glsl/CH06-brick.frag
parentce00d232f3c01c71fb659568e9b58da1f24b2519 (diff)
remove .txt suffix from shader source files
Diffstat (limited to 'progs/glsl/CH06-brick.frag')
-rw-r--r--progs/glsl/CH06-brick.frag36
1 files changed, 36 insertions, 0 deletions
diff --git a/progs/glsl/CH06-brick.frag b/progs/glsl/CH06-brick.frag
new file mode 100644
index 00000000000..06ef04e3afb
--- /dev/null
+++ b/progs/glsl/CH06-brick.frag
@@ -0,0 +1,36 @@
+//
+// Fragment shader for procedural bricks
+//
+// Authors: Dave Baldwin, Steve Koren, Randi Rost
+// based on a shader by Darwyn Peachey
+//
+// Copyright (c) 2002-2006 3Dlabs Inc. Ltd.
+//
+// See 3Dlabs-License.txt for license information
+//
+
+uniform vec3 BrickColor, MortarColor;
+uniform vec2 BrickSize;
+uniform vec2 BrickPct;
+
+varying vec2 MCposition;
+varying float LightIntensity;
+
+void main()
+{
+ vec3 color;
+ vec2 position, useBrick;
+
+ position = MCposition / BrickSize;
+
+ if (fract(position.y * 0.5) > 0.5)
+ position.x += 0.5;
+
+ position = fract(position);
+
+ useBrick = step(position, BrickPct);
+
+ color = mix(MortarColor, BrickColor, useBrick.x * useBrick.y);
+ color *= LightIntensity;
+ gl_FragColor = vec4(color, 1.0);
+}