3 * @brief Warp 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
18 /** After glsl1110 this need to be explicitly declared; used by fixed functionality at the end of the OpenGL pipeline.*/
19 out vec4 gl_FragData[2];
21 /** After glsl1110 this need to be explicitly declared; used by fixed functionality at the end of the OpenGL pipeline.*/
22 out vec4 gl_FragColor;
27uniform float GLOWSCALE;
29uniform sampler2D SAMPLER_DIFFUSE;
30uniform sampler2D SAMPLER_WARP;
31uniform sampler2D SAMPLER_GLOWMAP;
37 vec4 finalColor = vec4(0.0);
39 /* Sample glowmap and calculate final glow color. */
40 vec4 glow_tex = texture2D(SAMPLER_GLOWMAP, gl_TexCoord[0].st);
41 vec3 glowcolor = glow_tex.rgb * glow_tex.a * GLOWSCALE;
43 /* Sample the warp texture at a time-varied offset, */
44 vec4 warp = texture2D(SAMPLER_WARP, gl_TexCoord[0].xy + OFFSET.xy);
46 /* and derive a diffuse texcoord based on the warp data, */
47 vec2 coord = vec2(gl_TexCoord[0].x + warp.z, gl_TexCoord[0].y + warp.w);
49 /* sample the diffuse texture, factoring in primary color as well. */
50 finalColor = gl_Color * texture2D(SAMPLER_DIFFUSE, coord);
54 finalColor = FogFragment(finalColor);
58 gl_FragData[0] = finalColor;
59 if (GLOWSCALE > 0.01) {
60 gl_FragData[1].rgb = glowcolor;
61 gl_FragData[1].a = 1.0;
63 gl_FragData[1] = vec4(0,0,0,1);
66 gl_FragColor.rgb = finalColor.rgb + glowcolor;
67 gl_FragColor.a = finalColor.a;