Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Depending on whether the input parameter is the default value, or a constant value or a connection, the call to EvalParam() will either return a pointer to storage containing a single value or an entire numPts worth of values. This can be changed by setting the optional parameter promoteToVarying to be true, in which case the storage for the result will be guaranteed to be an entire numPts worth of values; however, this does not alter the return value. This storage is allocated by the renderer and has a lifetime associated with the shading context; it does not need to be managed by the caller.

The return value of EvalParam is a value of RixSCDetailk_RixSCUniform indicating that the input parameter was uniform (a constant or default value) or k_RixSCVarying indicating the parameter was varying (a connection). If the value cannot be found (typically because it does not have the correct matching type, i.e. the wrong version of EvalParam was used) then k_RixSCInvalidDetail will be returned.

In some circumstances, users of EvalParam() that do not know the paramId (perhaps due to the use of a dynamic parameter table) or the type of the parameter can introspect for the paramId or information about the parameter via the GetParamId() and the GetParamInfo() methods.  

Some examples for reading different types of input parameters are shown below.

    // Read a uniform integer value, and store the result in the
    // RtInt noiseType variable. m_noiseType is a PxrCustomNoise
    // member variable that contains the default noiseType value.
    RtInt *noiseTypePtr;
    sctx->EvalParam(k_noiseType, -1, &noiseTypePtr, &m_noiseType, uniform);
    RtInt const noiseType(*noiseTypePtr);

    // Read a varying float value for the threshold input parameter.
    // m_threshold is a PxrCustomNoise member variable that contains
    // the default value.
    RtFloat *threshold;
    sctx->EvalParam(k_threshold, -1, &threshold, &m_threshold, varying);

    // Read one value from a varying float[2] array.
    RtFloat *repeatUV0, *repeatUV1;
    sctx->EvalParam(k_repeatUV, 0, &repeatUV0, &m_repreatUV, varying);
    // Read the other value from a varying float[2] array. Note that
    // the arrayIndex parameter is set to 1 to read the second value.
    sctx->EvalParam(k_repeatUV, 1, &repeatUV1, &m_repreatUV, varying);

    // Read in a float[3] array of values into a RtFloat3 variable.
    RtFloat3 *scale;
    sctx->EvalParam(k_scale, -1, &scale, &m_scale, varying);

    // Read in a varying color value.
    RtColorRGB* defaultColor;
    sctx->EvalParam(k_defaultColor, -1, &defaultColor, &m_defaultColor, varying);

Anchor
allocate
allocate
Memory Management

...