제임스딘딘의
Tech & Life

개발자의 기록 노트/XNA Framework

FBX improvements in XNA Game Studio 3.0

제임스-딘딘 2011. 10. 3. 03:32
max에서 FBX파일을 export한뒤 xna에서 import하여 다룰때 필요한 심화된 정보 정도로 보면 되겠다.



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 whichcoordinate 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!

출처 : http://blogs.msdn.com/b/shawnhar/archive/2008/09/18/fbx-improvements-in-xna-game-studio-3-0.aspx

'개발자의 기록 노트 > XNA Framework' 카테고리의 다른 글

XNA와 3D 기초 (1)  (0) 2011.09.10
XNA Framework의 논리적 흐름  (0) 2011.07.21