To extend my experiments with PixelBender, I created a new class to compliment my ShaderNode class - ShaderEditor. An instance of a ShaderEditor class accepts a ShaderNode and dispatches ShaderEditorChangeEvents. It is the user interface component that allows a user to set the parameters of a PixelBender object.

When the ShaderEditor's shaderNode is set, I loop through the parameters and create input fields that happen to have the same names as those parameters. The input boxes dispatch ShaderEditorChangeEvent events on each change.

The ShaderEditorChangeEvent contains the parameter name and the new value, and ShaderNode now has a new method setParameterByName(), so an event handler should look something like this:

private function shaderChangeHandler(event:ShaderEditorChangeEvent):void
{
ShaderEditor(event.target).shaderNode.setParameterByName(event.shaderParameterName, event.shaderParameterValue)
}

This demo is fugly and there is no validation, but it is a great proof of concept. It daisy chains a pixelate, smudge and twirl together - the twirl is proof that my editors can handle more than one parameter. Here's the demo - with source code enabled.

simon gladman
0

Add a comment

About Me
About Me
Labels
Labels
Blog Archive
Loading