A note on terminology plugin: We use the term plugin a lot. Technically it could mean a plugin DLL for V-Ray (even V-Ray itself is a kind of plugin) or the type defined in it, which is for example a class in the programming sense, or finally an instance of this class which resides in memory and can be saved to a scene file. We will be using the term plugin to refer to plugin instances. exporter/translator: We call the piece of software that translates some native scene format to the V-Ray scene format an exporter or a translator, interchangeably. Basically what it does is creating a bunch of V-Ray plugins and setting their parameters. Note that we also use the verb "to export" sometimes in reference to the act of saving out the scene (which was already translated) to a *.vrscene file. Overview Plugins are the building blocks in a V-Ray scene. Everything is a plugin - the lights, geometry, materials and settings.
We could informally define three kinds of plugins that build up a V-Ray scene. One would be the so called "top-level" plugins, which can exist on their own, without being part of some plugin tree. Lights are top-level plugins for example. They can also receive input from other plugins of course, but they do not output values to other plugins. The plugins which are not top-level serve as input for parameter slots which require a plugin of certain type. For example a material plugin may require an optional texture input and you'd reference a texture plugin there. The texture plugin may receive input from a UVW generator and so on. The third kind would be a special type of top-level plugins which only have one instance. These are basically settings plugins. Most of them have "Settings" in their name, but a few do not. The V-Ray camera is also defined by such a singleton plugin.
Each of the language bindings has a Plugin class which is a lightweight wrapper for the underlying instance in the V-Ray engine. These objects do not contain the actual property data, so they can be copied around (e.g. passed by value). In the statically typed languages we support - C++ and C# - there are concrete classes for the specific V-Ray plugin types as well as the generic Plugin type. They provide property getters and setters for convenience over the generic methods that use strings to identify the property.
Since Plugin objects are just wrappers, their going out of scope does not remove the actual V-Ray plugin from the scene. It's just a reference. Adding and removing instances is done through methods of the VRayRenderer class.
The default constructor for the Plugin class creates an invalid object. The object can be checked as a boolean value for validity. Some APIs such as getPlugin() return a Plugin object. It can be invalid if for example the requested instance name was not found. It is good practice to check such returned values for validity before using them further.
Getting a plugin reference There are several ways of obtaining a reference to an existing plugin specific for each language (see also PluginRef in the next chapter). They are demonstrated in the following example:
Python <code data-v-c2b1f83f=""><span data-v-c2b1f83f="" class="line"># We know the plugin's name in advance</span><span data-v-c2b1f83f="" class="line">renderView = renderer.plugins["renderView"]</span><span data-v-c2b1f83f="" class="line"># or equivalently</span><span data-v-c2b1f83f="" class="line">renderView2 = renderer.plugins.renderView</span><span data-v-c2b1f83f="" class="line">assert renderView == renderView2</span></code>
C++ <code data-v-c2b1f83f=""><span data-v-c2b1f83f="" class="line">// We know the plugin's name in advance</span><span data-v-c2b1f83f="" class="line">RenderView renderView = renderer.getPlugin<RenderView>("renderView");</span><span data-v-c2b1f83f="" class="line">// We know only the type of the plugin and that it's a singleton</span><span data-v-c2b1f83f="" class="line">RenderView renderView2 = renderer.getInstanceOf<RenderView>();</span><span data-v-c2b1f83f="" class="line">// We get it as a generic plugin type</span><span data-v-c2b1f83f="" class="line">Plugin renderView3 = renderer.getPlugin("renderView");</span><span data-v-c2b1f83f="" class="line">// We can use this special cast similar to static_cast if we are certain of the type</span><span data-v-c2b1f83f="" class="line">RenderView renderView4 = plugin_cast<RenderView>(renderView3);</span><span data-v-c2b1f83f="" class="line">// There is a checked version similar to dynamic_cast. It returns invalid Plugin if the type doesn't match</span><span data-v-c2b1f83f="" class="line">RenderView renderView5 = plugin_checked_cast<RenderView>(renderView3);</span><span data-v-c2b1f83f="" class="line"> </span><span data-v-c2b1f83f="" class="line">assert(renderView == renderView2);</span><span data-v-c2b1f83f="" class="line">assert(renderView == renderView3); // note that the right side here is generic Plugin</span><span data-v-c2b1f83f="" class="line">assert(renderView == renderView4);</span><span data-v-c2b1f83f="" class="line">assert(renderView == renderView5);</span></code>
C#.NET <code data-v-c2b1f83f=""><span data-v-c2b1f83f="" class="line">// We know the plugin's name in advance</span><span data-v-c2b1f83f="" class="line">RenderView renderView = renderer.GetPlugin<RenderView>("renderView");</span><span data-v-c2b1f83f="" class="line">// We know only the type of the plugin and that it's a singleton</span><span data-v-c2b1f83f="" class="line">RenderView renderView2 = renderer.GetInstanceOf<RenderView>();</span><span data-v-c2b1f83f="" class="line">// We get it as a generic plugin type</span><span data-v-c2b1f83f="" class="line">Plugin renderView3 = renderer.GetPlugin("renderView");</span><span data-v-c2b1f83f="" class="line"> </span><span data-v-c2b1f83f="" class="line">System.Diagnostics.Debug.Assert(renderView == renderView2);</span><span data-v-c2b1f83f="" class="line">System.Diagnostics.Debug.Assert(renderView == renderView3);</span></code>
Node.js <code data-v-c2b1f83f=""><span data-v-c2b1f83f="" class="line">var assert = require('assert');</span><span data-v-c2b1f83f="" class="line">// We know the plugin's name in advance</span><span data-v-c2b1f83f="" class="line">var renderView = renderer.plugins["renderView"];</span><span data-v-c2b1f83f="" class="line">// or equivalently</span><span data-v-c2b1f83f="" class="line">var renderView2 = renderer.plugins.renderView;</span><span data-v-c2b1f83f="" class="line">assert(renderView == renderView2);</span></code>
We can retrieve all plugin names or all possible plugin types. We can also retrieve all instances of a given plugin type, e.g. Node.
Python <code data-v-c2b1f83f=""><span data-v-c2b1f83f="" class="line"># Print the names of all plugin instances</span><span data-v-c2b1f83f="" class="line">for plugin in renderer.plugins:</span><span data-v-c2b1f83f="" class="line"> print(plugin.getName())</span><span data-v-c2b1f83f="" class="line"># Print the names of all available plugin classes</span><span data-v-c2b1f83f="" class="line">for cls in renderer.classes:</span><span data-v-c2b1f83f="" class="line"> print(cls.getName())</span><span data-v-c2b1f83f="" class="line"># Print all instance names of a given type</span><span data-v-c2b1f83f="" class="line">for node in renderer.classes.Node.getInstances():</span><span data-v-c2b1f83f="" class="line"> print(node.getName())</span></code>
C++ <code data-v-c2b1f83f=""><span data-v-c2b1f83f="" class="line">// Print the names of all plugin instances</span><span data-v-c2b1f83f="" class="line">for (const Plugin& plugin : renderer.getPlugins())</span><span data-v-c2b1f83f="" class="line"> cout << plugin.getName() << endl;</span><span data-v-c2b1f83f="" class="line">// Print the names of all available plugin classes</span><span data-v-c2b1f83f="" class="line">for (const string& className : renderer.getAllPluginTypes())</span><span data-v-c2b1f83f="" class="line"> cout << className << endl;</span><span data-v-c2b1f83f="" class="line">// Print all instance names of a given type</span><span data-v-c2b1f83f="" class="line">for (const Plugin& node : renderer.getPlugins("Node"))</span><span data-v-c2b1f83f="" class="line"> cout << node.getName() << endl;</span></code>
C#.NET <code data-v-c2b1f83f=""><span data-v-c2b1f83f="" class="line">// Print the names of all plugin instances</span><span data-v-c2b1f83f="" class="line">foreach (Plugin plugin in renderer.GetPlugins())</span><span data-v-c2b1f83f="" class="line"> Console.WriteLine(plugin.GetName());</span><span data-v-c2b1f83f="" class="line">// Print the names of all available plugin classes</span><span data-v-c2b1f83f="" class="line">foreach (string className in renderer.AllPluginTypes)</span><span data-v-c2b1f83f="" class="line"> Console.WriteLine(className);</span><span data-v-c2b1f83f="" class="line">// Print all instance names of a given type</span><span data-v-c2b1f83f="" class="line">foreach (Plugin node in renderer.GetPlugins("Node"))</span><span data-v-c2b1f83f="" class="line"> Console.WriteLine(node.GetName());</span></code>
Node.js <code data-v-c2b1f83f=""><span data-v-c2b1f83f="" class="line">// Print the names of all plugin instances</span><span data-v-c2b1f83f="" class="line">for (var plugName in renderer.plugins)</span><span data-v-c2b1f83f="" class="line"> console.log(plugName);</span><span data-v-c2b1f83f="" class="line">// Or alternatively iterate over all plugin instances and print their names</span><span data-v-c2b1f83f="" class="line">for (var plugin of renderer.plugins)</span><span data-v-c2b1f83f="" class="line"> console.log(plugin.getName());</span><span data-v-c2b1f83f="" class="line">// Print the names of all available plugin classes</span><span data-v-c2b1f83f="" class="line">for (var className in renderer.classes)</span><span data-v-c2b1f83f="" class="line"> console.log(className);</span><span data-v-c2b1f83f="" class="line">// Or alternatively iterate over all plugin classes and print their names</span><span data-v-c2b1f83f="" class="line">for (var cls of renderer.classes)</span><span data-v-c2b1f83f="" class="line"> console.log(cls.getName());</span><span data-v-c2b1f83f="" class="line">// Print all instance names of a given type</span><span data-v-c2b1f83f="" class="line">var nodeInstances = renderer.classes.Node.getInstances();</span><span data-v-c2b1f83f="" class="line">for (var node of nodeInstances)</span><span data-v-c2b1f83f="" class="line"> console.log(node.getName());</span></code>
All plugins expose info about their properties' names, types, default values, and descriptions. This information we call plugin's metadata. It can be accessed in the following way:
Python <code data-v-c2b1f83f=""><span data-v-c2b1f83f="" class="line">pluginDescription = renderer.classes.RenderView.getDescription()</span><span data-v-c2b1f83f="" class="line"># Description of a render view (camera) -- position, field of view, etc. [gpuSupport=(partial)]</span><span data-v-c2b1f83f="" class="line"></span><span data-v-c2b1f83f="" class="line">pluginMeta = renderer.classes.RenderView.getMeta()</span><span data-v-c2b1f83f="" class="line">for propName, propMeta in pluginMeta.items():</span><span data-v-c2b1f83f="" class="line"> print("propName = " + repr(propName))</span><span data-v-c2b1f83f="" class="line"> # 'transform', 'fov', ...</span><span data-v-c2b1f83f="" class="line"> propertyDescription = propMeta["description"]</span><span data-v-c2b1f83f="" class="line"> # 'Camera transform - position and rotation', 'Horizontal field of view', ...</span><span data-v-c2b1f83f="" class="line"> propertyType = propMeta["type"]</span><span data-v-c2b1f83f="" class="line"> # 'Transform', 'float', ...</span><span data-v-c2b1f83f="" class="line"> defaultVal = propMeta["defaultValue"]</span><span data-v-c2b1f83f="" class="line"> # 'Transform(Matrix(Vector(1, 0, 0), Vector(0, 1, 0), Vector(0, 0, 1)), Vector(0, 0, 0))', '0.785398', ...</span><span data-v-c2b1f83f="" class="line"> gpuParamSupport = propMeta["GPUSupport"]</span><span data-v-c2b1f83f="" class="line"> # 'Full', 'Full', ...</span></code>
C++ <code data-v-c2b1f83f=""><span data-v-c2b1f83f="" class="line">PluginMeta pluginMeta = renderer.getPluginMeta("RenderView");</span><span data-v-c2b1f83f="" class="line">string pluginDescription = pluginMeta.getDescription();</span><span data-v-c2b1f83f="" class="line">// Description of a render view (camera) -- position, field of view, etc. [gpuSupport=(partial)]</span><span data-v-c2b1f83f="" class="line">const vector<string> propertyNames = pluginMeta.getPropertyNames();</span><span data-v-c2b1f83f="" class="line">// ["transform", "fov", ...]</span><span data-v-c2b1f83f="" class="line">for (const string& propName : propertyNames) {</span><span data-v-c2b1f83f="" class="line"> PropertyMeta propertyMeta = pluginMeta.getPropertyMeta(propName);</span><span data-v-c2b1f83f="" class="line"> string propertyDescription = propertyMeta.getDescription();</span><span data-v-c2b1f83f="" class="line"> // "Camera transform - position and rotation", "Horizontal field of view", ...</span><span data-v-c2b1f83f="" class="line"> string propertyType = propertyMeta.getTypeAsString();</span><span data-v-c2b1f83f="" class="line"> // "Transform", "float", ...</span><span data-v-c2b1f83f="" class="line"> Value defaultVal = propertyMeta.getDefaultValue();</span><span data-v-c2b1f83f="" class="line"> // "Transform(Matrix(Vector(1, 0, 0), Vector(0, 1, 0), Vector(0, 0, 1)), Vector(0, 0, 0))", "0.785398", ...</span><span data-v-c2b1f83f="" class="line"> GPUParamSupport gpuParamSupport = propertyMeta.getGPUSupport();</span><span data-v-c2b1f83f="" class="line"> // GPUParamSupport::GPUParamSupport_Full, GPUParamSupport::GPUParamSupport_Full, ...</span><span data-v-c2b1f83f="" class="line">}</span></code>
C#.NET <code data-v-c2b1f83f=""><span data-v-c2b1f83f="" class="line">PluginMeta pluginMeta = renderer.GetPluginMeta("RenderView");</span><span data-v-c2b1f83f="" class="line">string pluginDescription = pluginMeta.Description;</span><span data-v-c2b1f83f="" class="line">// Description of a render view (camera) -- position, field of view, etc. [gpuSupport=(partial)]</span><span data-v-c2b1f83f="" class="line">string[] propertyNames = pluginMeta.PropertyNames;</span><span data-v-c2b1f83f="" class="line">// ["transform", "fov", ...]</span><span data-v-c2b1f83f="" class="line">foreach (var propName in propertyNames)</span><span data-v-c2b1f83f="" class="line">{</span><span data-v-c2b1f83f="" class="line"> PropertyMeta propertyMeta = pluginMeta.GetPropertyMeta(propName);</span><span data-v-c2b1f83f="" class="line"> string propertyDescription = propertyMeta.Description;</span><span data-v-c2b1f83f="" class="line"> // "Camera transform - position and rotation", "Horizontal field of view", ...</span><span data-v-c2b1f83f="" class="line"> string propertyType = propertyMeta.TypeString;</span><span data-v-c2b1f83f="" class="line"> // "Transform", "float", ...</span><span data-v-c2b1f83f="" class="line"> object defaultVal = propertyMeta.DefaultValue;</span><span data-v-c2b1f83f="" class="line"> // "Transform(Matrix(Vector(1, 0, 0), Vector(0, 1, 0), Vector(0, 0, 1)), Vector(0, 0, 0))", "0.785398", ...</span><span data-v-c2b1f83f="" class="line"> GPUParamSupport gpuParamSupport = propertyMeta.GPUSupport;</span><span data-v-c2b1f83f="" class="line"> // GPUParamSupport.GPUParamSupport_Full, GPUParamSupport.GPUParamSupport_Full, ...</span><span data-v-c2b1f83f="" class="line">}</span></code>
Node.js <code data-v-c2b1f83f=""><span data-v-c2b1f83f="" class="line">var pluginDescription = renderer.classes.RenderView.getDescription()</span><span data-v-c2b1f83f="" class="line">// Description of a render view (camera) -- position, field of view, etc. [gpuSupport=(partial)]</span><span data-v-c2b1f83f="" class="line"></span><span data-v-c2b1f83f="" class="line">var pluginMeta = renderer.classes.RenderView.getMeta()</span><span data-v-c2b1f83f="" class="line">for (var propName in pluginMeta) {</span><span data-v-c2b1f83f="" class="line"> var propMeta = pluginMeta[propName]</span><span data-v-c2b1f83f="" class="line"> // 'transform', 'fov', ...</span><span data-v-c2b1f83f="" class="line"> propertyDescription = propMeta['description']</span><span data-v-c2b1f83f="" class="line"> // 'Camera transform - position and rotation', 'Horizontal field of view', ...</span><span data-v-c2b1f83f="" class="line"> propertyType = propMeta['type']</span><span data-v-c2b1f83f="" class="line"> // 'Transform', 'float', ...</span><span data-v-c2b1f83f="" class="line"> defaultVal = propMeta['defaultValue']</span><span data-v-c2b1f83f="" class="line"> // 'Transform(Matrix(Vector(1, 0, 0), Vector(0, 1, 0), Vector(0, 0, 1)), Vector(0, 0, 0))', '0.785398', ...</span><span data-v-c2b1f83f="" class="line"> gpuParamSupport = propMeta['GPUSupport']</span><span data-v-c2b1f83f="" class="line"> // 'Full', 'Full', ...</span><span data-v-c2b1f83f="" class="line">}</span></code>
Description is a string that can be placed in the UI. Type is a string, denoting one of the possible Property Types Default value is an object of type type. GPUParamSupport describes the extent to which a property is supported by V-Ray GPU Creating plugin instances The following example shows how new plugin instances are created. If the requested instance name is already used, creation will fail.
Python <code data-v-c2b1f83f=""><span data-v-c2b1f83f="" class="line"># this will generate a unique name for the instance</span><span data-v-c2b1f83f="" class="line">renderView = renderer.plugins.classes.RenderView()</span><span data-v-c2b1f83f="" class="line"># or pass a name of your own</span><span data-v-c2b1f83f="" class="line">renderView = renderer.plugins.classes.RenderView("myRenderView")</span></code>
C++ <code data-v-c2b1f83f=""><span data-v-c2b1f83f="" class="line">// this will generate a unique name for the instance</span><span data-v-c2b1f83f="" class="line">RenderView renderView = renderer.newPlugin<RenderView>();</span><span data-v-c2b1f83f="" class="line">// or pass a name of your own</span><span data-v-c2b1f83f="" class="line">RenderView renderView = renderer.newPlugin<RenderView>("myRenderView");</span></code>
C#.NET <code data-v-c2b1f83f=""><span data-v-c2b1f83f="" class="line">// this will generate a unique name for the instance</span><span data-v-c2b1f83f="" class="line">RenderView renderView = renderer.NewPlugin<RenderView>();</span><span data-v-c2b1f83f="" class="line">// or pass a name of your own</span><span data-v-c2b1f83f="" class="line">RenderView renderView = renderer.NewPlugin<RenderView>("myRenderView");</span></code>
Node.js <code data-v-c2b1f83f=""><span data-v-c2b1f83f="" class="line">// this will generate a unique name for the instance</span><span data-v-c2b1f83f="" class="line">var renderView = renderer.plugins.classes.RenderView();</span><span data-v-c2b1f83f="" class="line">// or pass a name of your own</span><span data-v-c2b1f83f="" class="line">var renderView = renderer.plugins.classes.RenderView("myRenderView");</span></code>
Additionally, there is the getInstanceOrCreate() method, which only creates the instance if one does not already exist. Otherwise, it returns the existing instance. This is useful for settings plugins that should not have more than one instance in the scene. There is also the getInstanceOf() method in C++, GetInstanceOf() in C#, and getInstance() in Python and Node.js that returns the most recently added instance, if one exists.
Removing plugin instances When a plugin instance is removed from the scene all references to it are reset to null internally. Any Plugin objects you have that reference the deleted plugin instance become invalid, although performing a boolean check on them still returns True. Operations on them will fail. If you're not sure if an instance still exists, get a Plugin reference by name again from the renderer and perform a boolean check on it.
Python <code data-v-c2b1f83f=""><span data-v-c2b1f83f="" class="line">node = renderer.plugins['myNodeName']</span><span data-v-c2b1f83f="" class="line">del renderer.plugins['myNodeName']</span><span data-v-c2b1f83f="" class="line"># or</span><span data-v-c2b1f83f="" class="line">del renderer.plugins.myNodeName</span><span data-v-c2b1f83f="" class="line"># or</span><span data-v-c2b1f83f="" class="line">del renderer.plugins[node]</span><span data-v-c2b1f83f="" class="line"># or simply</span><span data-v-c2b1f83f="" class="line">node.deleteThis() # node variable won't reference any plugin instance after this call</span></code>
C++ <code data-v-c2b1f83f=""><span data-v-c2b1f83f="" class="line">Node node = renderer.getPlugin<Node>("myNodeName");</span><span data-v-c2b1f83f="" class="line">renderer.deletePlugin(node);</span><span data-v-c2b1f83f="" class="line">// or</span><span data-v-c2b1f83f="" class="line">renderer.deletePlugin("myNodeName");</span><span data-v-c2b1f83f="" class="line">// or (but not recommended)</span><span data-v-c2b1f83f="" class="line">renderer.deletePlugin(node.getName());</span></code>
C#.NET <code data-v-c2b1f83f=""><span data-v-c2b1f83f="" class="line">Node node = renderer.GetPlugin<Node>("myNodeName");</span><span data-v-c2b1f83f="" class="line">renderer.DeletePlugin(node);</span><span data-v-c2b1f83f="" class="line">// or</span><span data-v-c2b1f83f="" class="line">renderer.DeletePlugin("myNodeName");</span><span data-v-c2b1f83f="" class="line">// or (but not recommended)</span><span data-v-c2b1f83f="" class="line">renderer.DeletePlugin(node.getName());</span></code>
Node.js <code data-v-c2b1f83f=""><span data-v-c2b1f83f="" class="line">var node = renderer.plugins['myNodeName'];</span><span data-v-c2b1f83f="" class="line">delete renderer.plugins['myNodeName'];</span><span data-v-c2b1f83f="" class="line">// or</span><span data-v-c2b1f83f="" class="line">delete renderer.plugins.myNodeName;</span><span data-v-c2b1f83f="" class="line">// or</span><span data-v-c2b1f83f="" class="line">delete renderer.plugins[node];</span><span data-v-c2b1f83f="" class="line"># or simply</span><span data-v-c2b1f83f="" class="line">node.deleteThis(); // node variable won't reference any plugin instance after this call</span></code>
Replacing plugin instances In some cases, you will want to use a new plugin instance in place of another that may be connected to multiple parameter slots. This is typical for changing materials or their textures, for example. To avoid having to set all the connections yourself, use the plugin replacement API. You can also use it to reset connections to null.
Python <code data-v-c2b1f83f=""><span data-v-c2b1f83f="" class="line">oldPlugin = renderer.plugins["oldMaterial"]</span><span data-v-c2b1f83f="" class="line">newPlugin = renderer.classes.MtlSingleBRDF("newMaterial")</span><span data-v-c2b1f83f="" class="line">newPlugin.brdf = renderer.classes.BRDFDiffuse("grayDiffuse")</span><span data-v-c2b1f83f="" class="line">oldPlugin.replaceWith(newPlugin)</span><span data-v-c2b1f83f="" class="line"># or</span><span data-v-c2b1f83f="" class="line">oldPlugin.replaceWith(None)</span></code>
C++ <code data-v-c2b1f83f=""><span data-v-c2b1f83f="" class="line">Plugin oldPlugin = renderer.getPlugin("oldMaterial");</span><span data-v-c2b1f83f="" class="line">Plugin newPlugin = renderer.newPlugin("MtlSingleBRDF", "newMaterial");</span><span data-v-c2b1f83f="" class="line">newPlugin.set_brdf(renderer.newPlugin("BRDFDiffuse", "grayDiffuse"));</span><span data-v-c2b1f83f="" class="line">renderer.replacePlugin(oldPlugin, newPlugin);</span><span data-v-c2b1f83f="" class="line">// or pass default constructed Plugin to reset to null</span><span data-v-c2b1f83f="" class="line">renderer.replacePlugin(oldPlugin, Plugin());</span></code>
C#.NET <code data-v-c2b1f83f=""><span data-v-c2b1f83f="" class="line">Plugin oldPlugin = renderer.GetPlugin("oldMaterial");</span><span data-v-c2b1f83f="" class="line">Plugin newPlugin = renderer.NewPlugin("newMaterial", "MtlSingleBRDF");</span><span data-v-c2b1f83f="" class="line">newPlugin.Brdf = renderer.NewPlugin("BRDFDiffuse", "grayDiffuse");</span><span data-v-c2b1f83f="" class="line">renderer.ReplacePlugin(oldPlugin, newPlugin);</span><span data-v-c2b1f83f="" class="line">// or</span><span data-v-c2b1f83f="" class="line">renderer.ReplacePlugin(oldPlugin, null);</span></code>
Node.js <code data-v-c2b1f83f=""><span data-v-c2b1f83f="" class="line">var oldPlugin = renderer.plugins["oldMaterial"];</span><span data-v-c2b1f83f="" class="line">var newPlugin = renderer.classes.MtlSingleBRDF("newMaterial");</span><span data-v-c2b1f83f="" class="line">newPlugin.brdf = renderer.classes.BRDFDiffuse("grayDiffuse");</span><span data-v-c2b1f83f="" class="line">oldPlugin.replaceWith(newPlugin);</span><span data-v-c2b1f83f="" class="line">// or</span><span data-v-c2b1f83f="" class="line">oldPlugin.replaceWith(null);</span></code>