Sign in to follow this  
Carnevil_

DX11 Alternate model format for DX9?

Recommended Posts

Carnevil_    130
I'm wondering - what model format is typically used in DirectX 9 (besides the .x format)? From what I've been reading, the support for .x is pretty awful, and Microsoft is even dropping support for the format in DX11. The animator on a project I'm working on can't even get one of his animated models to export to .x, and even when he could on previous versions of the model, there were always issues with them. Yuck! So, I'm guessing that most projects use something besides .x. What alternate formats are commonly used? This is a commercial project, so the format/library used to load them would have to be something non-restrictive for commercial products. Any help would be greatly appreciated. Thanks!

Share this post


Link to post
Share on other sites
Schrompf    1035
DirectX .x files are still fine, I think... after all it's just a file format. The builtin exporters for DirectX models in most modelling applications are awful, though. For 3DSMax I suggest getting the kwXPort plugin, for Maya the CVXporter is doing a good job.

Other formats might still be interesting, though. Especially if the exporters are maintained. I therefore recommend Collada or FBX. Both come with well-maintained exporters for various 3d modelling packages, and both support a basic SDK to read them into your engine. On the loading side the Collada SDK is close to unusable in my opinion, FBX seems better.

That said, there's a generic model loader library called the Open Asset Import Library for which I wrote several loaders. It reads 20+ file formats, including DirectX .x, Collada .dae, Milkshape .ms3d, Lightwave .obj, 3DSMax .3ds and a lot more... FBX support is in the works at the moment. This library might save you the hassle of writing your own loaders.

Share this post


Link to post
Share on other sites
jbb    471
I would consider inventing your own custom format that contains the data you need in the format you need it. You can make it little more than a binary dump of your vertex and index buffers and any other data fields will be little more that the fields of your model object.

If you do that then your models will be very fast and easy to load, and you won't have to include any complex and large API into your actual game code. I wouldn't feel happy to include large third party APIs directly into my game code.

You'll of course have to write a tool to convert your models and run it on all of them as part of your build, but at least then your converter can load lots of different kinds of file without bloating and slowing your engine and it doesn't matter if your tool gets "bloated" by including several different model APIs.

Share this post


Link to post
Share on other sites
solenoidz    591
Quote:
Original post by jbb
I would consider inventing your own custom format that contains the data you need in the format you need it. You can make it little more than a binary dump of your vertex and index buffers and any other data fields will be little more that the fields of your model object.

If you do that then your models will be very fast and easy to load, and you won't have to include any complex and large API into your actual game code. I wouldn't feel happy to include large third party APIs directly into my game code.

You'll of course have to write a tool to convert your models and run it on all of them as part of your build, but at least then your converter can load lots of different kinds of file without bloating and slowing your engine and it doesn't matter if your tool gets "bloated" by including several different model APIs.


For a final game run, I would also recommend a custom binary format, that loads in a blink of an eye, and could be quickly streamed and stuff.
But that's only for a final game(or techdemo). Using Assimp for a converting tool is very attractive solution, as it support many formats, that get exported from 3D packages, and you don't have to implement and maintain your own exporters. Assimp is very sweet and provides nice uniform data structure back to the application. I don't know how fast it actually is, parsing different models, but I guess, loading a binary dump from hard disk straight to the memory buffers will be faster. Also, when I compile it in release mode without boost, it's 14 MB big static lib ? That kind of concerns me including it into my application.
Maybe i'm doing something completely wrong with the compilation process ? Sorry for biasing the topic to Assimp, but if Schrompf(or someone else) could answer would be nice.

Share this post


Link to post
Share on other sites
Schrompf    1035
Assimp is quite slow. The reasons for this are that most 3d file formats do not contain plain vertex data only, but alot of additional data, and mostly in a very non-straightforward manner. It takes time to parse textbased files, and it takes time to reorganise data and calculate derived data. The other reason for the relative slowliness is the post processing applied to the imported 3D scene. Things such as calculating tangent data for your vertices, triangulating polygons or creating index buffers also cost time.

Therefore I also suggest inventing your own file format for quick loading, just like everybody else here did. Assimp is not intended for loading assets on game startup. You can do this, but it will take time. A binary format specifically designed to hold the data you need in an engine-specific way will load much faster. Assimp is intended to be an importer library - read files once when your graphics artist delivered them and save them in your custom file format for quick every-day reading.

Concerning the size of the static library: I never actually looked for how large my Assimp build got. It's just a temporary file, after all... if you link statically. In my case the final executable got larger by only a few 100 kb, and that's what counts for me. I guess it's due to the usage of templates, but I never checked.

Share this post


Link to post
Share on other sites
solenoidz    591
Yeah, the lib is something like concatenation of the object files, and I guess it get's pretty fat(duplicate code ?) when templates are involved. But for a final linkage to the exe(or dll) most of it would be eliminated, so no big worries. :)

Share this post


Link to post
Share on other sites
Carnevil_    130
I see. So basically what you guys are saying is that I should take something like AssImp, use that to load the files, convert them to my own format, and then use that new format to load into the game?

Is there a tutorial or something on that? Thinking of loading all of the animations and heirarchical data and skin information is going to make my head explode.

Share this post


Link to post
Share on other sites
nvtroll    100
I'm also using assimp as temporarily collada loader. The only problem is that the documentation is poor and the assimp viewer source is bit too complex just to search for a one example call. Using assimp requires patience. Took me a while to get an overview how to e.g. load the materials using that ::Get()

[Edited by - nvtroll on March 22, 2010 12:02:36 PM]

