I am writing an exporter / plug-in for an external rendering engine. I have not been able to find any examples / docs about creating custom render settings or changing the way material settings work through C#.
What is the correct way of doing this? For example, my rendering engine defines different types of materials with different settings (i.e. not just Color, Bump, Alpha, etc.). How can I replace the Rhino materials with my custom material options?
Similarly, how can I add custom render parameters to the render settings dialog?
Since I’m away from the office, @dale will have to help you find a sample for replacing the options dialog render page in C#. (Sorry Dale - I couldn’t seem to find one).
Both the Rhino C++ and Rhino_DotNet SDKs have functions on their render plug-in objects that allow the developer to replace the Render page in the Options dialog box. RhinoCommon does not. It’s on the to-do list…
Hopefully in a future service release. You an add your own pages to the Options dialog, from RhinoCommon. You just cannot replace the Render page (yet).
Ah! That would completely suffice for now. I just need somewhere to stick a load of render settings (scene parameters + camera properties).
Any templates for THAT bit? Thanks again for your continued help!
If you’re interested, I’m putting together an exporter for Indigo Renderer (indigorenderer.com) which is an amazing spectral renderer used a lot for arch. viz + products.
The example seems a bit too extensive and I’m a little bit confused about what is actually necessary to get a bare-bones custom material… I’ve written my own material class, as in CustomMaterial.cs but am not sure if I need the rest of the material classes (CustomMaterialViewModel, CustomMaterialWpfUserInterfaceSection.xaml, CustomMaterialUserInterfaceSection, and CustomMaterialUserInterfaceSection2). As it is, nothing new shows up in the Material Editor when launching my render plugin.
Is there any documentation perhaps that describes each of these elements in further detail?
Also, on another slightly different note, how can I embed settings within the Rhino document? Objects have custom user data, however global settings (such as for render settings) don’t seem available under RhinoDoc…
Pay particular attention to the project’s PlugIn inherited class, as it overrides ShouldCallWriteDocument, WriteDocument, and ReadDocument required to write and read document user data.
The UserInterfaceSection stuff is for custom UI only (using either Forms or XAML). If you use the automatic section, your field data will be shown in the UI without any further coding.
You should be able to omit those classes (and the calling code in the CustomMaterial.cs file) and get a working material.
@jesterKing may be able to cook up a more simple example for you.
Verify the RhinoCommon reference is correct as per your own installation.
When you’ve loaded the plugin into Rhino you are able to create a new material of type “CSharp Custom Material”. The new material will by default have an orangy diffuse color. You can find fields added under “Texture Summary” section for the material.