Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® MotionBuilder® / Open Reality / cgfx and scripts in MotionBuilder?
  RSS 2.0 ATOM  

cgfx and scripts in MotionBuilder?
Rate this thread
 
56426
 
Permlink of this thread  
avatar
  • simt
  • Posted: 31 May 2011 05:19 PM
  • Total Posts: 4
  • Joined: 07 May 2010 03:31 AM

Hi,
I’ve started on writing cgfx shaders for use with Motionbuilder’s built in KOGLCgFxShader.
And I’m coming across a few issues. The current issue is in scripts for the techniques.
A script can be used for looping a pass. But I can’t get it to properly work in Motionbuilder.
My (relevant) code looks like this:

float furLayers
<
 
string UIWidget "slider";
 
float UIMin 1;
 
float UIMax 100;
 
float UIStep 1;
 
string UIName "furLayers";
> = 
1.0;

float currentCount string UIWidget="None";>;

vertexOutput VS_TransformAndTexture_loop(vertexInput INuniform float furLayersuniform float currentLayer 
...rest of code }

float4 PS_Textured_loop
vertexOutput INuniform float furLayersuniform float currentLayer ): COLOR
...rest of code }

technique Fur_Multi_Layer
 
<
 
string ScriptClass "object";
 
string ScriptOrder "standard";
 
string ScriptOutput "color";
 
string Script =
         
"LoopByCount=furLayers;"
     "LoopGetIndex=currentCount;"
     "Pass=Shell;"
         "LoopEnd=;"
;
 >
{
    pass Shell
    {
 VertexShader 
compile vp40 VS_TransformAndTexture_loopfurLayerscurrentCount );
 
PixelShader  compile fp40 PS_Textured_loopfurLayerscurrentCount );
    
}
}
//End technique Multi_layer_fur

The user can interactively set the number of furLayers to render, and the script in the technique will loop the ‘Shell’ pass by that number sending in to each instance of the shaders the variables ‘furLayers’, ‘currentCount’.
The “LoopByCount=furLayers;” line works, and I am getting looping. However the “LoopGetIndex=currentCount;” line doesn’t work. currentCount is supposed to increment up each iteration of the loop, but it’s staying static. My shader does work if I hard code all the passes instead of using a script.

I’m hoping there’s a mistake in my code that someone here could point out. Much worse would be if Motionbuilder is buggy in supporting this feature.

Also I can’t find anywhere what version of cg Motionbuilder 2012 supports. I know Motionbuilder 7 supported cg 1.4.  cg 3.0 came out July 2010 and I’m guessing MotionBuilder 2012 support is somewhere in between.

For cgfx in Motionbuilder where can I find a list of the cgfx semantics that Motionbuilder uses?

‘regards
Simeon.



Replies: 0
avatar
  • qhliao
  • Posted: 14 August 2011 04:57 AM

I think MoBu2012 used Cg3.0. However their semantics support are pretty limited, definitely no script support as you tried to achieved.




Replies: 0