Eyeon:Script/Reference/Applications/Fuse/Classes/ViewShader/AddParam
From VFXPedia
Contents |
Summary
The AddParam function is used to expose run-time parameters in the shader.
In addition to the 'ViewShader source' data member, the struct derived from the ViewShader baseclass in the shader string may also contain other data members, which can be exposed as run-time parameters. To do this, call AddParam(name), where name is the name of the data member to be exposed. This is typically done when the ViewShader object is created, in ScriptViewShader:SetupShader().
Once exposed, the value of the run-time parameter can be set with SetParam(), typically when ScriptViewShader:SetupParams() is called. Various data types are supported, including numbers, booleans, vectors, 4x4 matrices and images.
Usage
index = AddParam(string name)
name (string, required)
- The name of the data member in the ViewShader struct that is to be exposed.
Returns
AddParam() returns the index of the exposed parameter. This will usually be an ordinal starting from 1.
Example
This example fetches a shaded pixel from the source and applies a simple gamma.
-- 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
Tips for AddParam (edit)
EyeonTips:Script/Reference/Applications/Fuse/Classes/ViewShader/AddParam