Unique RenderAttributes per obj
Reply on sbox.game-
I am trying to set a unique render attribute on each object in my scene, and I want something like this:
GetComponent<ModelRenderer>().Attributes.Set( "MyColor", myColor);
.. but that isn't doing anything. I also tried making a clone of the OverrideMaterial per object.
I know the material is set up correctly internally at least as this works, but it affects every object:Scene.RenderAttributes.Set( "MyColor", myColor);
Does anyone have an example that works? -
I would expect what you're doing there to work
-
you'll also need to do
SceneObject.Batchable = false;
otherwise it will "bleed" over to other objects using that model -
Hmm ok cool that probably means I lose some optimizations like instancing maybe?
-
Looks like I needed:
GetComponent<ModelRenderer>().SceneObject.Attributes.Set( "MyColor", myColor);
(On the SceneObject instead of the ModelRenderer itself) -
That makes some sense, but did
GetComponent<ModelRenderer>().Attributeseven work? I don't really see how it could have - that member doesn't exist? We should create it? -
Renderer.Attributes does not exist, no
-
Ah sorry this is what I tried that didn't work, botched it when I was simplifying the exampleedited:
GetComponent<ModelRenderer>().GetMaterial().AttributesI could see maybe needing to create unique material instances per object or something, but I couldn't see the result of this at all even globally