- Home /
Change Material settings through script
Hello
I procdurally generate a tessellation material
p.renderer.material = new Material(Shader.Find("Tessellation/Bumped Specular (displacement)"));
p.renderer.material.mainTexture = heightMap;
p.renderer.material.SetTexture("_ParallaxMap",heightMap);
p.renderer.material.SetTexture("_BumpMap",heightMap);
And now I want to change the height and edge length of the tessellation shader/material. How do I do that with a script? I cant find any function for that.
if that's code do you $$anonymous$$ formatting it?
Edited. Sorry thought I did it already. But the code is not really importent for a solution.
Answer by Fornoreason1000 · May 13, 2013 at 06:18 PM
look here :http://docs.unity3d.com/Documentation/ScriptReference/Material.html
there are a set of get functions you can use. I'm assuming you length are height are float so you will use the Material.GetFloat
so:
render.material.GetFloat("Height")
render.material.GetFloat("EdgeLength")
if your setting parameters you will use the Material.SetFloat
so it would be
render.material.SetFloat("Height", 0.1234f)
render.material.SetFloat("EdgeLength", 70000f)
you can do this for vector hope it helps
Just found it dont know if your code is working, I found it by looking into the tes shader
p.renderer.material.SetFloat("_Parallax",0f);
p.renderer.material.SetFloat("_EdgeLength",0f);
Could come have earlier on that idea... thanks anyway :)
//Edit Just saw your EdgeLength 70000f. The max value I found is 50f so dont know where you get the 70000 ^^
Edit Just saw your EdgeLength 70000f. The max value I found is 50f so dont know where you get the 70000
its random.... its just an example my friend