gKit2 light
Loading...
Searching...
No Matches
texcoords.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= 1) in vec2 texcoord;
9layout(location= 2) in vec3 normal;
10
11uniform mat4 mvpMatrix;
12uniform mat4 mvMatrix;
13uniform mat4 normalMatrix;
14
15out vec3 vertex_position;
16out vec2 vertex_texcoord;
17out vec3 vertex_normal;
18
19void 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
30uniform sampler2D color_texture;
31
32in vec3 vertex_position;
33in vec2 vertex_texcoord;
34in vec3 vertex_normal;
35
36out vec4 fragment_color;
37
38void 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
float dot(const Vector &u, const Vector &v)
renvoie le produit scalaire de 2 vecteurs.
Definition vec.cpp:181
Vector normalize(const Vector &v)
renvoie un vecteur unitaire / longueur == 1.
Definition vec.cpp:167
vecteur generique, utilitaire.
Definition vec.h:152
vecteur generique, utilitaire.
Definition vec.h:169
vecteur generique 4d, ou 3d homogene, utilitaire.
Definition vec.h:192