p3d_TextureMatrix Without a Texture...?

In short, if a model has no texture applied, is the texture-matrix supplied to shaders that expect it?

To explain:

I have a shader that takes two textures as inputs–but not via the built-in texture-system (e.g. as a result of calls to “setTexture” or inclusion in a model-file); they’re applied simply as shader-inputs.

I now want to be able to use the texture-matrix with this shader–but for some reason it doesn’t seem to be working, where it seems to work in other shaders. A quick look at those shaders, however, indicates that at least the few that I examined do in fact take at least one texture in via the built-in texture-system.

So I’m wondering whether perhaps the texture-matrix is simply not provided, or is forced to the identity matrix, in the case in which no texture is applied to the model in question.

Is this so? Or might I be doing something else incorrectly…?

Note, by the way, that the change that I’m looking for from the texture-matrix right now is a scaling-factor, which I’m attempting to apply with a call along the following lines:
model.setTexScale(TextureStage.getDefault(), uVal, vVal)

Now, of course I could rework the shader in question to use the built-in texture-system–but this shader is already doing a lot of work elsewhere, and I’m hesitant to change too much.

(My other option, of course, is to apply the effect of the texture-matrix elsehow, using a new shader-input. But that likewise might incur changes to other things using the shader.)

No, this isn’t possible. setTexScale is meant to go hand-in-hand with setTexture. That’s because the indices of the p3d_TextureMatrix array correspond 1:1 with the order of the texture stages of the applied textures.

If you specify the texture as a shader input, you’ll have to do the same with the matrix:

model.setShaderInput("mat", Mat4.scaleMat(su, sv, sw))

Alternatively, apply a dummy texture to the scene root that is overridden by nodes that have their own texture applied.

1 Like

Ah, I see! A bit of a pain in my situation, but so it goes!

Thank you for the explanation! :slight_smile:

I’ll have to think about what to do in my specific case, then…

I’m internally debating whether it’d make sense for p3d_TextureMatrix to take on the value of the default texture stage’s matrix in the absence of any assigned textures.

It would make sense to me, I think. After all, I would expect a default stage to, by its nature as a default, always be present, and thus operations performed on that stage to be effective and passed on to shaders.

I’m not sure that’s what “default” is intended to mean in the context of Panda, but please file an issue request.

Fair enough, and done! :slight_smile: