1
0
Fork 0
mutter-performance-source/clutter/cogl/gles/cogl-fixed-vertex-shader.glsl
Robert Bragg ea643ca0f8 [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

65 lines
1.8 KiB
GLSL

/*** cogl_fixed_vertex_shader_per_vertex_attribs ***/
/* Per vertex attributes */
attribute vec4 vertex_attrib;
attribute vec4 color_attrib;
/*** cogl_fixed_vertex_shader_transform_matrices ***/
/* Transformation matrices */
uniform mat4 modelview_matrix;
uniform mat4 mvp_matrix; /* combined modelview and projection matrix */
/*** cogl_fixed_vertex_shader_output_variables ***/
/* Outputs to the fragment shader */
varying vec4 frag_color;
varying float fog_amount;
/*** cogl_fixed_vertex_shader_fogging_options ***/
/* Fogging options */
uniform float fog_density;
uniform float fog_start;
uniform float fog_end;
/*** cogl_fixed_vertex_shader_main_start ***/
void
main (void)
{
vec4 transformed_tex_coord;
/* Calculate the transformed position */
gl_Position = mvp_matrix * vertex_attrib;
/* Calculate the transformed texture coordinate */
/*** cogl_fixed_vertex_shader_frag_color_start ***/
/* Pass the interpolated vertex color on to the fragment shader */
frag_color = color_attrib;
/*** cogl_fixed_vertex_shader_fog_start ***/
/* Estimate the distance from the eye using just the z-coordinate to
use as the fog coord */
vec4 eye_coord = modelview_matrix * vertex_attrib;
float fog_coord = abs (eye_coord.z / eye_coord.w);
/* Calculate the fog amount per-vertex and interpolate it for the
fragment shader */
/*** cogl_fixed_vertex_shader_fog_exp ***/
fog_amount = exp (-fog_density * fog_coord);
/*** cogl_fixed_vertex_shader_fog_exp2 ***/
fog_amount = exp (-fog_density * fog_coord
* fog_density * fog_coord);
/*** cogl_fixed_vertex_shader_fog_linear ***/
fog_amount = (fog_end - fog_coord) / (fog_end - fog_start);
/*** cogl_fixed_vertex_shader_fog_end ***/
fog_amount = clamp (fog_amount, 0.0, 1.0);
/*** cogl_fixed_vertex_shader_end ***/
}