Eyeon:Script/Reference/Applications/Fuse/Classes/ViewShader
From VFXPedia
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:
ViewShader | Constructs a new ViewShader object |
Methods:
AddParam | Exposes a run-time parameter in the shader |
SetParam | Sets the value of a run-time parameter |
Members:
Name | The name of the ViewShader-derived struct |
String | The Cg shader program string |
Len | The length of the shader program string |
ParamName | A 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:
ShadePixel | Called 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