~oem-solutions-group/unity-2d/clutter-1.0

« back to all changes in this revision

Viewing changes to clutter/cogl/cogl/driver/gles/cogl-fixed-vertex-shader.c

  • Committer: Bazaar Package Importer
  • Author(s): Emilio Pozuelo Monfort
  • Date: 2010-03-21 13:27:56 UTC
  • mto: (2.1.3 experimental)
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20100321132756-nf8yd30yxo3zzwcm
Tags: upstream-1.2.2
ImportĀ upstreamĀ versionĀ 1.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Cogl
 
3
 *
 
4
 * An object oriented GL/GLES Abstraction/Utility Layer
 
5
 *
 
6
 * Copyright (C) 2008,2009 Intel Corporation.
 
7
 *
 
8
 * This library is free software; you can redistribute it and/or
 
9
 * modify it under the terms of the GNU Lesser General Public
 
10
 * License as published by the Free Software Foundation; either
 
11
 * version 2 of the License, or (at your option) any later version.
 
12
 *
 
13
 * This library is distributed in the hope that it will be useful,
 
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
16
 * Lesser General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU Lesser General Public
 
19
 * License along with this library; if not, write to the
 
20
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
21
 * Boston, MA 02111-1307, USA.
 
22
 */
 
23
 
 
24
  ;
 
25
const char cogl_fixed_vertex_shader_per_vertex_attribs[] =
 
26
  "\n"
 
27
  "/* Per vertex attributes */\n"
 
28
  "attribute vec4     vertex_attrib;\n"
 
29
  "attribute vec4     color_attrib;\n"
 
30
  "\n"
 
31
  ;
 
32
const char cogl_fixed_vertex_shader_transform_matrices[] =
 
33
  "\n"
 
34
  "/* Transformation matrices */\n"
 
35
  "uniform mat4       modelview_matrix;\n"
 
36
  "uniform mat4       mvp_matrix; /* combined modelview and projection matrix */\n"
 
37
  "\n"
 
38
  ;
 
39
const char cogl_fixed_vertex_shader_output_variables[] =
 
40
  "\n"
 
41
  "/* Outputs to the fragment shader */\n"
 
42
  "varying vec4       frag_color;\n"
 
43
  "varying float      fog_amount;\n"
 
44
  "\n"
 
45
  ;
 
46
const char cogl_fixed_vertex_shader_fogging_options[] =
 
47
  "\n"
 
48
  "/* Fogging options */\n"
 
49
  "uniform float      fog_density;\n"
 
50
  "uniform float      fog_start;\n"
 
51
  "uniform float      fog_end;\n"
 
52
  "\n"
 
53
  ;
 
54
const char cogl_fixed_vertex_shader_main_start[] =
 
55
  "\n"
 
56
  "void\n"
 
57
  "main (void)\n"
 
58
  "{\n"
 
59
  "  vec4 transformed_tex_coord;\n"
 
60
  "\n"
 
61
  "  /* Calculate the transformed position */\n"
 
62
  "  gl_Position = mvp_matrix * vertex_attrib;\n"
 
63
  "\n"
 
64
  "  /* Calculate the transformed texture coordinate */\n"
 
65
  "\n"
 
66
  ;
 
67
const char cogl_fixed_vertex_shader_frag_color_start[] =
 
68
  "\n"
 
69
  "  /* Pass the interpolated vertex color on to the fragment shader */\n"
 
70
  "  frag_color = color_attrib;\n"
 
71
  "\n"
 
72
  ;
 
73
const char cogl_fixed_vertex_shader_fog_start[] =
 
74
  "\n"
 
75
  "  /* Estimate the distance from the eye using just the z-coordinate to\n"
 
76
  "     use as the fog coord */\n"
 
77
  "  vec4 eye_coord = modelview_matrix * vertex_attrib;\n"
 
78
  "  float fog_coord = abs (eye_coord.z / eye_coord.w);\n"
 
79
  "\n"
 
80
  "  /* Calculate the fog amount per-vertex and interpolate it for the\n"
 
81
  "     fragment shader */\n"
 
82
  "\n"
 
83
  ;
 
84
const char cogl_fixed_vertex_shader_fog_exp[] =
 
85
  "  fog_amount = exp (-fog_density * fog_coord);\n"
 
86
  ;
 
87
const char cogl_fixed_vertex_shader_fog_exp2[] =
 
88
  "  fog_amount = exp (-fog_density * fog_coord\n"
 
89
  "                 * fog_density * fog_coord);\n"
 
90
  ;
 
91
const char cogl_fixed_vertex_shader_fog_linear[] =
 
92
  "  fog_amount = (fog_end - fog_coord) / (fog_end - fog_start);\n"
 
93
  "\n"
 
94
  ;
 
95
const char cogl_fixed_vertex_shader_fog_end[] =
 
96
  "  fog_amount = clamp (fog_amount, 0.0, 1.0);\n"
 
97
  "\n"
 
98
  ;
 
99
const char cogl_fixed_vertex_shader_end[] =
 
100
  "}\n"
 
101
  ;