3 * @brief Default battlescape model fragment shader.
8 * Indicates that gl_FragData is written to, not gl_FragColor.
9 * #extension needs to be placed before all non preprocessor code.
11 #extension GL_ARB_draw_buffers : enable
16uniform int SPECULARMAP;
21in_qualifier vec3 sunDir; /** < Direction towards the sun */
24uniform sampler2D SAMPLER_DIFFUSE;
26uniform sampler2D SAMPLER_SPECULAR;
28uniform sampler2D SAMPLER_ROUGHMAP;
30uniform sampler2D SAMPLER_NORMALMAP;
32#define R_DYNAMIC_LIGHTS #replace r_dynamic_lights
34in_qualifier vec3 lightDirs[R_DYNAMIC_LIGHTS];
35uniform vec4 LIGHTPARAMS[R_DYNAMIC_LIGHTS];
38#include "bump_fs.glsl"
40#include "cook-torrance_fs.glsl"
41#include "model_devtools_fs.glsl"
42#include "write_fragment_fs.glsl"
48 vec4 finalColor = vec4(0.0);
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
55 finalColor = IlluminateFragment();
59 finalColor = FogFragment(finalColor);
62 /* Developer tools, if enabled */
63 finalColor = ApplyDeveloperTools(finalColor, sunDir, texture2D(SAMPLER_NORMALMAP, gl_TexCoord[0].st).rgb);
65 writeFragment(finalColor);