How to set the bump amount of a PhysicallyBasedMaterial in RhinoCommon?

In our RhinoCommon based plugin for Rhino 8 I would like to set the bump amount for a PBR material. I can successfully set a bump texture but I’m not able to set the bump amount.

I created a Material:
var mat = new Rhino.DocObjects.Material();

Then I created the PBR material:

Rhino.DocObjects.PhysicallyBasedMaterial pbrMat = mat.PhysicallyBased;

And finally I created a RenderMaterial:
var renderMat = Rhino.Render.RenderMaterial.FromMaterial(mat, doc);

How can I change the bump amount of the PBR material? I tried to set it in all three materials. The PhysicallyBasedMaterial seems to have no bump amount property and I also tried things like renderMat.SetChildSlotAmount("Bump", 50.0, RenderContent.ChangeContexts.Program); without success.

Thanks in advance!

Best regards

Hi @Timothy_Peoples, below works fine in Rhino 7 but fails in Rhino 8:

context = Rhino.Render.RenderContent.ChangeContexts.Program
rm.SetParameter("pbr-bump-amount", 45) 

Edit: btw. if you create this PhysicallyBased material from scratch you’ll need to enable the displacement / bump UI section as well. See this post for more information. The best way to find out about the used parameter names is to create a material in the material browser then save it as rmtl file and look inside the xml structure…

@johnc, i think Rhino 8 has a bug. To repeat it, please create a new document with only one physically based material with a bump slot, then run this script:

import Rhino
import scriptcontext
import rhinoscriptsyntax as rs

def DoSomething():
    renderMat = list(scriptcontext.doc.RenderMaterials)[0]
    print "Before:", renderMat.GetParameter("pbr-bump-amount").ToDouble(None)
    context = Rhino.Render.RenderContent.ChangeContexts.Program
    renderMat.SetParameter("pbr-bump-amount", 42, context) 
    print "After:", renderMat.GetParameter("pbr-bump-amount").ToDouble(None)

It seems the value get/set works properly but the UI does not reflect it. (i’ve tried various different context values).


1 Like

The UI not updating the new value is a bug. I logged it I will also fix it now.

Edit: Fixed in v.8.4


Thank you very much for your help, Clement and Max!