summaryrefslogtreecommitdiff
path: root/data/shaders/pbr-frag.glsl
blob: 813f9a91832e9eacef74870b2965a2098d8d5721 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// -*- mode: c -*-

#ifdef GLSL120
attribute vec2 fragTexcoord0;
attribute vec2 fragTexcoord1
attribute vec4 fragColor0;
#else
in vec2 fragTexcoord0;
in vec2 fragTexcoord1;
in vec4 fragColor0;
#endif

#ifdef GLSL330
out vec4 fragColor;
#endif

uniform bool textured0;
uniform bool textured1;
uniform bool vertexColored;
uniform vec3 baseColorFactor;
uniform sampler2D texture0;
uniform sampler2D texture1;

void main (void) {
  vec4 finalColor = vec4(baseColorFactor, 1.0);
  // Vertex coloring.
  if(vertexColored) {
    finalColor *= fragColor0;
  }
  // Texture sampling.
  if(textured0) {
    finalColor *= texture(texture0, fragTexcoord0);
  }
  if(textured1) {
    finalColor += texture(texture1, fragTexcoord1);
  }
#ifdef GLSL330
  fragColor = finalColor;
#else
  gl_FragColor = finalColor;
#endif
}