mutter/gles/cogl-fixed-fragment-shader.glsl
Robert Bragg 509928cc76 [multi-texturing] This adds a new cogl_multi_texture API for GL,GLES1 + GLES2
Multitexturing allows blending multiple layers of texture data when texturing
some geometry. A common use is for pre-baked light maps which can give nice
lighting effects relativly cheaply. Another is for dot-3 bump mapping, and
another is applying alpha channel masks.

The dot-3 bump mapping would be really nice one day, but currently cogl doesn't
support lighting so that's not dealt with in this patch.

notable limitations:
- It can only texture rectangles a.t.m - and like cogl_texture_rectangle there
is no support for rotated texturing.
- Sliced textures are not supported. I think I've figured out how to handle
layers with different slice sizes at least for rectangular geometry, but I'm
not sure how complex it becomes once rotations are possible and texturing
arbitrary cogl_polygons.
- Except for this new API, cogl still doesn't know about more than one texture
unit, and so has no way of caching any enables related to other units. So that
things don't break it's currently necessary to disable anything to do with
additional units as soon as we are done with them which isn't ideal.
- No clutter API yet.
2008-12-22 16:35:51 +00:00

63 lines
1.6 KiB
GLSL

/*** cogl_fixed_fragment_shader_variables_start ***/
/* There is no default precision for floats in fragment shaders in
GLES 2 so we need to define one */
precision highp float;
/*** cogl_fixed_fragment_shader_inputs ***/
/* Inputs from the vertex shader */
varying vec4 frag_color;
varying float fog_amount;
/*** cogl_fixed_fragment_shader_texturing_options ***/
/* Texturing options */
/*** cogl_fixed_fragment_shader_fogging_options ***/
/* Fogging options */
uniform vec4 fog_color;
/* Alpha test options */
uniform float alpha_test_ref;
/*** cogl_fixed_fragment_shader_main_declare ***/
void
main (void)
{
/*** cogl_fixed_fragment_shader_main_start ***/
/*** cogl_fixed_fragment_shader_fog ***/
/* Mix the calculated color with the fog color */
gl_FragColor.rgb = mix (fog_color.rgb, gl_FragColor.rgb, fog_amount);
/* Alpha testing */
/*** cogl_fixed_fragment_shader_alpha_never ***/
discard;
/*** cogl_fixed_fragment_shader_alpha_less ***/
if (gl_FragColor.a >= alpha_test_ref)
discard;
/*** cogl_fixed_fragment_shader_alpha_equal ***/
if (gl_FragColor.a != alpha_test_ref)
discard;
/*** cogl_fixed_fragment_shader_alpha_lequal ***/
if (gl_FragColor.a > alpha_test_ref)
discard;
/*** cogl_fixed_fragment_shader_alpha_greater ***/
if (gl_FragColor.a <= alpha_test_ref)
discard;
/*** cogl_fixed_fragment_shader_alpha_notequal ***/
if (gl_FragColor.a == alpha_test_ref)
discard;
/*** cogl_fixed_fragment_shader_alpha_gequal ***/
if (gl_FragColor.a < alpha_test_ref)
discard;
/*** cogl_fixed_fragment_shader_end ***/
}