Eyeon:Script/Reference/Applications/Fuse/Classes/ViewShader

From VFXPedia

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

Parent Class: None

The ViewShader object encapsulates a Cg shader program string, and a number of exposed, run-time parameters. It should be created by the ScriptViewShader:SetupShader() function, and is freed automatically when ScriptViewShader:FreeShader() is called. The created ViewShader is passed to ScriptViewShader:SetupParams() every redraw so that any run-time parameters can be set.

Details on programming Cg shaders can be found at nVidia's developer site.


Contents

Constructor:

ViewShaderConstructs a new ViewShader object

Methods:

AddParamExposes a run-time parameter in the shader
SetParamSets the value of a run-time parameter

Members:

NameThe name of the ViewShader-derived struct
StringThe Cg shader program string
LenThe length of the shader program string
ParamNameA table of run-time parameter names

Example:

Example of constructing a ViewShader object from a Cg program in "shaderstring":

local vs = ViewShader("GammaFuse", shaderstring)


The Shader String

The Cg shader string used to construct a ViewShader object consists of a definition of a struct derived from the ViewShader baseclass. This struct must contain a ViewShader member object called 'source', and must implement the ShadePixel() function. It can also contain other data members, which may be exposed with AddParam and set with SetParam.

Methods:

ShadePixelCalled to process each pixel

Examples

This is an example of a simple gamma shader program:

shaderstring = [[
 
struct GammaFuse : ViewShader
{
    ViewShader source;	                        // need this line
    float gamma;                                // run-time parameter
 
    void ShadePixel(inout FuPixel f)            // required ShadePixel() function
    {
        source.ShadePixel(f);                   // get source pixel
 
        f.Color.rgb = pow(f.Color.rgb, gamma);  // apply simple gamma
    }
};
 
]]

See Also:


Tips for ViewShader (edit)

EyeonTips:Script/Reference/Applications/Fuse/Classes/ViewShader