scg3  0.6
cube_map_gouraud_frag.glsl
Go to the documentation of this file.
1 /**
2  * \file cube_map_gouraud_frag.glsl
3  * \brief Cube map fragment shader with Gouraud shading.
4  */
5 
6 #version 150
7 
8 smooth in vec4 emissionAmbientDiffuse;
9 smooth in vec4 specular;
10 smooth in vec3 texCoord0;
11 
12 uniform mat4 colorMatrix;
13 uniform samplerCube texture0;
14 
15 out vec4 fragColor;
16 
17 
18 void main(void) {
19 
20  // apply cube map and determine color
21  vec4 texColor = texture(texture0, texCoord0);
22  vec4 color = clamp(mix(texColor, emissionAmbientDiffuse, 0.5) + specular, 0., 1.);
23 
24  // transform color by color matrix
25  vec4 transformedColor = colorMatrix * vec4(color.rgb, 1.);
26  transformedColor /= transformedColor.a; // perspective division
27 
28  // set final fragment color
29  fragColor = clamp(vec4(transformedColor.rgb, color.a), 0., 1.);
30 }