diff --git a/jme3-core/src/main/java/com/jme3/material/Material.java b/jme3-core/src/main/java/com/jme3/material/Material.java index 4be24fd29..180cdc544 100644 --- a/jme3-core/src/main/java/com/jme3/material/Material.java +++ b/jme3-core/src/main/java/com/jme3/material/Material.java @@ -788,21 +788,27 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable { private void updateShaderMaterialParameters(Renderer renderer, Shader shader, List overrides) { int unit = 0; - for (MatParamOverride override : overrides) { - VarType type = override.getVarType(); + if (overrides != null) { + for (MatParamOverride override : overrides) { + VarType type = override.getVarType(); - MatParam paramDef = def.getMaterialParam(override.getName()); - if (paramDef == null || paramDef.getVarType() != type || !override.isEnabled()) { - continue; - } + MatParam paramDef = def.getMaterialParam(override.getName()); + if (paramDef == null || paramDef.getVarType() != type || !override.isEnabled()) { + continue; + } - Uniform uniform = shader.getUniform(override.getPrefixedName()); - if (type.isTextureType()) { - renderer.setTexture(unit, (Texture) override.getValue()); - uniform.setValue(VarType.Int, unit); - unit++; - } else { - uniform.setValue(type, override.getValue()); + Uniform uniform = shader.getUniform(override.getPrefixedName()); + if (override.getValue() != null) { + if (type.isTextureType()) { + renderer.setTexture(unit, (Texture) override.getValue()); + uniform.setValue(VarType.Int, unit); + unit++; + } else { + uniform.setValue(type, override.getValue()); + } + } else { + uniform.clearValue(); + } } }