The constraints for manual parameter translation are similar to those of automatic parameter translation. The names and parameter structures no longer have to match, but the types must still match.
The parameters must be translated into the parameter block of the shader. This parameter block is accessed through imrShader::GerParametersParamBlock(). The structure of this parameter block matches that of the mental ray shader as declared in the .mi file. The types of parameters contained in this parameter block are as follows:
When doing manual translation, make sure you lookup the parameters by name and not by parameter ID, since the parameter IDs are not necessarily in order. To get a parameter ID from a parameter name, you may use the following function:
bool GetParamIDByName(ParamID& paramID, const TCHAR* name, IParamBlock2* pBlock) { DbgAssert(pBlock != NULL); int count = pBlock->NumParams(); for(int i = 0; i < count; ++i) { ParamID id = pBlock->IndextoID(i); ParamDef& paramDef = pBlock->GetParamDef(id); if(_tcsicmp(name, paramDef.int_name) == 0) { paramID = id; return true; } } DbgAssert(false); return false; }
The parameter ID will be returned through the "paramID" reference parameter. The function will return false if no parameter was found with the given name.