Share this post


Link to post
Share on other sites
Schrompf    1035
Concerning getting started with Assimp: there's the official documentation which explains the basic usage at http://assimp.sourceforge.net/lib_html/usage.html and how to interpret the imported data at http://assimp.sourceforge.net/lib_html/data.html. There's also this little tutorial at http://wasaproject.net16.net/?p=175

In my defense: I, too, don't like the material system. I would have preferred a flat structure because of easier access and clean debuggability. But this one wasn't my decision and now my spare time is way too lacking to implement an easier path to access it.

Share this post


Link to post
Share on other sites
Carnevil_    130
So, can Assimp export in all of those formats, too? Would it be possible to load a Collada file, and then export to a .x DirectX file? I'm really not interested in making my own file format or anything - I just want our modelers to be able to make the .x files the engine uses.

Share this post


Link to post
Share on other sites
solenoidz    591
I'm new to Assimp, but I'm afraid it can't be use to export .x
You could however lock and fill up your LPD3DXMESH mesh buffers with vertices, indices and stuff provided by Assimp and then call D3DXSaveMeshtoX to save it.

Share this post


Link to post
Share on other sites
Carnevil_    130
But then how would I save the hierarchy, bone, animation and skin information? There's a lot more to a mesh than just vertices, indices, normals, etc.

Share this post


Link to post
Share on other sites
Carnevil_    130
Quote:
Original post by solenoidz
This could help, i think.
http://www.toymaker.info/Games/html/x_file_saving.html


Ah, excellent! That's such a great site!

Well, awesome. So, the modelers can export to Collada or another well-supported format, I can load them using Assimp, and then save them to .x using the info from that site. I think I should be all set then!

Thanks everyone!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Partner Spotlight

  • Similar Content

    • By RubenRS
      How do i open an image to use it as Texture2D information without D3DX11CreateShaderResourceViewFromFile? And how it works for different formats like (JPG, PNG, BMP, DDS,  etc.)?
      I have an (512 x 512) image with font letters, also i have the position and texcoord of every letter. The main idea is that i want to obtain the image pixel info, use the position and texcoords to create a new texture with one letter and render it. Or am I wrong in something?
    • By thmfrnk
      Hey,
      I found a very interesting blog post here: https://bartwronski.com/2017/04/13/cull-that-cone/
      However, I didn't really got how to use his "TestConeVsSphere" test in 3D (last piece of code on his post). I have the frustumCorners of a 2D Tile cell in ViewSpace and my 3D Cone Origin and Direction, so where to place the "testSphere"? I thought about to also move the Cone into viewspace and put the sphere to the Center of the Cell with the radius of half-cellsize, however what about depth? A sphere does not have inf depth?
      I am missing anything? Any Ideas?
      Thx, Thomas
    • By Modymek
      hi all
      I want to enable and disable shader in MPCH Media player Classic
      the MPCH have shader option using HLSL shaders
      I want the shader to read each file extension before it plays the file
      so if the video file name is video.GR.Mp4 it will play it in Grayscale shader 
      if it is not and standard file name Video.Mp4 without GR. unique extension so it plays standard without shader or end the shader
      here is the shader I have for grayscale
      // $MinimumShaderProfile: ps_2_0
      sampler s0 : register(s0);
      float4 main(float2 tex : TEXCOORD0) : COLOR {
          float c0 = dot(tex2D(s0, tex), float4(0.299, 0.587, 0.114, 0));
          return c0;
      }
       
      I want to add if or block stantement or bloean to detect file name before it call the shader in order to go to the procedure or disable it or goto end direct without it
       
      any thoughts or help
    • By noodleBowl
      I've gotten to part in my DirectX 11 project where I need to pass the MVP matrices to my vertex shader. And I'm a little lost when it comes to the use of the constant buffer with the vertex shader
      I understand I need to set up the constant buffer just like any other buffer:
      1. Create a buffer description with the D3D11_BIND_CONSTANT_BUFFER flag 2. Map my matrix data into the constant buffer 3. Use VSSetConstantBuffers to actually use the buffer But I get lost at the VertexShader part, how does my vertex shader know to use this constant buffer when we get to the shader side of things
      In the example I'm following I see they have this as their vertex shader, but I don't understand how the shader knows to use the MatrixBuffer cbuffer. They just use the members directly. What if there was multiple cbuffer declarations like the Microsoft documentation says you could have?
      //Inside vertex shader cbuffer MatrixBuffer { matrix worldMatrix; matrix viewMatrix; matrix projectionMatrix; }; struct VertexInputType { float4 position : POSITION; float4 color : COLOR; }; struct PixelInputType { float4 position : SV_POSITION; float4 color : COLOR; }; PixelInputType ColorVertexShader(VertexInputType input) { PixelInputType output; // Change the position vector to be 4 units for proper matrix calculations. input.position.w = 1.0f; // Calculate the position of the vertex against the world, view, and projection matrices. output.position = mul(input.position, worldMatrix); output.position = mul(output.position, viewMatrix); output.position = mul(output.position, projectionMatrix); // Store the input color for the pixel shader to use. output.color = input.color; return output; }  
    • By gomidas
      I am trying to add normal map to my project I have an example of a cube: 
      I have normal in my shader I think. Then I set shader resource view for texture (NOT BUMP)
                  device.ImmediateContext.PixelShader.SetShaderResource(0, textureView);             device.ImmediateContext.Draw(VerticesCount,0); What should I do to set my normal map or how it is done in dx11 generally example c++?
  • Popular Now