Fix obnoxious normals bug in shader
This commit is contained in:
parent
28a9b5e03e
commit
41640ba543
@ -89,6 +89,7 @@ void main(){
|
|||||||
//}
|
//}
|
||||||
//result += CalcSpotLight(spotLight, norm, FragPos, viewDir);
|
//result += CalcSpotLight(spotLight, norm, FragPos, viewDir);
|
||||||
|
|
||||||
|
//this final calculation is for transparency
|
||||||
FragColor = vec4(result, texture(material.diffuse, TexCoord).a);//texture(ourTexture, TexCoord);//vec4(result, 1.0);
|
FragColor = vec4(result, texture(material.diffuse, TexCoord).a);//texture(ourTexture, TexCoord);//vec4(result, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,8 +99,8 @@ vec3 CalcDirLight(DirLight light, vec3 normal, vec3 viewDir){
|
|||||||
// diffuse shading
|
// diffuse shading
|
||||||
float diff = max(dot(normal, lightDir), 0.0);
|
float diff = max(dot(normal, lightDir), 0.0);
|
||||||
// specular shading
|
// specular shading
|
||||||
vec3 reflectDir = reflect(-lightDir, normal);
|
// vec3 reflectDir = reflect(-lightDir, normal);
|
||||||
float spec = pow(max(dot(viewDir, reflectDir), 0.0), material.shininess);
|
// float spec = pow(max(dot(viewDir, reflectDir), 0.0), material.shininess);
|
||||||
// combine results
|
// combine results
|
||||||
vec3 texColor = texture(material.diffuse, TexCoord).rgb;
|
vec3 texColor = texture(material.diffuse, TexCoord).rgb;
|
||||||
vec3 ambient = light.ambient;
|
vec3 ambient = light.ambient;
|
||||||
|
|||||||
@ -59,7 +59,7 @@ void main() {
|
|||||||
|
|
||||||
//push frag, normal, and texture positions to fragment shader
|
//push frag, normal, and texture positions to fragment shader
|
||||||
FragPos = vec3(model * FinalVertex);
|
FragPos = vec3(model * FinalVertex);
|
||||||
Normal = mat3(transpose(inverse(model))) * aNormal;
|
Normal = mat3(transpose(inverse(model))) * FinalNormal.xyz;
|
||||||
TexCoord = aTex;
|
TexCoord = aTex;
|
||||||
|
|
||||||
//shadow map stuff
|
//shadow map stuff
|
||||||
|
|||||||
@ -285,10 +285,11 @@ public class Main {
|
|||||||
//
|
//
|
||||||
// P L A Y E R W O R L D P O S I T I O N U P D A T E
|
// P L A Y E R W O R L D P O S I T I O N U P D A T E
|
||||||
//
|
//
|
||||||
// if(Globals.playerCharacter != null && Globals.commonWorldData != null){
|
// if(Globals.playerCharacter != null && Globals.commonWorldData != null){
|
||||||
// newPlayerCharacterPosition = EntityUtils.getPosition(Globals.playerCharacter);
|
// EntityUtils.getRotation(Globals.playerCharacter).rotateX(0.01f);
|
||||||
// Globals.clientPlayerData.setWorldPosition(Globals.commonWorldData.convertRealToWorld(newPlayerCharacterPosition.x), Globals.commonWorldData.convertRealToWorld(newPlayerCharacterPosition.z));
|
// newPlayerCharacterPosition = EntityUtils.getPosition(Globals.playerCharacter);
|
||||||
// }
|
// Globals.clientPlayerData.setWorldPosition(Globals.commonWorldData.convertRealToWorld(newPlayerCharacterPosition.x), Globals.commonWorldData.convertRealToWorld(newPlayerCharacterPosition.z));
|
||||||
|
// }
|
||||||
|
|
||||||
///
|
///
|
||||||
/// C L I E N T C E L L M A N A G E R
|
/// C L I E N T C E L L M A N A G E R
|
||||||
|
|||||||
@ -731,20 +731,23 @@ public class Mesh {
|
|||||||
//Until we switch to uniform buffer objects we will have to buffer lighting data here manually each time we draw
|
//Until we switch to uniform buffer objects we will have to buffer lighting data here manually each time we draw
|
||||||
//side note: :(
|
//side note: :(
|
||||||
if(light_buffer == null){
|
if(light_buffer == null){
|
||||||
|
|
||||||
|
//this needs to get transformed by the view matrix and isn't
|
||||||
|
Vector3f lightLoc = new Vector3f(0.2f,-1.0f,0.3f);
|
||||||
float temp[] = new float[3];
|
float temp[] = new float[3];
|
||||||
temp[0] = 0.2f;
|
temp[0] = lightLoc.x;
|
||||||
temp[1] = -1.0f;
|
temp[1] = lightLoc.y;
|
||||||
temp[2] = 0.3f;
|
temp[2] = lightLoc.z;
|
||||||
glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "dirLight.direction"), temp);
|
glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "dirLight.direction"), temp);
|
||||||
|
|
||||||
temp[0] = 0.1f;
|
temp[0] = 0.3f;
|
||||||
temp[1] = 0.1f;
|
temp[1] = 0.3f;
|
||||||
temp[2] = 0.1f;
|
temp[2] = 0.3f;
|
||||||
glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "dirLight.ambient"), temp);
|
glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "dirLight.ambient"), temp);
|
||||||
|
|
||||||
temp[0] = 0.8f;
|
temp[0] = 0.5f;
|
||||||
temp[1] = 0.8f;
|
temp[1] = 0.5f;
|
||||||
temp[2] = 0.8f;
|
temp[2] = 0.5f;
|
||||||
glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "dirLight.diffuse"), temp);
|
glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "dirLight.diffuse"), temp);
|
||||||
|
|
||||||
temp[0] = 0.1f;
|
temp[0] = 0.1f;
|
||||||
@ -757,11 +760,13 @@ public class Mesh {
|
|||||||
|
|
||||||
GL20.glUniformMatrix4fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "model"), false, parent.modelMatrix.get(new float[16]));
|
GL20.glUniformMatrix4fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "model"), false, parent.modelMatrix.get(new float[16]));
|
||||||
|
|
||||||
Vector3f cam_Loc = CameraEntityUtils.getCameraEye(Globals.playerCamera);//Globals.cameraVisible.pos_Center;
|
//set in standard uniforms
|
||||||
temp[0] = cam_Loc.x;
|
//
|
||||||
temp[1] = cam_Loc.y;
|
// Vector3f cam_Loc = CameraEntityUtils.getCameraEye(Globals.playerCamera);//Globals.cameraVisible.pos_Center;
|
||||||
temp[2] = cam_Loc.z;
|
// temp[0] = cam_Loc.x;
|
||||||
glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "viewPos"), temp);
|
// temp[1] = cam_Loc.y;
|
||||||
|
// temp[2] = cam_Loc.z;
|
||||||
|
// glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "viewPos"), temp);
|
||||||
} else {
|
} else {
|
||||||
GL20.glUniformMatrix4fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "model"), false, parent.modelMatrix.get(new float[16]));
|
GL20.glUniformMatrix4fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "model"), false, parent.modelMatrix.get(new float[16]));
|
||||||
}
|
}
|
||||||
@ -776,7 +781,7 @@ public class Mesh {
|
|||||||
if(material.hasTransparency){
|
if(material.hasTransparency){
|
||||||
GL20.glUniform1i(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "hasTransparency"), 1);
|
GL20.glUniform1i(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "hasTransparency"), 1);
|
||||||
} else {
|
} else {
|
||||||
GL20.glUniform1i(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "hasTransparency"), 1);
|
GL20.glUniform1i(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "hasTransparency"), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -873,37 +878,37 @@ public class Mesh {
|
|||||||
// glUniformMatrix4fv(glGetUniformLocation(Globals.depthMapShaderProgramLoc, "lightSpaceMatrix"), false, Globals.lightDepthMatrix.get(new float[16]));
|
// glUniformMatrix4fv(glGetUniformLocation(Globals.depthMapShaderProgramLoc, "lightSpaceMatrix"), false, Globals.lightDepthMatrix.get(new float[16]));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if(useLight){
|
// if(useLight){
|
||||||
//
|
// //
|
||||||
//
|
// //
|
||||||
//Testing Lights
|
// //Testing Lights
|
||||||
//
|
// //
|
||||||
//
|
// //
|
||||||
float test_Light_Data[] = new float[3];
|
// float test_Light_Data[] = new float[3];
|
||||||
test_Light_Data[0] = 0.2f;
|
// test_Light_Data[0] = 0.2f;
|
||||||
test_Light_Data[1] = -1.0f;
|
// test_Light_Data[1] = -1.0f;
|
||||||
test_Light_Data[2] = 0.3f;
|
// test_Light_Data[2] = 0.3f;
|
||||||
glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "dirLight.direction"), test_Light_Data);
|
// glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "dirLight.direction"), test_Light_Data);
|
||||||
|
|
||||||
test_Light_Data = new float[3];
|
// test_Light_Data = new float[3];
|
||||||
test_Light_Data[0] = 0.3f;
|
// test_Light_Data[0] = 0.3f;
|
||||||
test_Light_Data[1] = 0.3f;
|
// test_Light_Data[1] = 0.3f;
|
||||||
test_Light_Data[2] = 0.3f;
|
// test_Light_Data[2] = 0.3f;
|
||||||
glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "dirLight.ambient"), test_Light_Data);
|
// glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "dirLight.ambient"), test_Light_Data);
|
||||||
|
|
||||||
test_Light_Data = new float[3];
|
// test_Light_Data = new float[3];
|
||||||
test_Light_Data[0] = 0.5f;
|
// test_Light_Data[0] = 0.5f;
|
||||||
test_Light_Data[1] = 0.5f;
|
// test_Light_Data[1] = 0.5f;
|
||||||
test_Light_Data[2] = 0.5f;
|
// test_Light_Data[2] = 0.5f;
|
||||||
glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "dirLight.diffuse"), test_Light_Data);
|
// glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "dirLight.diffuse"), test_Light_Data);
|
||||||
|
|
||||||
Vector3f cam_Loc = CameraEntityUtils.getCameraEye(Globals.playerCamera);
|
// Vector3f cam_Loc = CameraEntityUtils.getCameraEye(Globals.playerCamera);
|
||||||
test_Light_Data = new float[3];
|
// test_Light_Data = new float[3];
|
||||||
test_Light_Data[0] = cam_Loc.x;
|
// test_Light_Data[0] = cam_Loc.x;
|
||||||
test_Light_Data[1] = cam_Loc.y;
|
// test_Light_Data[1] = cam_Loc.y;
|
||||||
test_Light_Data[2] = cam_Loc.z;
|
// test_Light_Data[2] = cam_Loc.z;
|
||||||
glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "viewPos"), test_Light_Data);
|
// glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "viewPos"), test_Light_Data);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user