gKit2 light
Toggle main menu visibility
Loading...
Searching...
No Matches
gkit2_tutos
cubemap.glsl
Go to the documentation of this file.
1
3
4
#version 430
5
6
#ifdef VERTEX_SHADER
7
uniform mat4 mvpMatrix;
8
uniform mat4 modelMatrix;
9
10
layout(location= 0) in
vec3
position;
11
layout(location= 2) in
vec3
normal;
12
out
vec3
vertex_position;
13
out
vec3
vertex_normal;
14
15
void
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
25
uniform
vec3
camera_position;
26
uniform samplerCube texture0;
27
28
const
float
alpha= 400;
29
const
float
k= 0.8;
30
31
in
vec3
vertex_position;
32
in
vec3
vertex_normal;
33
out
vec4
fragment_color;
34
35
void
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
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