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."));
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 "
"ColorScaleAttribs that affect alpha by "
"creating an additional Texture layer over the geometry "

View File

@ -599,7 +599,8 @@ get_alpha_scale_via_texture() const {
INLINE bool GraphicsStateGuardian::
get_alpha_scale_via_texture(const TextureAttrib *tex_attrib) const {
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::
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;
_color_scale_enabled = attrib->has_scale();
_current_color_scale = attrib->get_scale();
@ -1588,8 +1594,11 @@ do_issue_color_scale() {
determine_light_color_scale();
}
if (_alpha_scale_via_texture && !_has_scene_graph_color &&
attrib->has_alpha_scale()) {
// This color scale will set a special texture--so again, clear
// the texture.
_state._texture = 0;
_state._tex_matrix = 0;
@ -1933,13 +1942,15 @@ end_bind_clip_planes() {
////////////////////////////////////////////////////////////////////
void GraphicsStateGuardian::
determine_effective_texture() {
nassertv(_target._texture != (TextureAttrib *)NULL &&
_target._tex_gen != (TexGenAttrib *)NULL);
_effective_texture = _target._texture->filter_to_max(_max_texture_stages);
_effective_tex_gen = _target._tex_gen;
if (_has_texture_alpha_scale) {
PT(TextureStage) stage = get_alpha_scale_texture_stage();
PT(Texture) texture = TexturePool::get_alpha_scale_map();
_effective_texture = DCAST(TextureAttrib, _effective_texture->add_on_stage(stage, texture));
_effective_tex_gen = DCAST(TexGenAttrib, _effective_tex_gen->add_stage
(stage, TexGenAttrib::M_constant, TexCoord3f(_current_color_scale[3], 0.0f, 0.0f)));