Spaces:
Sleeping
Sleeping
File size: 1,794 Bytes
b4c8bc3 |
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
#version 330 core
// Vertex Attributes
layout(location = 0) in vec3 position;
#ifdef NORMAL_LOC
layout(location = NORMAL_LOC) in vec3 normal;
#endif
#ifdef TANGENT_LOC
layout(location = TANGENT_LOC) in vec4 tangent;
#endif
#ifdef TEXCOORD_0_LOC
layout(location = TEXCOORD_0_LOC) in vec2 texcoord_0;
#endif
#ifdef TEXCOORD_1_LOC
layout(location = TEXCOORD_1_LOC) in vec2 texcoord_1;
#endif
#ifdef COLOR_0_LOC
layout(location = COLOR_0_LOC) in vec4 color_0;
#endif
#ifdef JOINTS_0_LOC
layout(location = JOINTS_0_LOC) in vec4 joints_0;
#endif
#ifdef WEIGHTS_0_LOC
layout(location = WEIGHTS_0_LOC) in vec4 weights_0;
#endif
layout(location = INST_M_LOC) in mat4 inst_m;
// Uniforms
uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
// Outputs
out vec3 frag_position;
#ifdef NORMAL_LOC
out vec3 frag_normal;
#endif
#ifdef HAS_NORMAL_TEX
#ifdef TANGENT_LOC
#ifdef NORMAL_LOC
out mat3 tbn;
#endif
#endif
#endif
#ifdef TEXCOORD_0_LOC
out vec2 uv_0;
#endif
#ifdef TEXCOORD_1_LOC
out vec2 uv_1;
#endif
#ifdef COLOR_0_LOC
out vec4 color_multiplier;
#endif
void main()
{
gl_Position = P * V * M * inst_m * vec4(position, 1);
frag_position = vec3(M * inst_m * vec4(position, 1.0));
mat4 N = transpose(inverse(M * inst_m));
#ifdef NORMAL_LOC
frag_normal = normalize(vec3(N * vec4(normal, 0.0)));
#endif
#ifdef HAS_NORMAL_TEX
#ifdef TANGENT_LOC
#ifdef NORMAL_LOC
vec3 normal_w = normalize(vec3(N * vec4(normal, 0.0)));
vec3 tangent_w = normalize(vec3(N * vec4(tangent.xyz, 0.0)));
vec3 bitangent_w = cross(normal_w, tangent_w) * tangent.w;
tbn = mat3(tangent_w, bitangent_w, normal_w);
#endif
#endif
#endif
#ifdef TEXCOORD_0_LOC
uv_0 = texcoord_0;
#endif
#ifdef TEXCOORD_1_LOC
uv_1 = texcoord_1;
#endif
#ifdef COLOR_0_LOC
color_multiplier = color_0;
#endif
}
|