3 * @brief Low quality 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
20in_qualifier vec3 sunDir; /** < Direction towards the sun */
23uniform sampler2D SAMPLER_DIFFUSE;
25uniform sampler2D SAMPLER_NORMALMAP;
27#define R_DYNAMIC_LIGHTS #replace r_dynamic_lights
29in_qualifier vec3 lightDirs[R_DYNAMIC_LIGHTS];
30uniform vec4 LIGHTPARAMS[R_DYNAMIC_LIGHTS];
33#include "light_fs.glsl"
35#include "model_devtools_fs.glsl"
36#include "write_fragment_fs.glsl"
44 vec4 diffuse = texture2D(SAMPLER_DIFFUSE, gl_TexCoord[0].st);
45 vec3 normal = vec3(0.0, 0.0, 1.0);
48 vec4 normalmap = texture2D(SAMPLER_NORMALMAP, gl_TexCoord[0].st);
49 normal = normalmap.rgb * 2.0 - 1.0; /** < Expanded normal */
51 normal = normalize(normal);
54 /* Lambert illumination model */
55 vec3 light = AMBIENT + SUNCOLOR * clamp(dot(sunDir, normal), 0.0, 1.0);
56 light = clamp(light + LightFragment(normal), 0.0, 2.0);
58 finalColor.rgb = diffuse.rgb * light;
59 finalColor.a = diffuse.a;
63 finalColor = FogFragment(finalColor);
66 /* Developer tools, if enabled */
67 finalColor = ApplyDeveloperTools(finalColor, sunDir, normal);
69 writeFragment(finalColor);