gKit2 light
Loading...
Searching...
No Matches
is.glsl
1
2#version 330
3
4#ifdef VERTEX_SHADER
5out vec2 texcoord;
6
7void main(void)
8{
9 vec3 positions[3]= vec3[3]( vec3(-1, 1, -1), vec3( -1, -3, -1), vec3( 3, 1, -1) );
10
11 gl_Position= vec4(positions[gl_VertexID], 1.0);
12 texcoord= (positions[gl_VertexID].xy +1) / 2;
13}
14
15#endif
16
17#ifdef FRAGMENT_SHADER
18in vec2 texcoord;
19
20uniform sampler2D ptexture;
21uniform sampler2D ntexture;
22uniform sampler2D vtexture;
23
24uniform vec2 pixel;
25
26out vec4 fragment_color;
27
28void main( )
29{
30 vec3 q= texture(ptexture, texcoord).xyz;
31 vec3 qn= texture(ntexture, texcoord).xyz;
32 float v= texture(vtexture, texcoord).x;
33
34 vec3 p= texture(ptexture, pixel).xyz;
35 vec3 n= texture(ntexture, pixel).xyz;
36
37 vec3 d= q - p;
38 float cos_theta_p= max(0, dot(normalize(n), normalize(d)));
39 float cos_theta_q= max(0, dot(normalize(qn), normalize(-d)));
40 float dpq2= distance(p, q) * distance(p, q);
41
42 vec3 color= vec3(0, 0, cos_theta_p * cos_theta_q / dpq2) + abs(vec3(cos_theta_p, cos_theta_p, cos_theta_p)) / 8;
43
44 fragment_color= vec4(color, 1);
45
46 if(distance(pixel, texcoord) < 0.01)
47 fragment_color= vec4(1, 1, 1, 1);
48}
49#endif
50
Point max(const Point &a, const Point &b)
renvoie la plus grande composante de chaque point { max(a.x, b.x), max(a.y, b.y), max(a....
Definition vec.cpp:35
float distance(const Point &a, const Point &b)
renvoie la distance etre 2 points.
Definition vec.cpp:14
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