2010-06-11 13:36:38 +00:00
|
|
|
/*** _cogl_fixed_vertex_shader_per_vertex_attribs ***/
|
2008-06-24 16:21:40 +00:00
|
|
|
|
2008-05-27 17:42:50 +00:00
|
|
|
/* Per vertex attributes */
|
2010-07-23 16:46:41 +00:00
|
|
|
attribute vec4 cogl_position_in;
|
|
|
|
attribute vec4 cogl_color_in;
|
2008-05-27 17:42:50 +00:00
|
|
|
|
2010-06-11 13:36:38 +00:00
|
|
|
/*** _cogl_fixed_vertex_shader_transform_matrices ***/
|
2008-12-11 15:33:38 +00:00
|
|
|
|
2008-05-27 17:42:50 +00:00
|
|
|
/* Transformation matrices */
|
2010-07-23 16:46:41 +00:00
|
|
|
uniform mat4 cogl_modelview_matrix;
|
|
|
|
uniform mat4 cogl_modelview_projection_matrix; /* combined modelview and projection matrix */
|
2008-12-11 15:33:38 +00:00
|
|
|
|
2010-06-11 13:36:38 +00:00
|
|
|
/*** _cogl_fixed_vertex_shader_output_variables ***/
|
2008-05-27 17:42:50 +00:00
|
|
|
|
|
|
|
/* Outputs to the fragment shader */
|
2010-07-23 16:46:41 +00:00
|
|
|
varying vec4 _cogl_color;
|
|
|
|
varying float _cogl_fog_amount;
|
2008-05-28 17:14:17 +00:00
|
|
|
|
2010-06-11 13:36:38 +00:00
|
|
|
/*** _cogl_fixed_vertex_shader_fogging_options ***/
|
2008-12-11 15:33:38 +00:00
|
|
|
|
2008-05-28 17:14:17 +00:00
|
|
|
/* Fogging options */
|
2010-07-23 16:46:41 +00:00
|
|
|
uniform float _cogl_fog_density;
|
|
|
|
uniform float _cogl_fog_start;
|
|
|
|
uniform float _cogl_fog_end;
|
2008-05-28 17:14:17 +00:00
|
|
|
|
2010-03-22 09:32:17 +00:00
|
|
|
/* Point options */
|
2010-07-23 16:46:41 +00:00
|
|
|
uniform float cogl_point_size_in;
|
2010-03-22 09:32:17 +00:00
|
|
|
|
2010-06-11 13:36:38 +00:00
|
|
|
/*** _cogl_fixed_vertex_shader_main_start ***/
|
2008-12-11 15:33:38 +00:00
|
|
|
|
2008-05-27 17:42:50 +00:00
|
|
|
void
|
|
|
|
main (void)
|
|
|
|
{
|
2008-12-11 15:33:38 +00:00
|
|
|
vec4 transformed_tex_coord;
|
|
|
|
|
2008-05-27 17:42:50 +00:00
|
|
|
/* Calculate the transformed position */
|
2010-07-23 16:46:41 +00:00
|
|
|
gl_Position = cogl_modelview_projection_matrix * cogl_position_in;
|
2008-05-27 17:42:50 +00:00
|
|
|
|
2010-03-22 09:32:17 +00:00
|
|
|
/* Copy across the point size from the uniform */
|
2010-07-23 16:46:41 +00:00
|
|
|
gl_PointSize = cogl_point_size_in;
|
2010-03-22 09:32:17 +00:00
|
|
|
|
2008-05-27 17:42:50 +00:00
|
|
|
/* Calculate the transformed texture coordinate */
|
2008-12-11 15:33:38 +00:00
|
|
|
|
2010-06-11 13:36:38 +00:00
|
|
|
/*** _cogl_fixed_vertex_shader_frag_color_start ***/
|
2008-05-27 17:42:50 +00:00
|
|
|
|
|
|
|
/* Pass the interpolated vertex color on to the fragment shader */
|
2010-07-23 16:46:41 +00:00
|
|
|
_cogl_color = cogl_color_in;
|
2008-05-28 17:14:17 +00:00
|
|
|
|
2010-06-11 13:36:38 +00:00
|
|
|
/*** _cogl_fixed_vertex_shader_fog_start ***/
|
2008-06-24 16:21:40 +00:00
|
|
|
|
|
|
|
/* Estimate the distance from the eye using just the z-coordinate to
|
|
|
|
use as the fog coord */
|
2010-07-23 16:46:41 +00:00
|
|
|
vec4 eye_coord = cogl_modelview_matrix * cogl_position_in;
|
2008-06-24 16:21:40 +00:00
|
|
|
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 13:36:38 +00:00
|
|
|
/*** _cogl_fixed_vertex_shader_fog_exp ***/
|
2010-07-23 16:46:41 +00:00
|
|
|
_cogl_fog_amount = exp (-fog_density * fog_coord);
|
2010-06-11 13:36:38 +00:00
|
|
|
/*** _cogl_fixed_vertex_shader_fog_exp2 ***/
|
2010-07-23 16:46:41 +00:00
|
|
|
_cogl_fog_amount = exp (-_cogl_fog_density * fog_coord
|
|
|
|
* _cogl_fog_density * fog_coord);
|
2010-06-11 13:36:38 +00:00
|
|
|
/*** _cogl_fixed_vertex_shader_fog_linear ***/
|
2010-07-23 16:46:41 +00:00
|
|
|
_cogl_fog_amount = (_cogl_fog_end - fog_coord) /
|
|
|
|
(_cogl_fog_end - _cogl_fog_start);
|
2008-06-24 16:21:40 +00:00
|
|
|
|
2010-06-11 13:36:38 +00:00
|
|
|
/*** _cogl_fixed_vertex_shader_fog_end ***/
|
2010-07-23 16:46:41 +00:00
|
|
|
_cogl_fog_amount = clamp (_cogl_fog_amount, 0.0, 1.0);
|
2008-06-24 16:21:40 +00:00
|
|
|
|
2010-06-11 13:36:38 +00:00
|
|
|
/*** _cogl_fixed_vertex_shader_end ***/
|
2008-05-27 17:42:50 +00:00
|
|
|
}
|
2010-07-23 16:46:41 +00:00
|
|
|
|