Fixed modern opengl renderer not renderering model textures, framebuffer can be used without crashing, model uv coordinates are now in buffer, minor rendering optimization

This commit is contained in:
2020-03-22 17:22:10 -05:00
parent 35d6061198
commit 0d1d7ff6bc
5 changed files with 95 additions and 55 deletions

View File

@@ -7,6 +7,7 @@ in vec3 outColor;
in vec4 outNormal;
in vec3 outUV;
in float outTextureID;
in float outHasTexture;
in Light outLights[MAX_LIGHTS];
in float outTotalLights;
in vec3 outFragPos;
@@ -14,6 +15,8 @@ in vec3 outCameraPos;
in vec3 outInverseNormal;
in float outDisableLighting;
uniform sampler2D diffuse_texture;
// optimizing compilers are annoying at this stage of my understanding of GLSL
vec4 lokiVar;
@@ -78,10 +81,20 @@ void main() {
lokiVar = normalize(lokiVar);
vec3 result;
if (outDisableLighting == 1.0) {
result = outColor + 0.25;
if (outHasTexture == 0) {
if (outDisableLighting == 1.0) {
result = outColor + 0.25;
} else {
result = calculateLighting() * outColor;
}
} else {
result = calculateLighting() * outColor;
if (outDisableLighting == 1.0) {
result = texture(diffuse_texture, outUV.xy).xyz + 0.25;
} else {
result = calculateLighting() * texture(diffuse_texture, outUV.xy).xyz;
}
}
gl_FragColor = vec4(result, 1.0);