Fixed a crash in the PBR shader when adding a light map.

This commit is contained in:
Nehon 2017-02-06 19:48:49 +01:00
parent 09ce6205c7
commit 0610f703d7

View File

@ -148,6 +148,16 @@ void main(){
vec3 normal = normalize(wNormal); vec3 normal = normalize(wNormal);
#endif #endif
float specular = 0.5;
#ifdef SPECGLOSSPIPELINE
vec4 specularColor = texture2D(m_SpecularMap, newTexCoord);
vec4 diffuseColor = albedo;
Roughness = 1.0 - texture2D(m_GlossMap, newTexCoord).r;
#else
float nonMetalSpec = 0.08 * specular;
vec4 specularColor = (nonMetalSpec - nonMetalSpec * Metallic) + albedo * Metallic;
vec4 diffuseColor = albedo - albedo * Metallic;
#endif
#ifdef LIGHTMAP #ifdef LIGHTMAP
vec3 lightMapColor; vec3 lightMapColor;
@ -160,17 +170,6 @@ void main(){
albedo.rgb *= lightMapColor; albedo.rgb *= lightMapColor;
#endif #endif
float specular = 0.5;
#ifdef SPECGLOSSPIPELINE
vec4 specularColor = texture2D(m_SpecularMap, newTexCoord);
vec4 diffuseColor = albedo;
Roughness = 1.0 - texture2D(m_GlossMap, newTexCoord).r;
#else
float nonMetalSpec = 0.08 * specular;
vec4 specularColor = (nonMetalSpec - nonMetalSpec * Metallic) + albedo * Metallic;
vec4 diffuseColor = albedo - albedo * Metallic;
#endif
gl_FragColor.rgb = vec3(0.0); gl_FragColor.rgb = vec3(0.0);
float ndotv = max( dot( normal, viewDir ),0.0); float ndotv = max( dot( normal, viewDir ),0.0);
for( int i = 0;i < NB_LIGHTS; i+=3){ for( int i = 0;i < NB_LIGHTS; i+=3){