ok, now alpha-scale-via-texture is ready for prime time

This commit is contained in:
David Rose 2006-10-11 20:58:42 +00:00
parent 19eebe69c1
commit e5903ff101
3 changed files with 16 additions and 4 deletions

View File

@ -204,7 +204,7 @@ ConfigVariableBool color_scale_via_lighting
"it. See also alpha-scale-via-texture.")); "it. See also alpha-scale-via-texture."));
ConfigVariableBool alpha_scale_via_texture ConfigVariableBool alpha_scale_via_texture
("alpha-scale-via-texture", false, ("alpha-scale-via-texture", true,
PRC_DESC("When this is true, Panda will try to implement " PRC_DESC("When this is true, Panda will try to implement "
"ColorScaleAttribs that affect alpha by " "ColorScaleAttribs that affect alpha by "
"creating an additional Texture layer over the geometry " "creating an additional Texture layer over the geometry "

View File

@ -599,7 +599,8 @@ get_alpha_scale_via_texture() const {
INLINE bool GraphicsStateGuardian:: INLINE bool GraphicsStateGuardian::
get_alpha_scale_via_texture(const TextureAttrib *tex_attrib) const { get_alpha_scale_via_texture(const TextureAttrib *tex_attrib) const {
return _alpha_scale_via_texture && return _alpha_scale_via_texture &&
(tex_attrib->get_num_on_stages() < get_max_texture_stages()); (tex_attrib == (const TextureAttrib *)NULL ||
tex_attrib->get_num_on_stages() < get_max_texture_stages());
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////

View File

@ -1568,6 +1568,12 @@ do_issue_color() {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void GraphicsStateGuardian:: void GraphicsStateGuardian::
do_issue_color_scale() { do_issue_color_scale() {
// If the previous color scale had set a special texture, clear the
// texture now.
if (_has_texture_alpha_scale) {
_state._texture = 0;
}
const ColorScaleAttrib *attrib = _target._color_scale; const ColorScaleAttrib *attrib = _target._color_scale;
_color_scale_enabled = attrib->has_scale(); _color_scale_enabled = attrib->has_scale();
_current_color_scale = attrib->get_scale(); _current_color_scale = attrib->get_scale();
@ -1588,8 +1594,11 @@ do_issue_color_scale() {
determine_light_color_scale(); determine_light_color_scale();
} }
if (_alpha_scale_via_texture && !_has_scene_graph_color && if (_alpha_scale_via_texture && !_has_scene_graph_color &&
attrib->has_alpha_scale()) { attrib->has_alpha_scale()) {
// This color scale will set a special texture--so again, clear
// the texture.
_state._texture = 0; _state._texture = 0;
_state._tex_matrix = 0; _state._tex_matrix = 0;
@ -1933,6 +1942,8 @@ end_bind_clip_planes() {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void GraphicsStateGuardian:: void GraphicsStateGuardian::
determine_effective_texture() { determine_effective_texture() {
nassertv(_target._texture != (TextureAttrib *)NULL &&
_target._tex_gen != (TexGenAttrib *)NULL);
_effective_texture = _target._texture->filter_to_max(_max_texture_stages); _effective_texture = _target._texture->filter_to_max(_max_texture_stages);
_effective_tex_gen = _target._tex_gen; _effective_tex_gen = _target._tex_gen;