gKit2 light
Loading...
Searching...
No Matches
tuto5GL_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= 22;
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 m= reflect(v, n);
40 //~ vec3 color= texture(texture0, m).rgb;
41 vec3 color= texture(texture0, n).rgb;
42
43 //~ // approximation
44 //~ float w= textureSize(texture0, 0).x;
45 //~ float dlevel= log2(w) +1;
46 //~ float glevel= max(0, log2(w * sqrt(3)) - 0.5 * log2(alpha+1));
47 //~ vec3 diffuse= textureLod(texture0, n, dlevel).rgb;
48 //~ vec3 glossy= textureLod(texture0, m, glevel).rgb;
49 //~ vec3 color= k * diffuse + (1 - k) * glossy;
50
51 fragment_color= vec4(color, 1);
52}
53#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