gKit2 light
Loading...
Searching...
No Matches
cubemap.glsl
Go to the documentation of this file.
1
3
4#version 430
5
6#ifdef VERTEX_SHADER
7uniform mat4 mvpMatrix;
8uniform mat4 modelMatrix;
9
10layout(location= 0) in vec3 position;
11layout(location= 2) in vec3 normal;
12out vec3 vertex_position;
13out vec3 vertex_normal;
14
15void main( )
16{
17 gl_Position= mvpMatrix * vec4(position, 1);
18 vertex_position= vec3(modelMatrix * vec4(position, 1));
19 vertex_normal= mat3(modelMatrix) * normal;
20}
21#endif
22
23
24#ifdef FRAGMENT_SHADER
25uniform vec3 camera_position;
26uniform samplerCube texture0;
27
28const float alpha= 400;
29const float k= 0.8;
30
31in vec3 vertex_position;
32in vec3 vertex_normal;
33out vec4 fragment_color;
34
35void main( )
36{
37 vec3 v= vertex_position - camera_position;
38 vec3 n= normalize(vertex_normal);
39 //~ vec3 color= texture(texture0, n).rgb; // couleur dans la direction de la normale
40
41 vec3 m= reflect(v, n);
42 vec3 color= texture(texture0, m).rgb; // couleur dans la direction du reflet miroir
43
44 //~ // ou approximation pour un modele blinn - phong, cf shaders et brdfs...
45 //~ float size= textureSize(texture0, 0).x;
46 //~ float dlevel= floor(log2(size)) +1;
47 //~ vec3 diffuse= textureLod(texture0, n, dlevel).rgb;
48
49 //~ float glevel= max(0, log2(size * sqrt(3)) - 0.5 * log2(alpha+1));
50 //~ vec3 glossy= textureLod(texture0, m, glevel).rgb;
51
52 //~ vec3 color= k * diffuse + (1 - k) * glossy;
53
54 fragment_color= vec4(color, 1);
55}
56#endif
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