gKit2 light
Toggle main menu visibility
Loading...
Searching...
No Matches
gkit2_tutos
deferred_mesh.glsl
1
2
#version 330
3
4
#ifdef VERTEX_SHADER
5
layout(location= 0) in
vec3
position;
6
layout(location= 2) in
vec3
normal;
7
8
uniform mat4 mvpMatrix;
9
uniform mat4 mvMatrix;
10
11
out
vec3
vertex_position;
12
out
vec3
vertex_normal;
13
14
void
main( )
15
{
16
gl_Position= mvpMatrix *
vec4
(position, 1);
17
18
vertex_position=
vec3
(mvMatrix *
vec4
(position, 1));
19
vertex_normal= mat3(mvMatrix) * normal;
20
}
21
#endif
22
23
#ifdef FRAGMENT_SHADER
24
out
vec4
fragment_color;
25
26
in
vec3
vertex_position;
27
in
vec3
vertex_normal;
28
29
void
main( )
30
{
31
vec3
l=
normalize
(-vertex_position);
// la camera est la source de lumiere.
32
vec3
n=
normalize
(vertex_normal);
33
float
cos_theta=
max
(0,
dot
(n, l));
34
vec3
color=
vec3
(0.8) * cos_theta;
35
36
fragment_color=
vec4
(color, 1);
37
}
38
#endif
max
Point max(const Point &a, const Point &b)
renvoie la plus grande composante de chaque point { max(a.x, b.x), max(a.y, b.y), max(a....
Definition
vec.cpp:35
dot
float dot(const Vector &u, const Vector &v)
renvoie le produit scalaire de 2 vecteurs.
Definition
vec.cpp:181
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