forked from Librelancer/Librelancer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Basic_PositionNormalTexture.glsl
53 lines (48 loc) · 1.47 KB
/
Basic_PositionNormalTexture.glsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
@feature NORMALMAP
@include(Basic_Features.inc)
@include(Basic_Fragment.inc)
@vertex
@include(includes/lighting.inc)
@include(includes/camera.inc)
in vec3 vertex_position;
in vec3 vertex_normal;
in vec2 vertex_texture1;
#ifdef NORMALMAP
out mat3 tbn;
in vec2 vertex_texture2;
in vec2 vertex_texture3;
#else
out vec3 out_normal;
#endif
out vec2 out_texcoord;
out vec2 out_texcoord2;
out vec3 world_position;
out vec4 out_vertexcolor;
out vec4 view_position;
uniform mat4x4 World;
uniform mat4x4 NormalMatrix;
uniform vec4 MaterialAnim;
void main()
{
vec4 pos = (ViewProjection * World) * vec4(vertex_position, 1.0);
gl_Position = pos;
world_position = (World * vec4(vertex_position,1)).xyz;
view_position = (View * World) * vec4(vertex_position,1);
vec3 n = (NormalMatrix * vec4(vertex_normal,0)).xyz;
#ifdef NORMALMAP
vec4 v_tangent = vec4(vertex_texture2.x, vertex_texture2.y, vertex_texture3.x, vertex_texture3.y);
vec3 normalW = normalize(vec3(NormalMatrix * vec4(vertex_normal.xyz, 0.0)));
vec3 tangentW = normalize(vec3(NormalMatrix * vec4(v_tangent.xyz, 0.0)));
vec3 bitangentW = cross(normalW, tangentW) * v_tangent.w;
tbn = mat3(tangentW, bitangentW, normalW);
#else
out_normal = n;
#endif
out_texcoord = vec2(
(vertex_texture1.x + MaterialAnim.x) * MaterialAnim.z,
(vertex_texture1.y + MaterialAnim.y) * MaterialAnim.w
);
out_texcoord2 = out_texcoord;
out_vertexcolor = vec4(1,1,1,1);
light_vert(world_position, view_position, n);
}