UFO: Alien Invasion
model_high_fs.glsl
Go to the documentation of this file.
1 /**
2  * @file
3  * @brief Default battlescape model fragment shader.
4  */
5 
6 #if r_postprocess
7  /*
8  * Indicates that gl_FragData is written to, not gl_FragColor.
9  * #extension needs to be placed before all non preprocessor code.
10  */
11  #extension GL_ARB_draw_buffers : enable
12 #endif
13 
14 uniform int BUMPMAP;
15 uniform int ROUGHMAP;
16 uniform int SPECULARMAP;
17 uniform vec3 AMBIENT;
18 
19 uniform vec3 SUNCOLOR;
20 
21 in_qualifier vec3 sunDir; /** < Direction towards the sun */
22 
23 /** Diffuse texture.*/
24 uniform sampler2D SAMPLER_DIFFUSE;
25 /** Specularmap.*/
26 uniform sampler2D SAMPLER_SPECULAR;
27 /** Roughnessmap.*/
28 uniform sampler2D SAMPLER_ROUGHMAP;
29 /** Normalmap.*/
30 uniform sampler2D SAMPLER_NORMALMAP;
31 
32 #define R_DYNAMIC_LIGHTS #replace r_dynamic_lights
33 #if r_dynamic_lights
34 in_qualifier vec3 lightDirs[R_DYNAMIC_LIGHTS];
35 uniform vec4 LIGHTPARAMS[R_DYNAMIC_LIGHTS];
36 #endif
37 
38 #include "bump_fs.glsl"
39 #include "fog_fs.glsl"
40 #include "cook-torrance_fs.glsl"
41 #include "model_devtools_fs.glsl"
42 #include "write_fragment_fs.glsl"
43 
44 /**
45  * @brief main
46  */
47 void main(void) {
48  vec4 finalColor = vec4(0.0);
49 
50  /* use new dynamic lighing system, including
51  * the Cook-Torrance specularity model with the Phong
52  * model as a default if the roughness map isn't enabled
53  * ... but only for models for now
54  */
55  finalColor = IlluminateFragment();
56 
57 #if r_fog
58  /* Add fog.*/
59  finalColor = FogFragment(finalColor);
60 #endif
61 
62  /* Developer tools, if enabled */
63  finalColor = ApplyDeveloperTools(finalColor, sunDir, texture2D(SAMPLER_NORMALMAP, gl_TexCoord[0].st).rgb);
64 
65  writeFragment(finalColor);
66 }