Ok, I have many different surfaces (renderers) that I want to dynamically create procedural materials for.
What I'm doing now :
I have a reference material :
I have a table of procedural materials :
Then for each of them I want to create a clone that I can change independently :
Now, if I change the property of one :
It changes them all. It seems to be changing the original and not the clone.
I must be missing something here..
Thanks for your help.
asked Jul 24 '12 at 07:16 PM
I figured it out, and will share my finding here.
I had a material (not procedural) reference, which I was tweaking before I would apply it to other objects. I found that applying the material to an object "creates" the instance I was looking for.
So the proper process is :
I was trying to instantiate the material before I would assign it. It now works as I want, with pretty good performances.
answered Aug 08 '12 at 10:27 PM
You can instantiate substances at runtime using renderer.material instead of renderer.Sharedmaterial, Instanciate should not be used with procedural materials.
ProceduralMaterial Instance = GameObject.renderer.material as ProceduralMaterial;
This will instanciate dynamically a new copy "Instance" of the procedural material applied to GameObject.