mirror of
https://github.com/brl/mutter.git
synced 2024-12-25 12:32:05 +00:00
353ea5299b
We now prepend a set of defines to any given GLSL shader so that we can define builtin uniforms/attributes within the "cogl" namespace that we can use to provide compatibility across a range of the earlier versions of GLSL. This updates test-cogl-shader-glsl.c and test-shader.c so they no longer needs to special case GLES vs GL when splicing together its shaders as well as the blur, colorize and desaturate effects. To get a feel for the new, portable uniform/attribute names here are the defines for OpenGL vertex shaders: #define cogl_position_in gl_Vertex #define cogl_color_in gl_Color #define cogl_tex_coord_in gl_MultiTexCoord0 #define cogl_tex_coord0_in gl_MultiTexCoord0 #define cogl_tex_coord1_in gl_MultiTexCoord1 #define cogl_tex_coord2_in gl_MultiTexCoord2 #define cogl_tex_coord3_in gl_MultiTexCoord3 #define cogl_tex_coord4_in gl_MultiTexCoord4 #define cogl_tex_coord5_in gl_MultiTexCoord5 #define cogl_tex_coord6_in gl_MultiTexCoord6 #define cogl_tex_coord7_in gl_MultiTexCoord7 #define cogl_normal_in gl_Normal #define cogl_position_out gl_Position #define cogl_point_size_out gl_PointSize #define cogl_color_out gl_FrontColor #define cogl_tex_coord_out gl_TexCoord #define cogl_modelview_matrix gl_ModelViewMatrix #define cogl_modelview_projection_matrix gl_ModelViewProjectionMatrix #define cogl_projection_matrix gl_ProjectionMatrix #define cogl_texture_matrix gl_TextureMatrix And for fragment shaders we have: #define cogl_color_in gl_Color #define cogl_tex_coord_in gl_TexCoord #define cogl_color_out gl_FragColor #define cogl_depth_out gl_FragDepth #define cogl_front_facing gl_FrontFacing
65 lines
1.7 KiB
GLSL
65 lines
1.7 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 _cogl_color;
|
|
varying float _cogl_fog_amount;
|
|
|
|
/*** _cogl_fixed_fragment_shader_texturing_options ***/
|
|
|
|
/* Texturing options */
|
|
|
|
/*** _cogl_fixed_fragment_shader_fogging_options ***/
|
|
|
|
/* Fogging options */
|
|
uniform vec4 _cogl_fog_color;
|
|
|
|
/* Alpha test options */
|
|
uniform float _cogl_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 (_cogl_fog_color.rgb, gl_FragColor.rgb,
|
|
_cogl_fog_amount);
|
|
|
|
/* Alpha testing */
|
|
|
|
/*** _cogl_fixed_fragment_shader_alpha_never ***/
|
|
discard;
|
|
/*** _cogl_fixed_fragment_shader_alpha_less ***/
|
|
if (gl_FragColor.a >= _cogl_alpha_test_ref)
|
|
discard;
|
|
/*** _cogl_fixed_fragment_shader_alpha_equal ***/
|
|
if (gl_FragColor.a != _cogl_alpha_test_ref)
|
|
discard;
|
|
/*** _cogl_fixed_fragment_shader_alpha_lequal ***/
|
|
if (gl_FragColor.a > _cogl_alpha_test_ref)
|
|
discard;
|
|
/*** _cogl_fixed_fragment_shader_alpha_greater ***/
|
|
if (gl_FragColor.a <= _cogl_alpha_test_ref)
|
|
discard;
|
|
/*** _cogl_fixed_fragment_shader_alpha_notequal ***/
|
|
if (gl_FragColor.a == _cogl_alpha_test_ref)
|
|
discard;
|
|
/*** _cogl_fixed_fragment_shader_alpha_gequal ***/
|
|
if (gl_FragColor.a < _cogl_alpha_test_ref)
|
|
discard;
|
|
|
|
/*** _cogl_fixed_fragment_shader_end ***/
|
|
}
|
|
|