Browse Source

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

David Rose 19 years ago
parent
commit
e5903ff101

+ 1 - 1
panda/src/display/config_display.cxx

@@ -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 "

+ 2 - 1
panda/src/display/graphicsStateGuardian.I

@@ -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());
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////

+ 13 - 2
panda/src/display/graphicsStateGuardian.cxx

@@ -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,13 +1942,15 @@ 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;
-
+  
   if (_has_texture_alpha_scale) {
   if (_has_texture_alpha_scale) {
     PT(TextureStage) stage = get_alpha_scale_texture_stage();
     PT(TextureStage) stage = get_alpha_scale_texture_stage();
     PT(Texture) texture = TexturePool::get_alpha_scale_map();
     PT(Texture) texture = TexturePool::get_alpha_scale_map();
-
+    
     _effective_texture = DCAST(TextureAttrib, _effective_texture->add_on_stage(stage, texture));
     _effective_texture = DCAST(TextureAttrib, _effective_texture->add_on_stage(stage, texture));
     _effective_tex_gen = DCAST(TexGenAttrib, _effective_tex_gen->add_stage
     _effective_tex_gen = DCAST(TexGenAttrib, _effective_tex_gen->add_stage
                                (stage, TexGenAttrib::M_constant, TexCoord3f(_current_color_scale[3], 0.0f, 0.0f)));
                                (stage, TexGenAttrib::M_constant, TexCoord3f(_current_color_scale[3], 0.0f, 0.0f)));