gKit2 light
Toggle main menu visibility
Loading...
Searching...
No Matches
gkit2_tutos
texcoords.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= 1) in
vec2
texcoord;
9
layout(location= 2) in
vec3
normal;
10
11
uniform mat4 mvpMatrix;
12
uniform mat4 mvMatrix;
13
uniform mat4 normalMatrix;
14
15
out
vec3
vertex_position;
16
out
vec2
vertex_texcoord;
17
out
vec3
vertex_normal;
18
19
void
main( )
20
{
21
gl_Position= mvpMatrix *
vec4
(position, 1);
22
vertex_position=
vec3
(mvMatrix *
vec4
(position, 1));
23
vertex_texcoord= texcoord;
24
vertex_normal= mat3(normalMatrix) * normal;
// uniquement une rotation, mat3 suffit
25
26
}
27
#endif
28
29
#ifdef FRAGMENT_SHADER
30
uniform sampler2D color_texture;
31
32
in
vec3
vertex_position;
33
in
vec2
vertex_texcoord;
34
in
vec3
vertex_normal;
35
36
out
vec4
fragment_color;
37
38
void
main( )
39
{
40
// place la source de lumiere sur la camera, repere camera, position 0, 0, 0
41
float
cos_theta=
dot
(
normalize
(vertex_normal),
normalize
(-vertex_position));
42
//~ vec4 color= textureLod(color_texture, vertex_texcoord, 0);
43
vec4
color= texture(color_texture, vertex_texcoord);
44
fragment_color= cos_theta * color;
45
}
46
#endif
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
vec2
vecteur generique, utilitaire.
Definition
vec.h:152
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