Ok, so after messing around with MAX and the Direct X viewer quite a bit and scratching my head a lot here's what I've figured out:
SAS is a new standard to pass transformation matrices and other parameters between an application and an effect FX file. There are other standards around and 3DS MAX 7 is using one of them.
I managed to hack an existing .FX file to make it compliant with both 3DS MAX and SAS. In MAX this file can be used in a "Direct X 9 Shader"-type material. If everything goes well you will be able to set the colour values for 'light specualr", "material ambient", "material diffuse" and other parameters in the material. Those are custom parameters in the FX file that MAX understand, and also the X file and the Direct X viewer that I used to render the file.
When selecting "Include .FX file" and "Include .FX parameters" in Pandasoft exporter, the "Direct X 9 Shader" materials are exported as effect instances, and the custom parameters are exported too in the .X file with their name and value. The actual .FX files need to be in the same directory as the .X file, pandasoft doesn't copy tehm for you.
Thanks to the custom parameters the effects do not need to be hard-coded. This allows us to reuse the .FX files between materials (for instance we can have a red cel-shaded material and a blue one that use the same effect file but have different parameters for the diffuse colour.), and that's pretty neat... I think that the goal here is to have programmers write customizable effects and let the artists use them and see the results directly in their modeling program.
I exported a simple scene with a teapot and the toon shader that I modified, you can find it here:
http://www.adonf.org/wme/toon_teapot.rarThe .X file is in text format. The most interesting part is around line 8988, that's where the custom parameters are passed by name to the .FX file.
Here's a custom material parameter called "I_s" in the .X file:
EffectParamFloats {
"I_s";
4;
0.600000,
0.600000,
0.600000,
1.000000;
}
and here's its counterpart in the .FX file:
float4 I_s
<
// parameter information for DX SAS
string SasUiLabel = "light specular";
string SasUiControl = "ColorPicker";
// parameter information for 3DS MAX
string UIName = "light specular";
> = { 0.6f, 0.6f, 0.6f, 1.0f }; // default value
I'm not actually sure that we need the SAS-style definitions here. But where we
do need them is for the transformation matrices and lights, see line 70 for an example of how the effect fetches the light direction from the application.
Well I hope that you can do something with that. So maybe soon we'll all have fancy 3D effects like water ripples or reflexions in our games
Thanks, and let me know if there's any way that I can help...
Olivier