gKit2 light
Toggle main menu visibility
Loading...
Searching...
No Matches
gkit2_tutos
tuto4GL_normals.glsl
Go to the documentation of this file.
1
3
4
#version 330
5
6
#ifdef VERTEX_SHADER
7
in
vec3
position;
8
in
vec3
normal;
9
10
uniform mat4 mvpMatrix;
11
uniform mat4 mvMatrix;
12
13
// normal est un attribut du vertex shader, il n'est pas disponible dans le fragment shader, donc :
14
out
vec3
view_normal;
15
// il faut declarer un varying, un resultat du vertex shader
16
17
void
main( )
18
{
19
gl_Position= mvpMatrix *
vec4
(position, 1);
20
view_normal= mat3(mvMatrix) * normal;
// uniquement une rotation, mat3 suffit
21
22
}
23
#endif
24
25
#ifdef FRAGMENT_SHADER
26
uniform
vec3
color;
27
28
// recupere la normale calculee par le vertex shader, meme type, meme nom, mais in au lieu de out
29
in
vec3
view_normal;
30
// rappel: interpolation en fonction de la position du fragment dans le triangle
31
32
out
vec4
fragment_color;
33
34
void
main( )
35
{
36
fragment_color=
vec4
(color *
abs
(view_normal.z), 1);
37
}
38
#endif
abs
Color abs(const Color &color)
renvoie la valeur absolue de chaque canal.
Definition
color.cpp:71
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