Structs in Cg shaders.

Supposing I have a structure in a shader:

struct panda3d{
	float4 k_vec;

void vs( uniform panda3d str0, uniform panda3d str1,...)

How do I set the value to both the k_numbers? It seems to me there is no way to differentiate the inputs since the only name accepted is “vec”?

Hm… good point. I didn’t think of that when I implemented struct support. There’s no way to differentiate between those different k_vecs.

Do you want me to fix it?

What about:


That sounds like a fine idea. I don’t think we need k_ prefixes for struct members, I think we can assume them all to be custom uniform inputs.

The code that will need to be changed is around line 440 of shader.cxx - right now, it strips off everything before the last dot. Instead, we could simply check if it contains a dot, and if it does, treat it the same way as a k_ parameter (except that the k_ prefix is not stripped).

Yes, but I have added a new input (that takes A PTA() and works for every float1,2,3, 1x2, 2x1, …) and I am keeping it separated from k_ (even if it’s a uniform as well) so I need to differentiate it somehow, and I need k_.

But in the future I can integrate the new input with k_anything and thus get rid of k_ in the struct

Hm, I’m actually planning to phase out the use of the k_ prefix, and allow anything.
Why would the array inputs need a different prefix?

You are right it doesn’t need a different prefix.

OK, I fixed the bug. (two lines of code … :slight_smile: )