|
|
@ -162,6 +162,9 @@ void main(){ |
|
|
|
|
|
|
|
|
|
|
|
#ifdef NORMALMAP |
|
|
|
#ifdef NORMALMAP |
|
|
|
mat3 tbnMat = mat3(normalize(vTangent.xyz) , normalize(vBinormal.xyz) , normalize(vNormal.xyz)); |
|
|
|
mat3 tbnMat = mat3(normalize(vTangent.xyz) , normalize(vBinormal.xyz) , normalize(vNormal.xyz)); |
|
|
|
|
|
|
|
vec3 viewDir = normalize(-vPos.xyz * tbnMat); |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
vec3 viewDir = normalize(-vPos.xyz); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
for( int i = 0;i < NB_LIGHTS; i+=3){ |
|
|
|
for( int i = 0;i < NB_LIGHTS; i+=3){ |
|
|
@ -184,11 +187,9 @@ void main(){ |
|
|
|
#ifdef NORMALMAP |
|
|
|
#ifdef NORMALMAP |
|
|
|
//Normal map -> lighting is computed in tangent space |
|
|
|
//Normal map -> lighting is computed in tangent space |
|
|
|
lightDir.xyz = normalize(lightDir.xyz * tbnMat); |
|
|
|
lightDir.xyz = normalize(lightDir.xyz * tbnMat); |
|
|
|
vec3 viewDir = normalize(-vPos.xyz * tbnMat); |
|
|
|
|
|
|
|
#else |
|
|
|
#else |
|
|
|
//no Normal map -> lighting is computed in view space |
|
|
|
//no Normal map -> lighting is computed in view space |
|
|
|
lightDir.xyz = normalize(lightDir.xyz); |
|
|
|
lightDir.xyz = normalize(lightDir.xyz); |
|
|
|
vec3 viewDir = normalize(-vPos.xyz); |
|
|
|
|
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
vec2 light = computeLighting(normal, viewDir, lightDir.xyz, lightDir.w * spotFallOff , m_Shininess); |
|
|
|
vec2 light = computeLighting(normal, viewDir, lightDir.xyz, lightDir.w * spotFallOff , m_Shininess); |
|
|
|