gKit2 light
Loading...
Searching...
No Matches
instanceID.glsl
Go to the documentation of this file.
1
3
4#version 330
5
6#ifdef VERTEX_SHADER
7layout(location= 0) in vec3 position;
8layout(location= 2) in vec3 normal;
9
10uniform mat4 mvpMatrix;
11uniform mat4 normalMatrix;
12
13out vec3 vertex_normal;
14
15void 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
29in vec3 vertex_normal;
30
31out vec4 fragment_color;
32
33void main( )
34{
35 fragment_color= vec4(abs(normalize(vertex_normal).zzz), 1);
36}
37
38#endif
Color abs(const Color &color)
renvoie la valeur absolue de chaque canal.
Definition color.cpp:71
Vector normalize(const Vector &v)
renvoie un vecteur unitaire / longueur == 1.
Definition vec.cpp:167
vecteur generique, utilitaire.
Definition vec.h:169
vecteur generique 4d, ou 3d homogene, utilitaire.
Definition vec.h:192