ColladaMax 1.3 and Dx9 materials
I'm having difficulty in getting Collada fx information to output from the max exporter.
My test case was to set up a dx9 material (using any of the fx files installed with max 8 ) and apply it to a node in the scene trying both the with mixedFx option both on and off on the export dialog.
I managed to trace the problem down to the file MaterialExporter.cpp in member function: void MaterialExporter::AddMaterialNode(IGameMaterial* baseMaterial) in the following block of code:
863: IDxMaterial* dxm = static_cast<IDxMaterial*>(material->GetMaxMaterial()->GetInterface(IDXMATERIAL_INTERFACE));
864: if (dxm != NULL && dxm->GetEffectFilename() != NULL) colladaMaterial->isHLSL = true;
865: IGameFX* gameFX = material->GetIGameFX();
866: colladaMaterial->isHLSL = gameFX != NULL;
Stepping through it, everything seems to be in order until line 865 the call to GetIGameFX returns null so the material is not treated as HLSL.
I realise this is a IGame library call so may need to follow up with discreet but was wondering if anyone else came across this or knows of a solution?
Which are the .FX files installed with Max 8 did you use?
Many of them don't work with ColladaMax because ASHLI cannot parse them. The 'diffuseBump.FX' file is the only one that I trust. To get the ASHLI errors, you will have to use a debug build and check the debugger's output...
Thanks for the reply Guillaume,
I think I was a little unlucky in the fx files I tried initially (Wood.fx, hammerTime.fx and fur.fx), using your suggestion it did output the parameters. The debug information will help figure out what was causing problems with the ASHLI shader compiler on the fx files I tried earlier – is there any further information on incompatibilities between the compiler used in the material dialog and the exporter? The only other issue was that I expected the information to be under a ‘profile_HLSL’ or ‘profile_CG’ in library_effects?
I understand this is still work in progress, what are your thoughts on making errors like the shader compiler failure reported to the user and failing the export? It’s quite likely this is something that’s easily missed and causes unexpected results further on in a pipeline unless the user checks the output each time. Possibly message boxes depending on the silent mode flag used elsewhere in the max API and logging to the listener.
This is the major difference between the Material Editor compiler and the exporter, with respect to the DX9 material. It's the 3DXI library that outputs the debug information from ASHLI: not ColladaMax. I don't know if there is a way to bring this information to the user's attention: although I wish I could.
Do you/does anyone know a way to overwrite the target stream for the OutputDebugString Win32 function?
About the exported format: I don't believe there will be a HLSL profile. HLSL provides the exact same information that ColladaFX does. Instead, we use nVidia's proposed <import> mechanism to expose the filename of the HLSL file and we use the <instance_effect> element to expose the modified/modifiable parameters. Autodesk M&E has mentioned CG support in the past, we'll have to wait until they have it before we can really support ColladaFX in 3dsMax.