Parameter Evaluation API

Parameter value querying from shaders. More...

Parameter Evaluation Macros

These macros evaluate a shader parameter of a specific type.

There is a different macro for each supported parameter data type. This is the version that users will want to invoke most often since it passes the current shader globals and node by default. For example:

enum LambertParams {
p_Kd,
p_Kd_color
};
{
AiParameterFlt("Kd", 0.7f);
AiParameterRgb("Kd_color", 1, 1, 1);
// note that parameter ordering must match the enum above
}
{
float kd = AiShaderEvalParamFlt(p_Kd);
...
}

Please refer to ai_shader_parameval.h for a description of the functions called by these macros.

Parameters
pidIndex in the shader's parameter enum list
Returns
Parameter value of the corresponding type. If the requested type doesn't match the parameter's true type, but the types are "link compatible", this query will silently perform the appropiate conversion; otherwise if the types are not compatible a value of zero (or the closest thing to 0 for the requested type, such as NULL or black) will be returned.
#define AiShaderEvalParamByte(pid)   AiShaderEvalParamFuncByte (sg,node,pid)
 
#define AiShaderEvalParamInt(pid)   AiShaderEvalParamFuncInt (sg,node,pid)
 
#define AiShaderEvalParamUInt(pid)   AiShaderEvalParamFuncUInt (sg,node,pid)
 
#define AiShaderEvalParamBool(pid)   AiShaderEvalParamFuncBool (sg,node,pid)
 
#define AiShaderEvalParamFlt(pid)   AiShaderEvalParamFuncFlt (sg,node,pid)
 
#define AiShaderEvalParamRGB(pid)   AiShaderEvalParamFuncRGB (sg,node,pid)
 
#define AiShaderEvalParamRGBA(pid)   AiShaderEvalParamFuncRGBA (sg,node,pid)
 
#define AiShaderEvalParamVec(pid)   AiShaderEvalParamFuncVec (sg,node,pid)
 
#define AiShaderEvalParamVec2(pid)   AiShaderEvalParamFuncVec2 (sg,node,pid)
 
#define AiShaderEvalParamStr(pid)   AiShaderEvalParamFuncStr (sg,node,pid)
 
#define AiShaderEvalParamPtr(pid)   AiShaderEvalParamFuncPtr (sg,node,pid)
 
#define AiShaderEvalParamArray(pid)   AiShaderEvalParamFuncArray (sg,node,pid)
 
#define AiShaderEvalParamMtx(pid)   AiShaderEvalParamFuncMtx (sg,node,pid)
 
#define AiShaderEvalParamEnum(pid)   AiShaderEvalParamFuncEnum (sg,node,pid)
 
#define AiShaderEvalParamClosure(pid)   AiShaderEvalParamFuncClosure(sg,node,pid)
 
#define AiShaderEvalParamOpacity(pid)   AiShaderEvalParamFuncOpacity(sg,node,pid)
 

Detailed Description

Parameter value querying from shaders.

If the parameter is linked to another shader, the child shader will be executed and its output will be returned.

This is the recommended mechanism for parameter evaluation inside a shader. Note that, for parameters that are not linked, the AiNodeGet* API (AiNodeGetInt(), etc) also returns the static value of the parameter. For both consistency and optimal performance, it is recommended to always use the AiShaderEvalParam* API described in this module.


© 2020 Autodesk, Inc. · All rights reserved · www.arnoldrenderer.com