
mental ray for Maya レンダラを使用してハードウェア シェーダをレンダーすることができます。mental ray for Maya はハードウェア シェーダを認識し、Lambert シェーダとして扱います。
この機能を使用すると、マテリアルを複製してハードウェア シェーダのソフトウェアのバージョンを作成してライト マップをベイク処理する必要がありません。これにより、シーン内にシェーダが多数ある場合、多数のオーバーヘッドが削除されます。
タイプ kPluginHardwareShader のすべてのシェーダはサポートされています。mental ray for Maya は、最初に、Lambert シェーダに予期されるパラメータ(カラー(Color)、透明度(Transparency)、拡散(Diffuse)など)のハードウェア シェーダをチェックします。予期されるパラメータが存在しない場合は、既定の Lambert の値が使用されます。
また、単純な MEL スクリプトを使用して、カスタム ハードウェア シェーダ パラメータに標準の Lambert パラメータを再マップすることもできます。これにより、カスタム シェーダの拡散マップと法線マップもサポートできます。
以下の例は、カスタム MEL プロシージャです。この例では、標準の Lambert パラメータは、MayaUberShader.fx を使用して、dx11Shader の同等のパラメータにマップされます。
global proc string[] dx11Shader_lambertParameters( string $node, string $params[] )
//
// Description:
// Custom MEL procedure invoked during a mentalray render to allow plug-in
// hardware shaders to participate as lambert shaders.
//
// This procedure allows the plug-in hardware shader an opportunity to map
// lambert attribute parameters to the equivalent hardware shader attribute(s).
//
// The function must exhibit the following characteristics:
//
// 1. Size of the returned string[] array must equal the size of the input $params[] array.
// 2. A string entry of "" will use the default lambert attribute name.
//
{
string $newParams[];
int $nParams = size($params);
int $i;
for( $i = 0; $i < $nParams; $i++ )
{
string $param = $params[$i];
// Default to the lambert attribute name. Also ensures we allocate an entry per lambert parameter.
$newParams[$i] = $param;
if( $param == "color" )
{
// Remaps the color attribute to the diffuse map on the dx11Shader (MayaUberShader.fx)
$newParams[$i] = "DiffuseTexture";
}
else if( $param == "transparency" )
{
// Remaps the transparency attribute to the diffuse map on the dx11Shader (MayaUberShader.fx)
$newParams[$i] = "Diffuse_Map_Transparency";
}
else if( $param == "normalCamera" )
{
// Remaps the normal attribute to the normal map on the dx11Shader (MayaUberShader.fx)
$newParams[$i] = "NormalTexture";
}
}
return $newParams;
}
カスタム MEL プロシージャでは、次の命名規則を使用します。
$shaderType + “_lambertParameters”
例: dx11Shader_lambertParameters
このコールバックは、シェーダ ノードのインスタンスごとに 1 回実行されます。
再マッピングした後、mental ray for Maya は、ハードウェア シェーダのアトリビュートを同等の Lambert アトリビュートとして解釈します。