Eyeon Talk:Script/Reference/Applications/Fuse/Fuse Reference Manual

From VFXPedia

< Eyeon Talk:Script | Reference/Applications/Fuse
Revision as of 12:46, 1 November 2012 by Tilt (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents


Documentation of additional events implemented by the Fuse API. This is not written by eyeon but by users, so it might not be completely accurate.

OnConnected()

As mentioned on the laffey list, there's also the OnConnected callback that gets called when connections are made to the Fuse's inputs (or to any upstream tool) (NotifyChanged will only be called when parameters change):

function OnConnected(link, old, new)
   if link == InInput1 then
       print("poop", old, new)
   end
end

InInput1 being the main image input in this example.


OnAddToFlow()

This event gets called when a Fuse has been added to the flow, before all OnConnected() and NotifyChanged() calls. Use it to set up run-time defaults that weren't possible in the Create() function:

  • In Create(), add INP_DelayDefault = true to the input as well as LINK_ForceSave = true. (-> Input Attributes)
  • Call SetAttrs({INP_Default = your_value}) once you know the default, for example by querying self.Comp or self.Comp:GetPrefs().

One example would be setting a slider's minimum and maximum allowed range to the current composition's global range or initializing width and height of a creator tool to the composition's format.

function OnAddToFlow()
	-- read default size from comp preferences
	local formatPrefs = self.Comp:GetPrefs("Comp.FrameFormat")
	InWidth:SetAttrs({ INP_Default = formatPrefs.Width })
	InHeight:SetAttrs({ INP_Default = formatPrefs.Height })
end

Also, OnAddToFlow() is the place for OpenCL fuses to initialize the OCLManager and call BuildCachedProgram().


CheckRequest(req)

This function will get called once or multiple times before Process(). Its parameter is the Request object for the request that is about to happen. The function will be called once for each priority level as defined by the INP_Priority attributes of the Fuse's inputs. The higher priorities will be called first and all inputs that have a lower priority won't be available yet. If an input doesn't have INP_Priority defined it will receive a priority of zero.

You can use this function to set an input to another value than what the user has declared in the GUI. This change will only be valid for the current request and will not be reflected in the interface. This is useful for diverting image inputs to something else in order to prevent the connected input branch from being rendered. For an example, see the Switch Fuse or the C++ SDK.

If a Fuse transforms an image, it needs to request data from its upstream input that lies beyond the current region of interest. CheckRequest() is the place where you need to modify the current request so Fusion renders the necessary data before calling your Process() function. This topic is covered in depth in the ROIDS Tutorial. You can also take a look at the clMerge Fuse that ships with Fusion or the Overscan and BetterCornerPin Fuses.

PreCalcProcess(req)

This function is used to tell Fusion about the expected image size, DoD and so on, before the actual Process() function is called. Usually, you don't need it, since a default implementation takes the main input image and passes it on to the main output. There are two cases, however, where custom PreCalc handling is necessary:

If you use additional (non-image) outputs, you need to handle the PreCalcProcess event yourself. (If you don't, tools connected to the additional outputs will fail). The other case is when the output image should have a different DoD than the input image, either because the image gets transformed or because there's a "Clipping Mode" option (as for example in the Blur tool) which crops or enlarges the DoD. The dashed DoD rectangle in the viewers, for example, is based on what Fusion has been told by PreCalcProcess(), not by the processed output image's DataWindow.

If it's too much work to duplicate image processing code from your Process() function, you can create your Fuse with the REG_NoPreCalcProcess attribute. This will call Process() instead of PreCalcProcess().

Head over to the PreCalc and Process tutorial for a more detailed explanation of the process.