2010-06-11 09:36:38 -04:00
|
|
|
/*** _cogl_fixed_vertex_shader_per_vertex_attribs ***/
|
2008-06-24 12:21:40 -04:00
|
|
|
|
2008-05-27 13:42:50 -04:00
|
|
|
/* Per vertex attributes */
|
2008-05-28 13:14:17 -04:00
|
|
|
attribute vec4 vertex_attrib;
|
|
|
|
attribute vec4 color_attrib;
|
2008-05-27 13:42:50 -04:00
|
|
|
|
2010-06-11 09:36:38 -04:00
|
|
|
/*** _cogl_fixed_vertex_shader_transform_matrices ***/
|
2008-12-11 10:33:38 -05:00
|
|
|
|
2008-05-27 13:42:50 -04:00
|
|
|
/* Transformation matrices */
|
2008-05-28 13:14:17 -04:00
|
|
|
uniform mat4 modelview_matrix;
|
|
|
|
uniform mat4 mvp_matrix; /* combined modelview and projection matrix */
|
2008-12-11 10:33:38 -05:00
|
|
|
|
2010-06-11 09:36:38 -04:00
|
|
|
/*** _cogl_fixed_vertex_shader_output_variables ***/
|
2008-05-27 13:42:50 -04:00
|
|
|
|
|
|
|
/* Outputs to the fragment shader */
|
2008-05-28 13:14:17 -04:00
|
|
|
varying vec4 frag_color;
|
|
|
|
varying float fog_amount;
|
|
|
|
|
2010-06-11 09:36:38 -04:00
|
|
|
/*** _cogl_fixed_vertex_shader_fogging_options ***/
|
2008-12-11 10:33:38 -05:00
|
|
|
|
2008-05-28 13:14:17 -04:00
|
|
|
/* Fogging options */
|
|
|
|
uniform float fog_density;
|
|
|
|
uniform float fog_start;
|
|
|
|
uniform float fog_end;
|
|
|
|
|
2010-03-22 05:32:17 -04:00
|
|
|
/* Point options */
|
|
|
|
uniform float point_size;
|
|
|
|
|
2010-06-11 09:36:38 -04:00
|
|
|
/*** _cogl_fixed_vertex_shader_main_start ***/
|
2008-12-11 10:33:38 -05:00
|
|
|
|
2008-05-27 13:42:50 -04:00
|
|
|
void
|
|
|
|
main (void)
|
|
|
|
{
|
2008-12-11 10:33:38 -05:00
|
|
|
vec4 transformed_tex_coord;
|
|
|
|
|
2008-05-27 13:42:50 -04:00
|
|
|
/* Calculate the transformed position */
|
|
|
|
gl_Position = mvp_matrix * vertex_attrib;
|
|
|
|
|
2010-03-22 05:32:17 -04:00
|
|
|
/* Copy across the point size from the uniform */
|
|
|
|
gl_PointSize = point_size;
|
|
|
|
|
2008-05-27 13:42:50 -04:00
|
|
|
/* Calculate the transformed texture coordinate */
|
2008-12-11 10:33:38 -05:00
|
|
|
|
2010-06-11 09:36:38 -04:00
|
|
|
/*** _cogl_fixed_vertex_shader_frag_color_start ***/
|
2008-05-27 13:42:50 -04:00
|
|
|
|
|
|
|
/* Pass the interpolated vertex color on to the fragment shader */
|
|
|
|
frag_color = color_attrib;
|
2008-05-28 13:14:17 -04:00
|
|
|
|
2010-06-11 09:36:38 -04:00
|
|
|
/*** _cogl_fixed_vertex_shader_fog_start ***/
|
2008-06-24 12:21:40 -04:00
|
|
|
|
|
|
|
/* 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 */
|
|
|
|
|
2010-06-11 09:36:38 -04:00
|
|
|
/*** _cogl_fixed_vertex_shader_fog_exp ***/
|
2008-06-24 12:21:40 -04:00
|
|
|
fog_amount = exp (-fog_density * fog_coord);
|
2010-06-11 09:36:38 -04:00
|
|
|
/*** _cogl_fixed_vertex_shader_fog_exp2 ***/
|
2008-06-24 12:21:40 -04:00
|
|
|
fog_amount = exp (-fog_density * fog_coord
|
|
|
|
* fog_density * fog_coord);
|
2010-06-11 09:36:38 -04:00
|
|
|
/*** _cogl_fixed_vertex_shader_fog_linear ***/
|
2008-06-24 12:21:40 -04:00
|
|
|
fog_amount = (fog_end - fog_coord) / (fog_end - fog_start);
|
|
|
|
|
2010-06-11 09:36:38 -04:00
|
|
|
/*** _cogl_fixed_vertex_shader_fog_end ***/
|
2008-06-24 12:21:40 -04:00
|
|
|
fog_amount = clamp (fog_amount, 0.0, 1.0);
|
|
|
|
|
2010-06-11 09:36:38 -04:00
|
|
|
/*** _cogl_fixed_vertex_shader_end ***/
|
2008-05-27 13:42:50 -04:00
|
|
|
}
|