FBX improvements in XNA Game Studio 3.0

FBX improvements in XNA Game Studio 3.0

  • Comments 20

One of the less obvious changes in our 3.0 release is that we picked up an updated version of the FBX SDK from our partners at Autodesk, which enables some cool new functionality in our FBX importer:

  • Multiple textures
  • Multiple texture coordinate channels
  • Effect materials
  • Material name strings are now imported correctly

To use this stuff, you first need to make sure you have the latest version of the Max or Maya FBX exporters.

Now create a material that uses more than one texture. For instance I used Max to apply a diffuse texture map, specular map, and bump map. Here's how that data shows up when I read it with our 3.0 FBX importer:

    <Resource ID="#Resource1" Type="Graphics:BasicMaterialContent">
      <Name>ShawnsTestMaterial</Name>
      <OpaqueData>
        <Data Key="DiffuseColor" Type="Framework:Vector3">0.5 0.5 0.5</Data>
        <Data Key="EmissiveColor" Type="Framework:Vector3">0 0 0</Data>
        <Data Key="Alpha" Type="float">1</Data>
        <Data Key="SpecularColor" Type="Framework:Vector3">0 0 0</Data>
        <Data Key="SpecularPower" Type="float">1.9</Data>
      </OpaqueData>
      <Textures>
        <Texture Key="Texture">
          <OpaqueData>
            <Data Key="TextureCoordinate">TextureCoordinate0</Data>
          </OpaqueData>
          <Reference>#External1</Reference>
        </Texture>
        <Texture Key="SpecularFactor0">
          <OpaqueData>
            <Data Key="TextureCoordinate">TextureCoordinate0</Data>
          </OpaqueData>
          <Reference>#External2</Reference>
        </Texture>
        <Texture Key="Bump0">
          <OpaqueData>
            <Data Key="TextureCoordinate">TextureCoordinate1</Data>
          </OpaqueData>
          <Reference>#External3</Reference>
        </Texture>
      </Textures>
    </Resource>

See those extra two textures? See how the TextureCoordinate opaque data records which coordinate channel goes with each one?

The bad news is that if you load and draw this model in the usual way, these extra textures will not actually show up. That is because BasicEffect has no idea how to apply specular or bump maps, so the default material processor will just throw them away.

To render this kind of richer material, you must provide a suitable shader, then use a custom processor to apply it to your model. The improvement is that in 3.0, such processors now have more information about how the original material was set up in Max or Maya. With sufficient smarts, you could make a processor that examined the material to see which of many possible texture layers were present, chose the best fit from a set of shaders, then automatically applied the appropriate shader, passing all the correct textures through to it.

A more automated approach for using custom shaders comes into play if you apply a Direct3D material directly to your object in Max (I believe this is not currently supported by Maya). This now works in FBX the same way it previously did with X files. You can export an FBX file that uses a custom D3D effect as a material, import this into the Content Pipeline, where the material will show up as an EffectMaterialContent, then load it into your game, where the material will come through as an instance of your custom Effect already configured with the appropriate textures and parameter values.

This kind of thing makes me a happy chappie.

