fixed tangent space, added shader source displayed when compilation error occurs

This commit is contained in:
Anselme 2015-12-03 23:59:55 +01:00
parent 84662d2c9f
commit 87a2c2c906
3 changed files with 12 additions and 10 deletions

View File

@ -80,7 +80,7 @@ void main(void) {
#endif #endif
#ifdef AMBIENT_LIGHT #ifdef AMBIENT_LIGHT
outColor = vec4(ambient + lightColor*diffuse, 1); outColor = vec4(lightColor*ambient, 1);
#else #else
vec3 light = phongLighting(diffuse, specular, materialNs, lightColor, normal, lightDirInView, halfVecInView); vec3 light = phongLighting(diffuse, specular, materialNs, lightColor, normal, lightDirInView, halfVecInView);
outColor = vec4(light, 1); outColor = vec4(light, 1);

View File

@ -43,14 +43,15 @@ void main(void) {
#endif #endif
#ifdef POINT_LIGHT #ifdef POINT_LIGHT
lightDirInView = normalize(viewMatrix*pointLight - posInView); vec4 lightPosInView = viewMatrix*vec4(pointLight, 1);
halfVecInView = normalize(lightDirInView - posInView); lightDirInView = normalize(lightPosInView.xyz - posInView);
halfVecInView = normalize(lightDirInView - normalize(posInView));
#endif #endif
#ifdef NORMAL_MAP #ifdef NORMAL_MAP
tangentSpace = mat3(normalize(normalMatrix*inNormal), tangentSpace = transpose(mat3(normalize(normalMatrix*inTangent),
normalize(normalMatrix*inTangent), normalize(normalMatrix*inBinormal),
normalize(normalMatrix*inBinormal)); normalize(normalMatrix*inNormal)));
#else #else
varNormal = normalize(normalMatrix*inNormal); varNormal = normalize(normalMatrix*inNormal);
#endif #endif

View File

@ -104,6 +104,7 @@ GLuint Shader::createShader(const std::string &source, GLenum shaderType)
break; break;
} }
std::cerr << type_str << " shader not compiled : " << std::endl; std::cerr << type_str << " shader not compiled : " << std::endl;
std::cout << "Shader source :" << std::endl << source << std::endl;
printShaderInfoLog(shaderId); printShaderInfoLog(shaderId);
return 0; return 0;
} }