Problem when using setShader + setTexture, latest CVS source

This worked using 1.7.0, but now it has issues.

I’ll try to explain clearly:

  • I load a model and apply a shader to it.
  • I apply a different shader to one part of that model.
  • I use setTexture(texture, 1) to apply a texture to the part of the model.
  • Some time later, I use setTexture(another_texture) to replace the first texture.
  • Now the part of the model does not display properly, and the UV coordinates are being given to the shader as 0, 0 (tested by using a shader which outputs UVs as the output color).

Now here are two things that “fix” it:

  • If I call clearTexture() just prior to calling setTexture the second time, it does not have this problem. Took me a whole day to figure that one out.
  • If I do not call setShader on the part of the model, thereby having it use the shader applied to the model as a whole, it does not have this problem.

So it looks like some wires are getting crossed in the case where a shader is applied to a node and also to some other node below it.
This seems like it may be related to the new shader features?
Oh and by “latest CVS source” I mean yesterday.

What happens if you use setTexture(another_texture, 1) to change the texture?

One thing that changed between 1.7.0 and the cvs trunk is the way in which texture overrides (the ,1 in the setTexture call) are applied. Formerly, they were applied to the overall TextureAttrib. Now, they are applied per each TextureStage. It has subtle implications on the way the overrides apply between different setTexture() operations on the same node.


Oops, I was using “, 1” on all setTexture calls, just forgot to put that in the message.