diff --git a/engine/src/core-data/Common/MatDefs/Light/Lighting.frag b/engine/src/core-data/Common/MatDefs/Light/Lighting.frag index 8d5c785e0..8b8cc827e 100644 --- a/engine/src/core-data/Common/MatDefs/Light/Lighting.frag +++ b/engine/src/core-data/Common/MatDefs/Light/Lighting.frag @@ -188,20 +188,22 @@ void main(){ specularColor.rgb *= texture2D(m_ColorRamp, vec2(light.y, 0.0)).rgb; #endif + // Workaround, since it is not possible to modify varying variables + vec4 SpecularSum2 = SpecularSum; #ifdef USE_REFLECTION vec4 refColor = Optics_GetEnvColor(m_EnvMap, refVec.xyz); // Interpolate light specularity toward reflection color // Multiply result by specular map - specularColor = mix(SpecularSum * light.y, refColor, refVec.w) * specularColor; + specularColor = mix(SpecularSum2 * light.y, refColor, refVec.w) * specularColor; - SpecularSum = vec4(1.0); + SpecularSum2 = vec4(1.0); light.y = 1.0; #endif gl_FragColor = AmbientSum * diffuseColor + DiffuseSum * diffuseColor * light.x + - SpecularSum * specularColor * light.y; + SpecularSum2 * specularColor * light.y; #endif gl_FragColor.a = alpha; } diff --git a/engine/src/core-plugins/com/jme3/scene/plugins/OBJLoader.java b/engine/src/core-plugins/com/jme3/scene/plugins/OBJLoader.java index 99202d4b3..58a13f819 100644 --- a/engine/src/core-plugins/com/jme3/scene/plugins/OBJLoader.java +++ b/engine/src/core-plugins/com/jme3/scene/plugins/OBJLoader.java @@ -332,6 +332,9 @@ public final class OBJLoader implements AssetLoader { }else if (cmd.equals("usemtl")){ // use material from MTL lib for the following faces currentMatName = scan.next(); + if (!matList.containsKey(currentMatName)) + throw new IOException("Cannot locate material " + currentMatName + " in MTL file!"); + }else if (cmd.equals("mtllib")){ // specify MTL lib to use for this OBJ file String mtllib = scan.nextLine().trim();