DynamicKnobs

 v1.0

An example plugin that dynamically changes the knob set based on the contents of the text field.
Author
Jonathan Egstad
Created on: 26/08/2010
Updated on: 26/08/2010
Downloads: 129
Login or Register

This is an example plugin - the actual Op does nothing except hold the knobs.

The user can enter a list of parameters and their default values which are then parsed and used to construct knobs dynamically.  These knobs could then be used (for example) to drive a dynamically constructed shader.

 

A note to plugin writers:

Dynamic knobs are finicky and to aid in their management I've added a DynamicKnobManager class that attempts to clean up the plugin code and consolidates the state variables need to keep track of the knobs.  As is evident this is not a well fleshed-out part of Nuke's API and could use some love to help plugin writers out.

In particular there's three issues:

1) Upon Op construction the knobs are initialized using whatever value the knob that supplies the source text contains by default (in this case knob 'shader_code') but then the Op must know to update itself once a script loads and the knob is changed by 'from_script()'.  It's unclear when a knob is changed by script load or by user manipulation making this a dicey affair.  For example if the knobs simply rebuilt themselves avery time the source text changed this would dramatically slow down the user's ability to type into the text field as it would occur on every keystroke!  So being able to reliably identify the 'initialization' phase of a knob from the 'user interaction' phase would be very helpful.

2) The plugin writer must also store which knob the additional knobs are supposed to be added *after*, plus the current number of inserted knobs, plus whether the knobs have been loaded for the very first time.  This is a fair amount of state management that must be replicated properly in every plugin.

3) When the list of added knobs is changed (a knob is added or deleted,) the entire set of added knobs must be rebuilt, destroying whatever value they're currently set to.  The plugin writer must save the current values, build the new knob with its default value, then restore the current values.  This is a pain...

 

Hope this helps some plugin writers out,

-jonathan

Comments (1)

Dan Ring said:

...
Hey Jonathan,

thanks for this example, it's both concise and well written, and has helped me out a lot!

Dan.
March 01, 2012

Write comment
You must be logged in to post a comment. Please register if you do not have an account yet.

busy