Say I have 8 GEOs inside of another GEO and that I am applying a GLSL material to the parent GEO. Is there a way to access an attribute that would allow me to do something like lookup a different color for each of the GEOs inside? I can’t use instancing, because of the way the geometries need to work, so I’m wondering if I can either pass the shader a single color for each one, or somehow apply an ID to each that can be used in the shaders.
Right now I’m using the Point SOP, but unfortunately it gets quite expensive per frame when I’m changing the colors all the time.
I feel like there should be a way, but I’m having a hard time thinking of how. It also seems a bit silly to apply the Mat to each individual GEO, as there are a number of variable parameters associated with the MAT.
dont think it’s much of a problem to have a different MAT applied to each GEO seperately, they are gonna be uploaded as separate batches anyway…
but of course you can always use attributes. In your SOP chains, use a point SOP (ideally at the beginning of the chain, before any animated parameters) to add an ID attribute. The, in your custom shader that you apply at the top level, you use that ID to lookup the color from some CHOP channels via uniform arrays or texture buffers
You can use the Primitive SOP also which will be a little quicker than the point SOP.
Another way is to use the Inherit parameter that the GLSL MAT has to get uniforms from another GLSL MAT. That way you have the top level MAT with all the global uniforms/textures set, and just set a single uniform for the rest of the MATs which is the ID.
Thanks guys. I’ve ended up just making a MAT for each sub-geo within the master geo. It’s not hugely taxing. I just gave each one its own defined ID within the uniforms, and exported the same variables to each.
Creating an attribute would still force my entire SOP network to cook when it changed, correct?
As for inheriting, I would like to find a solution like that, but I can’t see how to inherit the uniforms of more than one MAT into the master MAT. Is there a way that it can inherit the uniforms just from the MAT associated with the geo that is currently being rendered? Or would each sub MAT actually be doing the inheriting from the master one?