アドバンスモードに変更する必要があります。
shaderFXエディターで右クリック、tools>toggle Advance Modeを
選択してアドバンスモードに変更します。
アドバンスモードに切り替えると使用できるノードとグループの展開が
可能になります。グループに四角いアイコンが追加されるのでクリックすると
グループが展開できるようになります。
HwShaderNodes>various>Custom codeでノードを作成します。
customCodeNodeのアトリビュートのeditボタンでコードを編集する
ウィンドウが表示されます。
こちらからサンプルファイルがダウンロードできます。
◇ShaderFX
サンプルの様にテクスチャーをカラーとして扱うときはいいのですが、
テクスチャーをUniform変数として渡したい時があります。
下記はそのやり方です。
https://gist.github.com/hiko9lock/11342282
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct CustomCode1245Output | |
{ | |
float3 color; | |
}; | |
CustomCode1245Output CustomCode1245Func( float2 UV ) | |
{ | |
CustomCode1245Output OUT; | |
float3 output= float3(0.0, 0.0, 0.0); | |
float dist= 0.004; | |
int radius= 4; | |
for( int i= -radius; i< radius; i++ ) { | |
for( int j= -radius; j< radius; j++ ) { | |
output+= tex2D( SFX_SAMPLER0, UV+float2(i*dist, j*dist)).xyz; | |
} | |
} | |
OUT.color= (output/((radius+1)*(radius+1))); | |
return OUT; | |
} |
Texture,Sampler Stateが必要となります。
HwShaderNodes>Texture>Texture Component
HwShaderNodes>Texture>Sampler Stateでノードを作成して
Custom CodeノードのTexture,SamplerStateに接続します。
また、カスタムコード関数の引数にfloat2 uvを指定しているので
HwShaderNodes>Inputs common>UV Setでノードを作成して
Custom Codeノードのuvに接続します。
14行目の
output+= tex2D( SFX_SAMPLER0, UV+float2(i*dist, j*dist)).xyz;ですが、これはCGFX用の書き方となり、SFX_SAMPLER0は
指定されたuniform変数となります。
すべての環境をサポートするにはifステートメントを使用する必要
があります。詳しくはヘルプ参照で。
◇Maya2015オンラインヘルプ
shaderFXカスタムコードノード
今回作成したカスタムシェーダーをplaneに適用させたものになります。
customCodeでフィルター処理もできるので、シェーダー作成も
面白くなりそうですね。