Fixed lighting artifacts caused by untransformed normals, added 'Scene' for holding objects for rendering, added turn table models to menus using a scene, misc other changes.

This commit is contained in:
2020-03-23 11:48:32 -05:00
parent 18a62b81cc
commit 87fcc3a05c
14 changed files with 139 additions and 48 deletions

View File

@@ -4,7 +4,7 @@
in vec3 outPosition;
in vec3 outColor;
in vec4 outNormal;
in vec3 outNormal;
in vec3 outUV;
in float outTextureID;
in float outHasTexture;
@@ -12,7 +12,6 @@ in Light outLights[MAX_LIGHTS];
in float outTotalLights;
in vec3 outFragPos;
in vec3 outCameraPos;
in vec3 outInverseNormal;
in float outDisableLighting;
uniform sampler2D diffuse_texture;
@@ -55,7 +54,7 @@ vec3 calculateBasicLight(Light light) {
float specularStrength = 0.5;
vec3 viewDir = normalize(outCameraPos - outFragPos);
vec3 reflectDir = reflect(-lightDir, outInverseNormal);
vec3 reflectDir = reflect(-lightDir, outNormal);
float spec = pow(max(dot(viewDir, reflectDir), 0.0), 32);
vec3 specular = specularStrength * spec * light.specular;
@@ -77,7 +76,7 @@ vec3 calculateLighting() {
}
void main() {
lokiVar = vec4(outColor, 1.0) + outNormal + vec4(outUV, 1.0) + vec4(outTextureID, 1.0, 1.0, 1.0);
lokiVar = vec4(outColor, 1.0) + vec4(outNormal, 1.0) + vec4(outUV, 1.0) + vec4(outTextureID, 1.0, 1.0, 1.0);
lokiVar = normalize(lokiVar);
vec3 result;

View File

@@ -4,13 +4,13 @@
layout(location = 0) in vec3 inPosition;
layout(location = 1) in vec3 inColor;
layout(location = 2) in vec4 inNormal;
layout(location = 2) in vec3 inNormal;
layout(location = 3) in vec3 inUV;
layout(location = 4) in float inTextureID;
out vec3 outPosition;
out vec3 outColor;
out vec4 outNormal;
out vec3 outNormal;
out vec3 outUV;
out float outTextureID;
out float outHasTexture;
@@ -19,7 +19,6 @@ out float outTotalLights;
out vec3 outFragPos;
out vec3 outViewPos;
out vec3 outCameraPos;
out vec3 outInverseNormal;
out float outDisableLighting;
uniform mat4 projection;
@@ -36,7 +35,7 @@ void main() {
// projection * view * model * position
outPosition = inPosition;
outColor = inColor;
outNormal= inNormal;
outNormal= normalize(transpose(inverse(mat3(model))) * inNormal);
outUV = inUV;
outTextureID = inTextureID;
outHasTexture = hasTexture;
@@ -44,7 +43,6 @@ void main() {
outTotalLights = totalLights;
outCameraPos = cameraPos;
outDisableLighting = disableLighting;
outInverseNormal = mat3(transpose(inverse(model))) * vec3(inNormal);
outFragPos = vec3(model * vec4(inPosition, 1.0));