-
Notifications
You must be signed in to change notification settings - Fork 14
Home
https://aka.ms/dxsdkcontentexporter
The Samples Content Exporter was shipped as a sample in the legacy DirectX SDK. It makes use of the Autodesk FBX SDK to import an FBX file and then export the data as an .SDKMESH
. The .SDKMESH
format is a runtime geometry format supported by the DirectX Tool Kit for DX11 / DX12 and DXUT, and is used in the Windows sample Marble Maze.
See Samples Content Exporter (May 2015), Samples Content Exporter Update (April 2012), and DirectXMesh.
Disclaimer: .SDKMESH
is a long-time samples runtime geometry format for Microsoft since the retiring of the legacy .X
file format. It has a number of limitations, and we don't recommend using it as a your production solution for meshes. It is, however, very useful for samples and itself serves as an example of such file containers. The documentation on the format can be found here
The exporter implements a broad set of features designed for game-related content export tasks, including the following:
- Parses FBX and other file formats supported by the Autodesk FBX SDK.
- Parses and exports full scene data, including transform frames (nodes), lights, and cameras.
- Exports rigid and skinned meshes, complete with subset information, several vertex compression options, multiple UV channels, and texture tangent space creation.
- Parses common material information (diffuse, normal map, and specular textures) extracted from all types of materials, regardless of their construction.
- Provides a sampling-based, adjustable precision animation track converter that stores linear keyframes with quaternions for orientation.
- Provides a texture map conversion and compression, including optional texture bundling for Xbox 360.
- Offers advanced content conversion and generation options, including UV atlas generation, poly mesh to Catmull-Clark subdivision surface translation, and more.
The exporter was originally designed as an internal support tool for samples development, but the decision was made to release the source code in hopes that title developers would find it useful.
Remember to set the FBX_SDK
environment variable to the location of the Autodesk FBX SDK installed on your system (such as C:\Program Files\Autodesk\FBX\FBX SDK\2020.2.1
) before launching Visual Studio.
Open a Command Prompt, and change to the directory containing ContentExporter.exe
(i.e. ...\ContentExporter\ImportFBX\Release_2019
if you use VS 2019 to build it).
contentexporter <path-to-your-scene-files>\test.fbx
This will load the test.fbx
file and then create a test.sdkmesh
output file in the same directory, along with .dds
files for any materials referenced.
-
-help, -? Shows the exporter usage help and command line options.
-
-outputpath path Sets the output path for the exporter. If this option is not specified, the output path is the path of each input file. XATG files will appear in scenes\ and textures\ subdirectories of the output path.
-
-verbose Shows more detailed output during export. Equivalent to
-loglevel 4
. -
-xatg Uses the XATG file format, equivalent to
-fileformat xatg
. -
-sdkmesh Uses the SDKMESH file format, equivalent to
-fileformat sdkmesh
. -
-sdkmesh2 Uses the SDKMESH v2 file format (supports PBR materials), equivalent to
-fileformat sdkmesh2
. -
-xbox360 Sets a group of options for an Xbox 360 target. This macro option is equivalent to the following options:
-endian ppc -packmeshdata+ -bundletextures+ -useexistingbundle+ -compressvertexdata+ -compressednormaltype float16_4 -texturebgra+ -fileformat xatg -featurelevel 9.3
- -windowsd3d9 Sets a group of options for a Windows Direct3D 9 target. This macro option is equivalent to the following options:
-endian intel -bundletextures- -useexistingbundle- -compressvertexdata- -compressednormaltype float16_4 -texturebgra- -fileformat sdkmesh -featurelevel 9.3
- -windowsd3d10 Sets a group of options for a Windows Direct3D 10 target. This macro option is equivalent to the following options:
-endian intel -bundletextures- -useexistingbundle- -compressvertexdata- -compressednormaltype rgba_10 -texturebgra- -fileformat sdkmesh -featurelevel 10.0
- -windowsd3d11 Sets a group of options for a Windows Direct3D 11 target. This macro option is equivalent to the following options:
-endian intel -bundletextures- -useexistingbundle- -compressvertexdata- -compressednormaltype rgba_10 -texturebgra+ -fileformat sdkmesh -featurelevel 11.0
- -xboxone Sets a group of options for a Xbox One target. This macro option is equivalent to the following options:
-endian intel -bundletextures- -useexistingbundle- -compressvertexdata+ -compressednormaltype rgba_s10 -texturebgra+ -fileformat sdkmesh -featurelevel 11.1
- -collisionmesh Sets a group of content filtering options to export collision meshes. Collision meshes consist of a 32-bit index buffer and vertex positions only. This macro option is equivalent to the following options:
-exportanimations- -exportcameras- -exportlights- -exportmaterials- -compressvertexdata- -computevertextangents- -exportnormals- -exportcolors- -exportbinormals- -exportboneweights- -force32bitindices+ -maxuvsetcount 0 -bundletextures- -useexistingbundle- -meshnamedecoration CollisionMesh
- -animation Sets a group of content filtering options to export animations. Only animation tracks are exported, and no meshes, frames, lights, cameras, or materials are exported. This macro option is equivalent to the following options:
-exportanimations+ -exportmeshes- -exportframes- -exportcameras- -exportlights- -exportmaterials- -compressvertexdata- -computevertextangents- -exportnormals- -exportcolors- -exportbinormals- -exportboneweights- -force32bitindices- -maxuvsetcount 0 -bundletextures- -useexistingbundle- -packmeshdata- -renameanimations+
- -character Sets a group of content filtering options to export characters. Only frames, meshes, and materials are exported, and no animations, cameras, or lights are exported. This macro option is equivalent to the following options:
-exportanimations- -exportcameras- -exportlights- -exportmeshes+ -exportframes+ -exportmaterials+
- -lightmaps Sets a group of content filtering options to export light-mapped meshes. No animations, normal, tangents, or binormals are exported. This macro option is equivalent to the following options:
-exportanimations- -exportmeshes+ -exportmaterials+ -computevertextangents- -exportnormals- -exportbinormals- -maxuvsetcount 2 -materialcolors- -useemissivetexture+
- -normalmaps Sets a group of content filtering options to export normal-mapped meshes. Includes normals and tangents. No animations or binormals are exported. This macro option is equivalent to the following options:
-exportanimations- -exportmeshes+ -exportmaterials+ -computevertextangents+ -exportnormals+ -exportbinormals- -maxuvsetcount 1 -materialcolors+ -useemissivetexture-
- -subd11 Sets a group of content filtering options to export content for the SubD11 sample. This macro option is equivalent to the following options:
-windowsd3d11 -compressvertexdata- -convertmeshtosubd+ -exportbinormals- -forceboneweights+ -maxuvsetcount 1
- -subdxbox Sets a group of content filtering options to export content for the Xbox 360 SubD sample. This macro option is equivalent to the following options:
-xbox360 -compressvertexdata+ -convertmeshtosubd+ -exportbinormals- -forceboneweights+ -maxuvsetcount 1
-
-savesettings filename Saves the current settings to the specified file. In order to capture all settings, ensure that this option is used last on the command line.
-
-loadsettings filename Loads settings from the specified file. Subsequent settings commands override those loaded from the file.
-
-filelist filename Loads a list of input content file names from the specified file.
-
-loglevel [1-10] Shows progress messages during the export operation. Higher numbers show more messages (defaults to 1).
For additional options, see Options
The content exporter can generate two different output file formats: XATG and SDKMESH. XATG was designed for use in Xbox 360 samples, and SDKMESH was designed for use in Direct3D 10 samples. While these two file formats are reasonably full featured, they do not necessarily demonstrate best practices for run-time formats for use in game development. Certain compromises have been made in each format to ease sample development, and these compromises may not make sense for a retail game title.
The XATG file format is a hybrid XML and binary format, designed for easy human readability and easy editability with XML or text editors, while maintaining reasonably fast load speeds for complex content. Since it is XML based, the layout of the data is reasonably flexible, and evolution of the XATG format does not necessarily mean that older XATG files become obsolete. The format supports transform frames, meshes with multiple subsets, materials with general parameters, lights, cameras, and animation tracks with timestamped linear keyframes. Mesh data (vertex and index buffers) can either be inlined as text in the XML file, or packed into a separate binary PMEM (physical memory) file, and simply referenced by offset in the XML data. Inlined text data is easier to inspect and edit by hand, but it greatly increases load times.
XATG requires a fixed directory structure; XATG and PMEM files must exist in a scenes subdirectory, and all textures must exist in a textures subdirectory parallel to the scenes directory. Textures can either be provided as a single texture bundle file (generated by using the Bundler tool), or as individual texture files.
The SDKMESH file format is a binary format consisting of memory-mapped structures, designed for quick loading. While it is not as flexible or readable as XATG, it is much quicker and simpler to load. Since it consists of memory mapped structures, most changes to the file format require old content to be re-exported, as the structures would no longer line up. SDKMESH supports transform frames, meshes with multiple subsets, materials with fixed parameters, and animation tracks with regularly spaced linear keyframes. Animation data is exported into a parallel SDKMESH_ANIM file.
SDKMESH does not place any restrictions on texture file locations. In practice, the SDKMESH file is in the same directory as all textures referenced in the file. SDKMESH files always reference individual texture files.
The content exporter is able to parse many types of materials and extract common material properties, including diffuse textures, normal map textures, specular map textures, and transparency. Material nodes are recursively parsed in search of these material properties. If more than one texture of a particular type is found, the second through final textures are labeled with a number, such as "DiffuseTexture2". Note that the SDKMESH file format only supports one texture of each type.
The content exporter automatically copies and converts source textures from their source locations to a location in the output path. DirectXTex is used to load textures, so the exporter supports all of the input file formats supported by that API, including BMP, TGA, JPG, PNG, and more. The input scene data usually specifies an absolute path for the texture files, and the exporter starts by looking in that location for each texture file. If a texture is not found in its source location, or the source location is unavailable, the exporter looks for a texture with the same filename in the same location as the source scene file. If the texture is not found in that location, the exporter gives up on converting that texture and shows a warning.
The content exporter generates bounding volumes for models, and computes ranges for point lights and spot lights. Model bounding volumes are generated by computing three bounds types (axis aligned box, oriented box, and sphere) for the mesh within a model, and choosing the bound with the smallest volume. The bounds are exported as part of the scene file, and are specified in object-relative coordinates.
Light ranges are a bit less straightforward, since DCC packages like Maya have no concept of a light range—just a falloff designated by the light type. In this case, a bounding range value must be computed from the intensity of the light and the falloff type. Therefore, to increase the range of a light in the exported content, increase the light intensity. The following table describes how the light range is computed for various light falloff settings.
Falloff Type Range Computation
No Decay 4 * Intensity
Linear 4 * Intensity
Quadratic 2 * Sqrt( Intensity )
Cubic/Other 20 (fixed value)
- This version no longer makes use of D3DX9 DLL or any component of the legacy DirectX SDK. It requires the Windows 8.0 SDK or later instead.
- It no longer supports compressing normals to the "dec3n" format as there is no DXGI equivalent to that Direct3D 9 format.
- This version supports new features such as vertex cache optimization
The DirectX SDK Samples Content Exporter is the work of Matt Lee with contributions from Chuck Walbourn.
Thanks to Shanon Drone for the SDKMESH file format.
All content and source code for this package are subject to the terms of the MIT License.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
- Windows desktop apps
- Windows 11
- Windows 10
- Windows 8.1
- Windows 7 Service Pack 1
- Visual Studio 2019
DirectX Tool Kit for DirectX 11
DirectX Tool Kit for DirectX 12
DirectXTKModelViewer for DirectX 11