|
|
@@ -36,7 +36,8 @@ StandardMunger(GraphicsStateGuardianBase *gsg, const RenderState *state,
|
|
|
_munge_color(false),
|
|
|
_munge_color_scale(false),
|
|
|
_auto_shader(false),
|
|
|
- _shader_skinning(false)
|
|
|
+ _shader_skinning(false),
|
|
|
+ _remove_material(false)
|
|
|
{
|
|
|
const ShaderAttrib *shader_attrib;
|
|
|
state->get_attrib_def(shader_attrib);
|
|
|
@@ -94,6 +95,19 @@ StandardMunger(GraphicsStateGuardianBase *gsg, const RenderState *state,
|
|
|
// effort to detect this contrived situation and handle it correctly.
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // If we have no lights but do have a material, we will need to remove it so
|
|
|
+ // that it won't appear when we enable color scale via lighting.
|
|
|
+ const LightAttrib *light_attrib;
|
|
|
+ const MaterialAttrib *material_attrib;
|
|
|
+ if (get_gsg()->get_color_scale_via_lighting() &&
|
|
|
+ (!state->get_attrib(light_attrib) || !light_attrib->has_any_on_light()) &&
|
|
|
+ state->get_attrib(material_attrib) &&
|
|
|
+ material_attrib->get_material() != nullptr &&
|
|
|
+ shader_attrib->get_shader() == nullptr) {
|
|
|
+ _remove_material = true;
|
|
|
+ _should_munge_state = true;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -291,6 +305,9 @@ compare_to_impl(const GeomMunger *other) const {
|
|
|
if (_auto_shader != om->_auto_shader) {
|
|
|
return (int)_auto_shader - (int)om->_auto_shader;
|
|
|
}
|
|
|
+ if (_remove_material != om->_remove_material) {
|
|
|
+ return (int)_remove_material - (int)om->_remove_material;
|
|
|
+ }
|
|
|
|
|
|
return StateMunger::compare_to_impl(other);
|
|
|
}
|
|
|
@@ -344,5 +361,9 @@ munge_state_impl(const RenderState *state) {
|
|
|
munged_state = munged_state->remove_attrib(ColorScaleAttrib::get_class_slot());
|
|
|
}
|
|
|
|
|
|
+ if (_remove_material) {
|
|
|
+ munged_state = munged_state->remove_attrib(MaterialAttrib::get_class_slot());
|
|
|
+ }
|
|
|
+
|
|
|
return munged_state;
|
|
|
}
|