MPO: clear param for null textures

experimental^2^2
Kirill Vainer 9 years ago
parent 06b817e116
commit 5588e859cb
  1. 32
      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<MatParamOverride> overrides) { private void updateShaderMaterialParameters(Renderer renderer, Shader shader, List<MatParamOverride> overrides) {
int unit = 0; int unit = 0;
for (MatParamOverride override : overrides) { if (overrides != null) {
VarType type = override.getVarType(); for (MatParamOverride override : overrides) {
VarType type = override.getVarType();
MatParam paramDef = def.getMaterialParam(override.getName()); MatParam paramDef = def.getMaterialParam(override.getName());
if (paramDef == null || paramDef.getVarType() != type || !override.isEnabled()) { if (paramDef == null || paramDef.getVarType() != type || !override.isEnabled()) {
continue; continue;
} }
Uniform uniform = shader.getUniform(override.getPrefixedName()); Uniform uniform = shader.getUniform(override.getPrefixedName());
if (type.isTextureType()) { if (override.getValue() != null) {
renderer.setTexture(unit, (Texture) override.getValue()); if (type.isTextureType()) {
uniform.setValue(VarType.Int, unit); renderer.setTexture(unit, (Texture) override.getValue());
unit++; uniform.setValue(VarType.Int, unit);
} else { unit++;
uniform.setValue(type, override.getValue()); } else {
uniform.setValue(type, override.getValue());
}
} else {
uniform.clearValue();
}
} }
} }

Loading…
Cancel
Save