Added instanced drawing to the GBuffer

This commit is contained in:
grayson committed 2021-10-01 14:16:47 -05:00
1 parent ba19742bfe
commit f422d1d138
14 files changed
+63 -179

No files matched your search

@@ -25,6 +25,6 @@ void main() {
normals = hasNormTex[matNum] ? normalize(tbn * (texture(normalTexture[matNum], texCoord).xyz * 2.0 - 1.0)) : normal;
diffuse = hasDiffuseTex[matNum] ? texture(diffuseTexture[matNum], texCoord).rgb : diffuseColor[matNum];
specular.r = specPower[matNum];
specular.g = hasSpecTex[matNum] ? texture(specularTexture[matNum], texCoord).r : 1.0;
specular.g = hasSpecTex[matNum] ? texture(specularTexture[matNum], texCoord).r : 0.2;
specular.b = 1.0;
}
@@ -6,7 +6,7 @@ layout(location = 2) in vec3 normals;
layout(location = 3) in vec3 tangent;
layout(location = 4) in int matN;
uniform mat4 model;
uniform mat4 model[60];
uniform mat4 view;
uniform mat4 proj;
@@ -17,10 +17,10 @@ out mat3 tbn;
flat out int matNum;
void main() {
vec4 world = model * vec4(pos, 1.0);
vec4 world = model[gl_InstanceID] * vec4(pos, 1.0);
fragPos = world.xyz;
texCoord = texCoords;
mat3 normalMat = transpose(inverse(mat3(model)));
mat3 normalMat = transpose(inverse(mat3(model[gl_InstanceID])));
vec3 t = normalize(normalMat * tangent);
vec3 n = normalize(normalMat * normals);
normal = n;
@@ -3,10 +3,10 @@
layout(location = 0) in vec3 pos;
uniform mat4 lightSpace;
uniform mat4 model;
uniform mat4 model[60];
out vec3 texCoord;
void main() {
gl_Position = lightSpace * model * vec4(pos, 1.0);
gl_Position = lightSpace * model[gl_InstanceID] * vec4(pos, 1.0);
}
@@ -2,8 +2,8 @@
layout(location = 0) in vec3 pos;
uniform mat4 model;
uniform mat4 model[60];
void main() {
gl_Position = model * vec4(pos, 1.0);
gl_Position = model[gl_InstanceID] * vec4(pos, 1.0);
}