gKit2 light
Toggle main menu visibility
Loading...
Searching...
No Matches
gkit2_tutos
tuto_storage_buffer.glsl
Go to the documentation of this file.
1
3
4
#version 430
5
6
#ifdef VERTEX_SHADER
7
8
struct
vertex
9
{
10
vec3 position;
11
vec3 normal;
12
vec2 texcoord;
13
};
14
15
layout(std430, binding= 0) readonly buffer vertexData
16
{
17
vertex
data[];
18
};
19
20
uniform mat4 mvpMatrix;
21
uniform mat4 mvMatrix;
22
uniform mat4 normalMatrix;
23
24
out
vec3
vertex_position;
25
out
vec3
vertex_normal;
26
out
vec2
vertex_texcoord;
27
28
void
main( )
29
{
30
vec3
p= data[gl_VertexID].position;
31
vec3
n= data[gl_VertexID].normal;
32
vec2
t= data[gl_VertexID].texcoord;
33
34
gl_Position= mvpMatrix *
vec4
(p, 1);
35
36
vertex_position=
vec3
(mvMatrix *
vec4
(p, 1));
37
vertex_normal= mat3(normalMatrix) * n;
38
vertex_texcoord= t;
39
}
40
#endif
41
42
#ifdef FRAGMENT_SHADER
43
44
uniform sampler2D diffuse_color;
45
46
in
vec3
vertex_position;
47
in
vec3
vertex_normal;
48
in
vec2
vertex_texcoord;
49
50
out
vec4
fragment_color;
51
52
void
main( )
53
{
54
float
cos_theta=
dot
(
normalize
(vertex_normal),
normalize
(-vertex_position));
55
vec3
color= texture(diffuse_color, vertex_texcoord).rgb * cos_theta;
56
fragment_color=
vec4
(color, 1);
57
}
58
#endif
59
dot
float dot(const Vector &u, const Vector &v)
renvoie le produit scalaire de 2 vecteurs.
Definition
vec.cpp:181
normalize
Vector normalize(const Vector &v)
renvoie un vecteur unitaire / longueur == 1.
Definition
vec.cpp:167
vec2
vecteur generique, utilitaire.
Definition
vec.h:152
vec3
vecteur generique, utilitaire.
Definition
vec.h:169
vec4
vecteur generique 4d, ou 3d homogene, utilitaire.
Definition
vec.h:192
vertex
representation de l'indexation complete d'un sommet
Definition
wavefront.cpp:176
Generated on
for gKit2 light by
1.17.0