diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index aa6cd82b58..297d4ebd0d 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -339,6 +339,7 @@ reset() { _color_write_mask = ColorWriteAttrib::C_all; _has_scene_graph_color = false; + _scene_graph_color.set(1.0f, 1.0f, 1.0f, 1.0f); _transform_stale = true; _color_blend_involves_color_scale = false; _texture_involves_color_scale = false; @@ -1560,6 +1561,7 @@ do_issue_color() { case ColorAttrib::T_off: // Color attribute off: it specifies that no scene graph color is // in effect, and vertex color is not important either. + _scene_graph_color.set(1.0f, 1.0f, 1.0f, 1.0f); _has_scene_graph_color = false; _vertex_colors_enabled = false; break; @@ -1567,6 +1569,7 @@ do_issue_color() { case ColorAttrib::T_vertex: // Color attribute vertex: it specifies that vertex color should // be revealed. + _scene_graph_color.set(1.0f, 1.0f, 1.0f, 1.0f); _has_scene_graph_color = false; _vertex_colors_enabled = true; break; diff --git a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx index 15afda4900..2b075eb92a 100644 --- a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx +++ b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx @@ -961,19 +961,12 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, } if (!needs_color) { - if (_has_scene_graph_color) { - const Colorf &d = _scene_graph_color; - _c->current_color.X = d[0]; - _c->current_color.Y = d[1]; - _c->current_color.Z = d[2]; - _c->current_color.W = d[3]; - - } else { - _c->current_color.X = 1.0f; - _c->current_color.Y = 1.0f; - _c->current_color.Z = 1.0f; - _c->current_color.W = 1.0f; - } + const Colorf &d = _scene_graph_color; + const Colorf &s = _current_color_scale; + _c->current_color.X = d[0] * s[0]; + _c->current_color.Y = d[1] * s[1]; + _c->current_color.Z = d[2] * s[2]; + _c->current_color.W = d[3] * s[3]; } bool needs_normal = false; @@ -1021,10 +1014,11 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader, if (needs_color) { const Colorf &d = rcolor.get_data4f(); - _c->current_color.X = d[0]; - _c->current_color.Y = d[1]; - _c->current_color.Z = d[2]; - _c->current_color.W = d[3]; + const Colorf &s = _current_color_scale; + _c->current_color.X = d[0] * s[0]; + _c->current_color.Y = d[1] * s[1]; + _c->current_color.Z = d[2] * s[2]; + _c->current_color.W = d[3] * s[3]; if (_color_material_flags) { if (_color_material_flags & CMF_ambient) {