Making Rendermonkey .fx export SAS (Microsoft) compliant

I did a quick trial’n’error step by step recognition on this one for my own work in progress / learning purposes.
I thought some other tech artists might fancy seeing this shared around as well :cool:

When you export your stuff to fx format : it doesn’t run as it is in the DXviewer.

That’s because it needs some SAS bananas (the Mircosoft one “version 1.1.0” not the Nvidia one “version 0.8”).
So here is what I found :


// Add a global parameter with the script version :

int sas : SasGlobal
<
	bool SasUiVisible = false;
	int3 SasVersion= {1,1,0};
>;

// Add the proper transformation matrices names
// and their data bindings to make DXviewer happy :

float4x4 matWorld : World
<
	bool SasUiVisible = false;
	string SasBindAddress= "Sas.Skeleton.MeshToJointToWorld[0]";
>;

float4x4 matView : View
<
	bool SasUiVisible = false;
	string SasBindAddress= "Sas.Camera.WorldToView";
>;

float4x4 matProjection : Projection
<
	bool SasUiVisible = false;
	string SasBindAddress= "Sas.Camera.Projection";
>;

In your vertex shader you’re probably multiplying position with the “matViewProjection” matrix.
(which is reckonned as “predefined” Semantic by R-monkey but somehow isn’t talking “DXviewer’s language”).


//So you need to split this from :

Output.Position = mul( Input.Position, matViewProjection );

//into :

Output.Position = mul( Input.Position, mul(matWorld, mul(matView, matProjection)));

Basically using the matrices you’ve declared previously in a slightly more decomposed fashion.

You should now have the beast not yelling “Reverting to the default effect.” anymore.
If you only see a black ball your textures are missing.


// You need to switch variables from this :

texture my_rendermonkey_texture
<
  string ResourceName = "C:\\bla.dds";
>;

// to something like this :

texture my_microsoft_texture
<
  string SASResourceAddress = "C:\\bla.dds";
  bool SasUiVisible = false;
>;

Et voila!:D:
Please feel free to add more of your findings if I missed anything else required.

Btw : some shader syntax coloring would be nice when posting code blocks : they seem to have a way to do this cool thing on XNA forums.

You have trouble using sas 0.8 in XNA?
What parts?

I’ve ran many 0.8 shaders in XNA without problems, so I am curious what parts don’t work…

thanks!

Well that’s a good point : I didn’t know that XNA was just handling sas 0.8
In fact I just started to have a look at the latest release 3.0 yesterday.

I’ve done very little C# before and as I’m not a programer it would cost me a lot of time to learn more : however it seems to be quite simplified and open to “code newbies” (like me :p:) : Microsoft wants to attract as many students as possible to use their Visual Studio “Express” products so there’s a cool community and plenty of tuts for beginners to start your own game…

I just thought that things were more “DXSDK-centric” and when I did some experiments with FXcomposer/Rendermonkey I’ve always been disapointed by double clicking on the .fx file and not being able to just see it in the DXviewer : which would be quite handy if I want to show it to somebody without requiring him to have my whole project setup on his machine.

Actually : the best would be to export a .exe straight out of R-monkey or FXC : that would be lovely (they should add that feature just like Blender does)

I think I’ll start by pluging my .fx to a very simple basic XNA template app…

oh and XNA 3.0 has full latest FBX support as well : sounds exciting ! :D:
Sounds like some cool pipeline to look at for tech artists to bridge with Max/Maya.

But I’m not sure if XNA is actually widely used in production (maybe only for 360 quick small projects?) : hardcore programers just use C++ instead…