Go Autodesk!

  • Shawn, Would you please tell what version of the FBX format should be used for export from Max - 2006.11 or 2009.1?

  • Shawn,

     I use Blender (it's free so it fits my hobby budget perfectly) and have been using the FBX exporter from Blender to get models to use in XNA 2.0.  Do you know if anyone has tried it with the 3.0 importer?

  • > Would you please tell what version of the FBX format should be used for export from Max - 2006.11 or 2009.1?

    You should use the 2009 version. Either will work, but if you use the 2006 release, you won't get any of these new features.

  • > I use Blender (it's free so it fits my hobby budget perfectly) and have been using the FBX exporter from Blender to get models to use in XNA 2.0.  Do you know if anyone has tried it with the 3.0 importer?

    We've done as much testing as we could with as many FBX files as we could find, but it's impossible for us to be 100% certain we covered everything in an area as wide open as this!

    My expectation is that FBX files exported from Blender should still work just the same as they used to, but these new material features will not show up until/if someone adds them to the Blender exporter.

    If you have worries about this, now would be a great time to try things out with the 3.0 beta version of the importer, and let us know via Connect if you run into any problems...

  • Actually Maya supports HLSL shader as well as CgFx shader.  You just need to turn on this plug-in in your setting, and then you will see HLSL shaders working in Maya.

    The only problem is that Maya FBX Exporter from AutoDesk doesn't export HLSL shader, which is odd since new FBX SDK supports both CgFx and HLSL shaders.  Anyways, at this moment 3DS Max only exports HLSL shader(not CgFx) to FBX, and Maya only exports CgFx shader(not HLSL) to FBX.

    I was hoping that XNA 3.0 would provide Maya FBX exporter that supports HLSL shader.  I guess that's not the case?

  • The XNA Game Studio team is not in the business of writing modelling tools or exporters: that side of things comes from our partners such as Autodesk.

    It's actually possible that you might have some luck authoring Cg shaders in Maya, then converting these to HLSL in a processor. You should still be able to access the data in your processor, although it would have to do some fixups to replace the Cg shader with a suitable HLSL equivalent. The two shader systems are very similar, though, so this might be viable as a way of authoring the data, setting up your parameter bindings, etc.

  • I've been banging at trying Maya + HLSL to FBX for an hour or so.  The best method will probably be the hack method Shawn has suggested, or using the FBX API and Maya API to extend the FBX exporter in maya.  You could make a plugin that acts as a second pass to the current FBX exporter, and fills in the shader details based on the HLSL shader node.

    Personally I think the XNA team needs to start applying some additional pressure to get the Maya exporter updated to support the HLSL shader nodes :-)

  • I want to share this good news!

    A couple months ago, I asked Autodesk to support HLSL export from Maya.  And today I got the confirmation that it will be supported before XNA 3.0 is out.  Here is the forum thread.

    http://area.autodesk.com/index.php/forums/viewthread/14945/#84278

  • Some of the built in Max shaders will not render correctly "out-of-the-box" when importing into GS3.0.  

    As example, in XNA Game Studio, the user is required to set both the vertex and pixel shader. There are max shaders that do not and thus will not work.  

    It's pretty easy though to just tweak the Max shaders so they work :D

  • Please, explain

    how can i assign a Direct3D material to object in Max?

    I have plugin for Max 9, installed with DirectX SDK, which allows  to create "DX Shader Material". But if I try to export such material to FBX, error comes.

    May be You are using any other plugins, or only special FX are allowed for export to FBX, or anything else?

  • > how can i assign a Direct3D material to object in Max?

    I'm far from a Max expert, but this works for me using a stock install of Max 2009:

    - Open the Material Editor

    - Click Get Material

    - Select DirectX Shader from the Material/Map Browser

  • Hello,

    I was wondering if tangent data were exported as well, in order to implement normal mapping in the application.

  • > I was wondering if tangent data were exported as well, in order to implement normal mapping in the application.

    I don't believe that is exported in the FBX file, but there is no need for that because tangent data is just a generated derivative of the normal and texture coordinate information. Anyone who needs this for rendering purposes can compute it for themselves. If you are using the XNA Framework Content Pipeline, you can do that by checking the generate tangent frames option in your content processor properties.

  • re:A more automated approach for using custom shaders comes into play if you apply a Direct3D material directly to your object in Max (I believe this is not currently supported by Maya). This now works in FBX the same way it previously did with X files. You can export an FBX file that uses a custom D3D effect as a material, import this into the Content Pipeline, where the material will show up as an EffectMaterialContent, then load it into your game, where the material will come through as an instance of your custom Effect already configured with the appropriate textures and parameter values.

    I tried to add DirectX Shader

    "Material Editor->Standart->DirectX shader"

    and get this message

    "Failed to export the following materials, they will be exported as generic materials:

    -01- Default"

    I could not found any string about shader in fbx file after.

    What does it mean - "will be exported as generic materials"?

  • Looks like it not work in 3dsmax 2008. We can use several texture and it exporte fine, but DirectX material is not exporte.

    I install 3dsmax 2009 and exporter(plugin already was there) do without errors, pathes to the shaders present in fbx file and shaders parameters too. Create job! Really cool. :)

Page 1 of 2 (20 items) 12
Leave a Comment
  • Please add 8 and 7 and type the answer here:
  • Post