Shader Transform Question

So I’ve observed some interesting and confusing behavior when dealing with shaders and multiple cameras. I’m going to try and explain it the best I can and see if this is expected behavior.

We have render with a standard camera set as it’s scene. Reparented to render are several debug visual parts which have transforms on them. Underneath one of those debug visual parts is a node which another camera is reparented to, which is used as our shadow cam and most of the physics and visual geometry. The shadow camera has it’s scene set to this node as well.

To reduce the geom node count of the scene, I setup a special shader that took in physics node paths as inputs, then used their transforms on parts of the visual geometry. This works great, as I have 5 physics objects per one visual geom. I used the trans_physicsNode#_to_model information to get each transform for a part of the model.

A problem showed up when I looked at the shadows. They were not in the correct position and through some experimentation I found that they were missing the transform from render to the node that the shadow cam was under.

My question is: Is this expected behavior? It seems like the “world” of the shader changes based on the camera the shader is being run with.

Hi Adam!

I read your question and let me see if I understand you.

You’ve got a single geom, and 5 physics nodes. You’re using the 5 physics nodes as “bones” to deform the one geom - right? But you’re not using panda’s built-in skinning, instead, you’ve written a shader that takes the 5 physics nodes as inputs, and the shader does the skinning?

Yo Josh! =)

Yup, thats correct.

It works great for the visual cameras, but doesn’t work quite as for the shadow camera, possibly due to the difference in transforms between the camera’s scenes.

I’m not using the built in code because I think we are processor limited at the moment.

I’m mainly curious if the difference between the two cameras, as far as the shader is concerned, is what is expected.

Sorry I didn’t get back to you sooner.

Anyhow, it sounds like there might be a bug of some sort. Or at least, the situation is sufficiently confusing that I don’t quite know what it should do.

Could you drop by my office and we could try to solve it together?

  • Josh

Sure sure.

I’m not sure if its a bug or not, its just not acting the way I would expect.

I’ll see if I can make it in Monday or Tuesday afternoon.

~~Adam