Statistics
| Revision:

root / PyOpenGL-Demo / proesch / shaderProg / brick.frag @ 1

History | View | Annotate | Download (822 Bytes)

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-2004 3Dlabs Inc. Ltd.
8
//
9
// See 3Dlabs-License.txt for license information
10
//  
11

    
12
uniform vec3  BrickColor, MortarColor;
13
uniform vec2  BrickSize;
14
uniform vec2  BrickPct;
15

    
16
varying vec2  MCposition;
17
varying float LightIntensity;
18

    
19
void main(void)
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
}