gKit2 light
Toggle main menu visibility
Loading...
Searching...
No Matches
gkit2_tutos
instanceID.glsl
Go to the documentation of this file.
1
3
4
#version 330
5
6
#ifdef VERTEX_SHADER
7
layout(location= 0) in
vec3
position;
8
layout(location= 2) in
vec3
normal;
9
10
uniform mat4 mvpMatrix;
11
uniform mat4 normalMatrix;
12
13
out
vec3
vertex_normal;
14
15
void
main( )
16
{
17
// decale chaque instance sur l'axe x...
18
vec3
p= position +
vec3
(gl_InstanceID * 4, 0, 0);
19
gl_Position= mvpMatrix *
vec4
(p, 1);
20
21
vertex_normal= mat3(normalMatrix) * normal;
22
}
23
24
// question : comment faire tourner chaque cube sur lui meme ? au lieu de faire tourner toute la "barre" ?
25
26
#endif
27
28
#ifdef FRAGMENT_SHADER
29
in
vec3
vertex_normal;
30
31
out
vec4
fragment_color;
32
33
void
main( )
34
{
35
fragment_color=
vec4
(
abs
(
normalize
(vertex_normal).zzz), 1);
36
}
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
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