scg3  0.6
gouraud_frag.glsl
Go to the documentation of this file.
1 /**
2  * \file gouraud_frag.glsl
3  * \brief Gouraud fragment shader, use external function applyTexture().
4  */
5 
6 #version 150
7 
8 smooth in vec4 emissionAmbientDiffuse;
9 smooth in vec4 specular;
10 smooth in vec4 texCoord0;
11 
12 uniform mat4 colorMatrix;
13 
14 out vec4 fragColor;
15 
16 
17 // --- declarations ---
18 
19 
20 vec4 applyTexture(const in vec4 texCoord, const in vec4 emissionAmbientDiffuse,
21  const in vec4 specular);
22 
23 
24 // --- implementations ---
25 
26 
27 void main(void) {
28 
29  // apply texture and determine color (to be defined in separate shader)
30  vec4 color = applyTexture(texCoord0, emissionAmbientDiffuse, specular);
31 
32  // transform color by color matrix
33  vec4 transformedColor = colorMatrix * vec4(color.rgb, 1.);
34  transformedColor /= transformedColor.a; // perspective division
35 
36  // set final fragment color
37  fragColor = clamp(vec4(transformedColor.rgb, color.a), 0., 1.);
38 }