Browse Source

fix texture limit on shader case

David Rose 16 years ago
parent
commit
f6971cc724
1 changed files with 8 additions and 3 deletions
  1. 8 3
      panda/src/dxgsg9/dxShaderContext9.cxx

+ 8 - 3
panda/src/dxgsg9/dxShaderContext9.cxx

@@ -740,11 +740,16 @@ update_shader_texture_bindings(CLP(ShaderContext) *prev, GSG *gsg)
         const ShaderInput *input = gsg->_target_shader->get_shader_input(id);
         tex = input->get_texture();
       } else {
-        if (_shader->_tex_spec[i]._stage >= gsg->_target_texture->get_num_on_stages()) {
+        // We get the TextureAttrib directly from the _target_rs, not the
+        // filtered TextureAttrib in _target_texture.
+        const TextureAttrib *texattrib = DCAST(TextureAttrib, gsg->_target_rs->get_attrib_def(TextureAttrib::get_class_slot()));
+        nassertv(texattrib != (TextureAttrib *)NULL);
+
+        if (_shader->_tex_spec[i]._stage >= texattrib->get_num_on_stages()) {
           continue;
         }
-        TextureStage *stage = gsg->_target_texture->get_on_stage(_shader->_tex_spec[i]._stage);
-        tex = gsg->_target_texture->get_on_texture(stage);
+        TextureStage *stage = texattrib->get_on_stage(_shader->_tex_spec[i]._stage);
+        tex = texattrib->get_on_texture(stage);
       }
       if (_shader->_tex_spec[i]._suffix != 0) {
         // The suffix feature is inefficient. It is a temporary hack.