Eyeon:Script/Reference/Applications/Fuse/ViewShader/Events/SetupShader

From VFXPedia

< Eyeon:Script | Reference | Applications | Fuse
Revision as of 04:12, 5 November 2009 by Daniel (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

ViewShader Reference Manual > SetupShader

Event Function


Contents


Summary

The SetupShader event is called when Fusion needs to rebuild the display view's LUT shader chain, for example when the user changes the selected LUTs.

The fuse should construct a ViewShader object, giving it a Cg shader program in a string, then add any run-time parameters that will be passed to the shader, and return the object. A Request object containing the current control settings is passed in, along with the image being displayed (which may be nil), if required.

Usage

SetupShader(object request, object image)

Arguments

request (request object)

A Request object containing the current control values.

image (Image object)

The source image that will be given to the shader

Returns

The function should return a freshly-created ViewShader object.

Examples

-- Here's the Cg shader itself:
shader = 
[[
struct GammaFuse : ViewShader
{
    ViewShader source;	                        // need this line
    float gamma;                                // run-time parameter
 
    void ShadePixel(inout FuPixel f)
    {
        source.ShadePixel(f);                   // get source pixel
 
        f.Color.rgb = pow(f.Color.rgb, gamma);  // apply simple gamma
    }
};
]]
 
-- This is called when the shader is created
-- img may be nil
function SetupShader(req, img)
    local vs = ViewShader("GammaFuse", shader);   -- pass struct name and shader string
 
    gammaparam  = vs:AddParam("gamma");           -- expose our run-time gamma parameter
 
    return vs;
end

See Also