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
#version 140
#define INSTANCE_COUNT 128

uniform mat4 viewProjectionMatrix;
uniform mat3 normalMatrix;

in vec4 position;
in vec2 texCoords;
in vec3 normal;
in vec3 tangent;
in float bitangentSign;

uniform vec3[INSTANCE_COUNT] instancePosition;


out vec3 vNormal;
out vec3 vTangent;
out float vBitangentSign;

out vec2 vTexCoords;

void main(){
    gl_Position = viewProjectionMatrix * vec4(position.xyz + instancePosition[int(position.w)], 1);
    
    vTexCoords = texCoords;
    
    vNormal = normalMatrix * normal;
    vTangent = normalMatrix * tangent;
    vBitangentSign = bitangentSign;
}