xref: /haiku/src/tests/kits/opengl/glsl/CH06-brick.frag (revision 1294543de9ac0eff000eaea1b18368c36435d08e)
1//
2// Fragment shader for procedural bricks
3//
4// Authors: Dave Baldwin, Steve Koren, Randi Rost
5//          based on a shader by Darwyn Peachey
6//
7// Copyright (c) 2002-2006 3Dlabs Inc. Ltd.
8//
9// See 3Dlabs-License.txt for license information
10//
11
12uniform vec3  BrickColor, MortarColor;
13uniform vec2  BrickSize;
14uniform vec2  BrickPct;
15
16varying vec2  MCposition;
17varying float LightIntensity;
18
19void main()
20{
21    vec3  color;
22    vec2  position, useBrick;
23
24    position = MCposition / BrickSize;
25
26    if (fract(position.y * 0.5) > 0.5)
27        position.x += 0.5;
28
29    position = fract(position);
30
31    useBrick = step(position, BrickPct);
32
33    color  = mix(MortarColor, BrickColor, useBrick.x * useBrick.y);
34    color *= LightIntensity;
35    gl_FragColor = vec4(color, 1.0);
36}
37