gKit2 light
Toggle main menu visibility
Loading...
Searching...
No Matches
gkit2_tutos
M2
statistics.glsl
1
2
#version 330
3
4
#ifdef VERTEX_SHADER
5
layout(location= 0) in
vec3
position;
6
7
uniform mat4 mvpMatrix;
8
uniform mat4 mvMatrix;
9
10
out
vec3
vertex_position;
11
void
main( )
12
{
13
gl_Position= mvpMatrix *
vec4
(position, 1);
14
vertex_position=
vec3
(mvMatrix *
vec4
(position, 1));
15
}
16
#endif
17
18
#ifdef FRAGMENT_SHADER
19
in
vec3
vertex_position;
20
21
#ifdef EARLY_TESTS
22
layout(early_fragment_tests) in;
23
#endif
24
25
out
vec4
fragment_color;
26
void
main( )
27
{
28
// recalcule la normale
29
// permet de recharger les objets passes a travers M2/vertices / optimisation
30
vec3
t= dFdx(vertex_position);
31
vec3
b= dFdy(vertex_position);
32
vec3
n=
normalize
(
cross
(t, b) );
33
34
float
cos_theta=
abs
(n.z);
35
vec3
color=
vec3
(1) * cos_theta;
36
fragment_color=
vec4
(color, 1);
37
}
38
#endif
abs
Color abs(const Color &color)
renvoie la valeur absolue de chaque canal.
Definition
color.cpp:71
normalize
Vector normalize(const Vector &v)
renvoie un vecteur unitaire / longueur == 1.
Definition
vec.cpp:167
cross
Vector cross(const Vector &u, const Vector &v)
renvoie le produit vectoriel de 2 vecteurs.
Definition
vec.cpp:173
vec3
vecteur generique, utilitaire.
Definition
vec.h:169
vec4
vecteur generique 4d, ou 3d homogene, utilitaire.
Definition
vec.h:192
Generated on
for gKit2 light by
1.17.0