38c9d46a0e
(cogl_gles2_wrapper_init): Get uniforms for fog parameters and initialise them. (cogl_wrap_glDrawArrays): Store the modelview matrix in a uniform as well so that it can be used for fogging calculations. (cogl_wrap_glEnable, cogl_wrap_glDisable): Enable/disable fogging. (cogl_wrap_glFogx, cogl_wrap_glFogxv): Fill in wrapper to set fogging parameters. * clutter/cogl/gles/cogl-fixed-vertex-shader.glsl: Calculate the fog amount if fogging is enabled. * clutter/cogl/gles/cogl-fixed-fragment-shader.glsl: Mix with fog color. * clutter/cogl/gles/cogl-gles2-wrapper.h (CoglGles2Wrapper): Add uniforms for fogging.
39 lines
996 B
GLSL
39 lines
996 B
GLSL
/* Inputs from the vertex shader */
|
|
varying vec4 frag_color;
|
|
varying vec2 tex_coord;
|
|
varying float fog_amount;
|
|
|
|
/* Texturing options */
|
|
uniform bool texture_2d_enabled;
|
|
uniform sampler2D texture_unit;
|
|
uniform bool alpha_only;
|
|
|
|
/* Fogging options */
|
|
uniform bool fog_enabled;
|
|
uniform vec4 fog_color;
|
|
|
|
void
|
|
main (void)
|
|
{
|
|
if (texture_2d_enabled)
|
|
{
|
|
if (alpha_only)
|
|
{
|
|
/* If the texture only has an alpha channel (eg, with the
|
|
textures from the pango renderer) then the RGB components
|
|
will be black. We want to use the RGB from the current
|
|
color in that case */
|
|
gl_FragColor = frag_color;
|
|
gl_FragColor.a *= texture2D (texture_unit, tex_coord).a;
|
|
}
|
|
else
|
|
gl_FragColor = frag_color * texture2D (texture_unit, tex_coord);
|
|
}
|
|
else
|
|
gl_FragColor = frag_color;
|
|
|
|
if (fog_enabled)
|
|
/* Mix the calculated color with the fog color */
|
|
gl_FragColor.rgb = mix (fog_color.rgb, gl_FragColor.rgb, fog_amount);
|
|
}
|