RenderableNode::SetShaderParameterCallback
Defined in:
Sets the shader parameter callback function.
C4Node.h
Prototype
void SetShaderParameterCallback(ShaderParameterCallback *callback, void *cookie = nullptr);
Parameters
callback |
A pointer to the shader parameter callback function. |
cookie |
The cookie that is passed to the callback function as its last parameter. |
Description
The SetShaderParameterCallback
function installs a callback function on a renderable node that provides the location of mutable shader parameters. Each time a new shader is compiled for the node, the callback function is invoked for each mutable parameter, and the callback function may return a pointer to an array of four floating-point numbers where the value of the parameter is stored. The ShaderParameterCallback
type is defined as follows.
typedef const void *ShaderParameterCallback(Type type, void *cookie);
type
parameter passed to the callback function specifies the type of parameter data to return. If the value of type
is in the range [0, kMaxShaderConstantCount
), then it represents a slot number used by one of the scalar, vector, or color processes in the shader, and the callback function should return the corresponding data. The cookie
parameter is the value previously passed to the SetShaderParameterCallback
function. If the callback function returns a pointer to a parameter, then the four floating-point values must remain allocated for the lifetime of the node or until the Renderable::InvalidatePipelineData
function is called. If the callback function returns nullptr
, then the parameter value is taken from the material object containing the shader.The parameter values at the location returned by the callback function may be changed at any time, and the new values will automatically be used the next time the node is rendered. It is not necessary to perform any updates or invalidation.