Quantcast
Viewing latest article 3
Browse Latest Browse All 18

Shader.SetGlobal for properties that materials already have

According to the unity script reference, the Shader.SetGlobal functions can only set properties that the material doesn't already have. Ex: if I had a material in the scene, and that material uses/used a shader that has a property called "_Theta"(float), if I call Shader.SetGlobalFloat("_Theta", 0.5f) it will not work for that material. Well, that's a big problem for me since I wrote some shaders and now I realise the cost of looping through the entire material list of the scene is pretty expensive( a 15-20 fps drop if I loop through all the materials and set floats for materials one by one), I modified my shaders(deleting the _Theta property in the property block) but now the materials(about 200 of them) I created with the old shader still has _Theta as a material property, I could remake all the materials again but that would take a lot of time, is there anyway to cleanup a material so that it will only have the properties that the current shader exposes?

Viewing latest article 3
Browse Latest Browse All 18

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>