A Fuse You Can Use

Hey all, long time no see. This will be a technical post and is meant for users of a wonderful software known as Fusion. No i'm not talking about Saddam and his alleged plot to nuke the world. We in the visual effects community use Fusion for a lot of techno-creative work and one of the things that you can do in Fusion is to write your own code, appropriately known as a Fuse.


This is my first and very basic attempt at writing a Fuse plug and was based on a discussion with my close colleague Deepak Dhawan, who heads the QE wing within our organization. Deepak was on the lookout for a way to switch multiple input streams/node trees to a single output. Such a functionality is seen in the Switcher node in Houdini and so I decided to give it a shot and attempt to write a Fuse plugin. Let me point out that you can attempt similar functionality by a combination of Dissolve nodes and a few expressions.


There are some macros available out there which use a concoction of Dissolves however call me plain old fashioned mad, but I like to script/program.


The first attempt produced a working prototype that switched between 4 channels but had a tiny flaw which required all four streams to be available or else the node would fail. A quick query and response from Chad Capeland and further pointers from Daniel Koch (eyeon) fixed the bug and here's the Fuse. Just copy paste the text, drop it in a file, call it Switcher.fuse and place the file gently in Fusion5.3/Fuses/eyeon/

--[[-- Switcher 1.0 by Sachin B [mailme@sachinbhatnagar.com] This node switches between 4 input streams to a single output. Just connect upto 4 input trees/nodes and flick the switch.
Drop this file in X:Program FilesFusion 5.3 Fuseseyeon --]]-- FuRegisterClass("Switcher", CT_Tool, { REGS_Name = "Switcher", REGS_Category = "Fuseseyeon", REGS_OpIconString = "Swtch", REGS_OpDescription = "Switcher", REG_OpNoMask = true, REG_NoBlendCtrls = true, REG_NoObjMatCtrls = true, REG_NoMotionblurCtrls = true, })
function Create() InImage = self:AddInput("Input1", "Input1", { LINKID_DataType = "Image", LINK_Main = 1, INP_Required = false, }) In2Image = self:AddInput("Input2", "Input2", { LINKID_DataType = "Image", LINK_Main = 2, INP_Required = false, }) In3Image = self:AddInput("Input3", "Input3", { LINKID_DataType = "Image", LINK_Main = 3, INP_Required = false, }) In4Image = self:AddInput("Input4", "Input4", { LINKID_DataType = "Image", LINK_Main = 4, INP_Required = false, }) InSwitch = self:AddInput("Switch", "Switch", { LINKID_DataType = "Number", INPID_InputControl = "MultiButtonControl", INP_Default = 0, {MBTNC_AddButton = "1", MBTNCD_ButtonWidth = 1, }, {MBTNC_AddButton = "2", MBTNCD_ButtonWidth = 1, }, {MBTNC_AddButton = "3", MBTNCD_ButtonWidth = 1, }, {MBTNC_AddButton = "4", MBTNCD_ButtonWidth = 1, }, }) OutImage = self:AddOutput("Output", "Output", { LINKID_DataType = "Image", LINK_Main = 1, }) end
function Process(req) local switch = InSwitch:GetValue(req).Value if switch == 0 then local img = InImage:GetValue(req) img:Use() OutImage:Set(req, img) else if switch == 1 then local img2 = In2Image:GetValue(req) img2:Use() OutImage:Set(req,img2) else if switch == 2 then local img3 = In3Image:GetValue(req) img3:Use() OutImage:Set(req,img3) else if switch == 3 then local img4 = In4Image:GetValue(req) img4:Use() OutImage:Set(req,img4) end end end end end

© SACHIN BHATNAGAR

  • Look me up on Facebook
  • I tweet too!
  • Connect with me on LinkedIn
  • Food and Life on Instagram