1
2/*
3Copyright (c) 2019 The Khronos Group Inc.
4Use of this source code is governed by an MIT-style license that can be
5found in the LICENSE.txt file.
6*/
7
8
9#ifdef GL_ES
10precision mediump float;
11#endif
12uniform float	mortarThickness;
13uniform vec3	brickColor;
14uniform vec3	mortarColor;
15
16uniform float	brickMortarWidth;
17uniform float	brickMortarHeight;
18uniform float	mwf;
19uniform float	mhf;
20
21varying vec3  Position;
22varying float lightIntensity;
23
24void main (void)
25{
26    vec3	ct;
27    float	ss, tt, w, h;
28
29    vec3 pos = Position;
30
31    ss = pos.x / brickMortarWidth;
32    tt = pos.z / brickMortarHeight;
33
34    if (fract (tt * 0.5) > 0.5)
35        ss += 0.5;
36
37    ss = fract (ss);
38    tt = fract (tt);
39
40    w = step (mwf, ss) - step (1.0 - mwf, ss);
41    h = step (mhf, tt) - step (1.0 - mhf, tt);
42
43    ct = clamp(mix (mortarColor, brickColor, w * h) * lightIntensity, 0.0, 1.0);
44
45    gl_FragColor = vec4 (ct, 1.0);
46}
47