マテリアルが複数のオブジェクトによって共有されている場合、テクスチャ プロジェクションを持つアタッチされたシェーダにシェーダ インスタンス データがあると考えられます。このインスタンス データを使用すると、マテリアルを共有する各オブジェクトに対してどのテクスチャ プロジェクションを使用すべきか、シェーダに指定することができます。
インスタンス データ値を直接参照できるシェーダ コードを記述することができます。このためには、角括弧の間に tspace_id パラメータの名前を指定します。たとえば、[MyRTSNodeThatHasATexture.tspace_id]のようになります。tspace_id が現在のリアルタイム シェーダ ツリーにある場合、[GLSLProgram]ノードのハードウェア属性マッピング テーブルには、便宜上 tspace_id が属性として一覧表示されます。

ハードウェア属性マッピング テーブルは以下のようになります。

[GLSLProgram]シェーダは[OGLTexture]シェーダの tspace_id を参照し、その tspace_id に指定されているテクスチャ プロジェクションを、texcoord0.xyz という名前のテクスチャ座標ハードウェア レジスタにマッピングします。
// Example of a custom realtime shader that uses hardcoded hardware mapping
extern "C" RTSHADER_API XSI_RTS_Attribute* MyNormalMapShader_GetAttributeList
(
IRTSExecutionState *in_pExecState,
MyNormalMapParameters_t *in_pParams,
void **io_pInstanceData
)
{
// This shader needs vertex position and normals and 1 texture projection.
// The texture projection must be an existing parameter
// attached to the shader tree. In this example, the parameter
//called 'OGLTexture.tspace_id'
char * l_szNormalShaderDataNeeded = "PointPosition,position.xyz,PointNormal,normal.xyz,[OGLTexture.tspace_id],texcoord0.xyz";
// The RTS 3.0 architecture expects an array of XSI_RTS_Attributes, you can use the
// GetAttributeDescriptorFromMapping API provided by the ExecutionState to create this structure for you.
XSI_RTS_Attribute* dataNeeded = in_pExecState->GetAttributeDescriptorFromMapping ( l_szNormalShaderDataNeeded );
return dataNeeded;
}
// Example of a custom realtime shader that uses ui-assisted hardware mapping
XSI_RTS_Attribute g_MyNormalMapShader_HardCoded_Attributes[] =
{
XSI_RTS_ATTRIBUTE_POSITION, ePOSITION,
"PointNormal", eNORMAL,
"Texture_Projection", eTEXCOORD0,
0, eMAX_STANDARD_VERTEX_ATTRIBUTE
};
extern "C" RTSHADER_API XSI_RTS_Attribute* MyNormalMapShader_GetAttributeList
(
IRTSExecutionState *in_pExecState,
MyNormalMapParameters_t *in_pParams,
void **io_pInstanceData
)
{
// A parameter on the PPG drives which attributes are needed to execute the shader
if ( in_pParams->MyShaderTechnique == HighRes )
{
return in_pExecState->GetAttributeDescriptorFromMapping ( in_pParams->MyHardwareMappingWidget );
} else{
return g_MyNormalMapShader_HardCoded_Attributes;
}
}