From a6b86ad24d783cb533b13bcabc703a9c6ad0f61a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Re=CC=81my=20Bouquet?= Date: Mon, 1 Jan 2018 14:12:00 +0100 Subject: [PATCH] Fixes Lightmap handling in PBR shader --- .../main/resources/Common/MatDefs/Light/PBRLighting.frag | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag b/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag index 118ebbe19..9771e4fa5 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag +++ b/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag @@ -195,6 +195,8 @@ void main(){ vec4 diffuseColor = albedo - albedo * Metallic; #endif + gl_FragColor.rgb = vec3(0.0); + #ifdef LIGHTMAP vec3 lightMapColor; #ifdef SEPARATE_TEXCOORD @@ -204,12 +206,14 @@ void main(){ #endif #ifdef AO_MAP lightMapColor.gb = lightMapColor.rr; + diffuseColor.rgb *= lightMapColor; + #else + gl_FragColor.rgb += diffuseColor.rgb * lightMapColor; #endif specularColor.rgb *= lightMapColor; - albedo.rgb *= lightMapColor; #endif - gl_FragColor.rgb = vec3(0.0); + float ndotv = max( dot( normal, viewDir ),0.0); for( int i = 0;i < NB_LIGHTS; i+=3){ vec4 lightColor = g_LightData[i];