5 uniform mat4 mvpMatrix;
7 layout(location= 0) in
vec3 position;
8 layout(location= 1) in
vec2 texcoords;
9 layout(location= 2) in
vec3 normal;
11 out
vec3 vertex_position;
12 out
vec2 vertex_texcoords;
14 out
vec3 view_position;
19 gl_Position= mvpMatrix *
vec4(position, 1);
21 vertex_position= position;
22 vertex_texcoords= texcoords;
24 view_position=
vec3(mvMatrix *
vec4(position, 1));
25 view_normal= mat3(mvMatrix) * normal;
30 #ifdef FRAGMENT_SHADER
31 out
vec4 fragment_color;
33 in
vec3 vertex_position;
34 in
vec2 vertex_texcoords;
36 in
vec3 view_position;
40 float hash2D( in
vec2 v ) {
return fract(1.0e4*sin(17.0*v.x + 0.1*v.y) * (0.1 + abs(sin(13.0*v.y + v.x)))); }
41 float hash3D( in
vec3 v ) {
return hash2D(
vec2(hash2D(v.xy), v.z)); }
45 float fresnel(
const in
float F0,
const in
vec3 n,
const in
vec3 l )
47 float ndotl= abs(
dot(n, l));
48 return F0 + (1 - F0) * pow(1 - ndotl, 5);
62 float f= fresnel(0.028, n, o);
65 float i= floor(f * msaa);
71 float rng=
min(msaa, (f * msaa + hash3D(
vec3(vertex_position.xy, view_position.z)) - 0.5)) / float(msaa);
73 fragment_color=
vec4(color.rgb, rng);
Point min(const Point &a, const Point &b)
renvoie la plus petite composante de chaque point. x, y, z= min(a.x, b.x), min(a.y,...
float dot(const Vector &u, const Vector &v)
renvoie le produit scalaire de 2 vecteurs.
Vector normalize(const Vector &v)
renvoie un vecteur unitaire / longueur == 1.
vecteur generique, utilitaire.
vecteur generique, utilitaire.
vecteur generique 4d, ou 3d homogene, utilitaire.