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);
|
||||
|
||||
//this final calculation is for transparency
|
||||
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
|
||||
float diff = max(dot(normal, lightDir), 0.0);
|
||||
// specular shading
|
||||
vec3 reflectDir = reflect(-lightDir, normal);
|
||||
float spec = pow(max(dot(viewDir, reflectDir), 0.0), material.shininess);
|
||||
// vec3 reflectDir = reflect(-lightDir, normal);
|
||||
// float spec = pow(max(dot(viewDir, reflectDir), 0.0), material.shininess);
|
||||
// combine results
|
||||
vec3 texColor = texture(material.diffuse, TexCoord).rgb;
|
||||
vec3 ambient = light.ambient;
|
||||
|
||||
@ -59,7 +59,7 @@ void main() {
|
||||
|
||||
//push frag, normal, and texture positions to fragment shader
|
||||
FragPos = vec3(model * FinalVertex);
|
||||
Normal = mat3(transpose(inverse(model))) * aNormal;
|
||||
Normal = mat3(transpose(inverse(model))) * FinalNormal.xyz;
|
||||
TexCoord = aTex;
|
||||
|
||||
//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
|
||||
//
|
||||
// if(Globals.playerCharacter != null && Globals.commonWorldData != null){
|
||||
// newPlayerCharacterPosition = EntityUtils.getPosition(Globals.playerCharacter);
|
||||
// Globals.clientPlayerData.setWorldPosition(Globals.commonWorldData.convertRealToWorld(newPlayerCharacterPosition.x), Globals.commonWorldData.convertRealToWorld(newPlayerCharacterPosition.z));
|
||||
// }
|
||||
// if(Globals.playerCharacter != null && Globals.commonWorldData != null){
|
||||
// EntityUtils.getRotation(Globals.playerCharacter).rotateX(0.01f);
|
||||
// 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
|
||||
|
||||
@ -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
|
||||
//side note: :(
|
||||
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];
|
||||
temp[0] = 0.2f;
|
||||
temp[1] = -1.0f;
|
||||
temp[2] = 0.3f;
|
||||
temp[0] = lightLoc.x;
|
||||
temp[1] = lightLoc.y;
|
||||
temp[2] = lightLoc.z;
|
||||
glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "dirLight.direction"), temp);
|
||||
|
||||
temp[0] = 0.1f;
|
||||
temp[1] = 0.1f;
|
||||
temp[2] = 0.1f;
|
||||
temp[0] = 0.3f;
|
||||
temp[1] = 0.3f;
|
||||
temp[2] = 0.3f;
|
||||
glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "dirLight.ambient"), temp);
|
||||
|
||||
temp[0] = 0.8f;
|
||||
temp[1] = 0.8f;
|
||||
temp[2] = 0.8f;
|
||||
temp[0] = 0.5f;
|
||||
temp[1] = 0.5f;
|
||||
temp[2] = 0.5f;
|
||||
glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "dirLight.diffuse"), temp);
|
||||
|
||||
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]));
|
||||
|
||||
Vector3f cam_Loc = CameraEntityUtils.getCameraEye(Globals.playerCamera);//Globals.cameraVisible.pos_Center;
|
||||
temp[0] = cam_Loc.x;
|
||||
temp[1] = cam_Loc.y;
|
||||
temp[2] = cam_Loc.z;
|
||||
glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "viewPos"), temp);
|
||||
//set in standard uniforms
|
||||
//
|
||||
// Vector3f cam_Loc = CameraEntityUtils.getCameraEye(Globals.playerCamera);//Globals.cameraVisible.pos_Center;
|
||||
// temp[0] = cam_Loc.x;
|
||||
// temp[1] = cam_Loc.y;
|
||||
// temp[2] = cam_Loc.z;
|
||||
// glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "viewPos"), temp);
|
||||
} else {
|
||||
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){
|
||||
GL20.glUniform1i(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "hasTransparency"), 1);
|
||||
} 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]));
|
||||
// }
|
||||
|
||||
if(useLight){
|
||||
//
|
||||
//
|
||||
//Testing Lights
|
||||
//
|
||||
//
|
||||
float test_Light_Data[] = new float[3];
|
||||
test_Light_Data[0] = 0.2f;
|
||||
test_Light_Data[1] = -1.0f;
|
||||
test_Light_Data[2] = 0.3f;
|
||||
glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "dirLight.direction"), test_Light_Data);
|
||||
// if(useLight){
|
||||
// //
|
||||
// //
|
||||
// //Testing Lights
|
||||
// //
|
||||
// //
|
||||
// float test_Light_Data[] = new float[3];
|
||||
// test_Light_Data[0] = 0.2f;
|
||||
// test_Light_Data[1] = -1.0f;
|
||||
// test_Light_Data[2] = 0.3f;
|
||||
// glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "dirLight.direction"), test_Light_Data);
|
||||
|
||||
test_Light_Data = new float[3];
|
||||
test_Light_Data[0] = 0.3f;
|
||||
test_Light_Data[1] = 0.3f;
|
||||
test_Light_Data[2] = 0.3f;
|
||||
glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "dirLight.ambient"), test_Light_Data);
|
||||
// test_Light_Data = new float[3];
|
||||
// test_Light_Data[0] = 0.3f;
|
||||
// test_Light_Data[1] = 0.3f;
|
||||
// test_Light_Data[2] = 0.3f;
|
||||
// glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "dirLight.ambient"), test_Light_Data);
|
||||
|
||||
test_Light_Data = new float[3];
|
||||
test_Light_Data[0] = 0.5f;
|
||||
test_Light_Data[1] = 0.5f;
|
||||
test_Light_Data[2] = 0.5f;
|
||||
glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "dirLight.diffuse"), test_Light_Data);
|
||||
// test_Light_Data = new float[3];
|
||||
// test_Light_Data[0] = 0.5f;
|
||||
// test_Light_Data[1] = 0.5f;
|
||||
// test_Light_Data[2] = 0.5f;
|
||||
// glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "dirLight.diffuse"), test_Light_Data);
|
||||
|
||||
Vector3f cam_Loc = CameraEntityUtils.getCameraEye(Globals.playerCamera);
|
||||
test_Light_Data = new float[3];
|
||||
test_Light_Data[0] = cam_Loc.x;
|
||||
test_Light_Data[1] = cam_Loc.y;
|
||||
test_Light_Data[2] = cam_Loc.z;
|
||||
glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "viewPos"), test_Light_Data);
|
||||
}
|
||||
// Vector3f cam_Loc = CameraEntityUtils.getCameraEye(Globals.playerCamera);
|
||||
// test_Light_Data = new float[3];
|
||||
// test_Light_Data[0] = cam_Loc.x;
|
||||
// test_Light_Data[1] = cam_Loc.y;
|
||||
// test_Light_Data[2] = cam_Loc.z;
|
||||
// glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "viewPos"), test_Light_Data);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user