when creating custom materials i´d like to have rough/polished value as you get with the metal material in Rhino.
i can not find a property like that. i tried “shine” but that does not seem to do anything.
how would i create something like the rhino metal materials myself? Is that an extra class i did not find?
If you use RenderMaterial to create a new material, then you can set the parameters
"polish-amount" to your wanted value (in the range [0.00,1.00]).
For a metal to be a metal with the custom rendermaterial you need to have diffuse color set to black and reflectivity to 1.
To check the names you should fiddle with you can save a material to file and open it in a text editor. I like to create a metal first, then convert it to custom, and save that out. Open up and look at the
How are you currently creating your materials? (Code snippet please).
here is the code:
var custom = new Rhino.DocObjects.Material(); custom.Reflectivity = 1; custom.ReflectionColor = System.Drawing.Color.FromArgb(r[currIntOption], g[currIntOption], b[currIntOption]); custom.Transparency = fjMatTrans[currIntOption]; custom.Shine = fjMatShine[currIntOption]; custom.Name = matName[currIntOption]; custom.CommitChanges(); rm = RenderMaterial.CreateBasicMaterial(custom);
are “shine” and “polish-amount” two different properties?
There seems to be a difference between “Material” and “RenderMaterial” that i don’t get. Are they connected? Do i have to use both like i do in my code?
Rhino.DocObjects.Material is the old-style material.
Rhino.Render.RenderMaterial is the new-style RDK material. I’d advise
Here is a snippet in Python to create 10 metal materials with random roughness. Shine and Polish Amount are the inverse of roughness, so for a perfectly smooth metal you’d pass in 1.0 to both.
# Create 10 random metal-like materials # using RenderMaterial import Rhino import System import scriptcontext import random for i in range(0,10): m = Rhino.DocObjects.Material() m.Name = "Random Roughness Metal" shine = random.random() rm = Rhino.Render.RenderMaterial.CreateBasicMaterial(m) rm.BeginChange(Rhino.Render.RenderContent.ChangeContexts.Program) rm.SetParameter("diffuse", System.Drawing.Color.Black) rm.SetParameter("reflectivity", 1.0) rm.SetParameter("reflectivity-color", System.Drawing.Color.LightBlue) rm.SetParameter("shine", shine) rm.SetParameter("polish-amount", shine) rm.EndChange() scriptcontext.doc.RenderMaterials.Add(rm)
A test run yields:
thank you very much! this helps a lot!