gKit2 light
Loading...
Searching...
No Matches
draw_cubemap.glsl
Go to the documentation of this file.
1
3#version 330
4
5#ifdef VERTEX_SHADER
6
7void main( )
8{
9 // repere projectif
10 vec2 positions[3]= vec2[3]( vec2(-1,-1), vec2(3, -1), vec2(-1, 3) );
11 // place le point sur le plan far / z=1... a l'infini
12 gl_Position= vec4(positions[gl_VertexID], 1, 1);
13}
14#endif
15
16#ifdef FRAGMENT_SHADER
17
18uniform mat4 invMatrix;
19uniform vec3 camera_position;
20uniform samplerCube texture0;
21
22out vec4 fragment_color;
23
24void main( )
25{
26 vec4 p= invMatrix * vec4(gl_FragCoord.xyz, 1);
27 vec3 pixel= p.xyz / p.w;
28
29 vec3 direction= normalize(pixel - camera_position);
30 fragment_color= texture(texture0, direction);
31}
32#endif
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