Properly using textures with CMO files

Nov 1, 2014 at 9:32 PM
Edited Nov 1, 2014 at 9:33 PM
I am completely lost with how to use textures. I would like to eventually apply normal and maybe specular maps, but I don't even know how to load in a diffuse map right now.

Here's my workflow thus far:
  1. Export an FBX from 3DS Max with one standard material with a diffuse bitmap, using the recommended settings from here (with no media embed)
  2. Open it in VS2013, click on the mesh in the view, and remove its Texture1 parameter
  3. Turn this FBX into a CMO by building it with the Visual Studio 3D Starter Kit
And as expected with what I've bolded, there is no texture on my object. I essentially had no choice but to empty that parameter because otherwise, the entire absolute path of the texture becomes set as the file name of what the CMO tries to look for (resulting in an error), slashes replaced with underscores and with '.dds' appended at the end (so it becomes something ugly and completely inaccurate like Assets/E_Documents_User_Project_Game_texture.dds.dds).

What is the right way of applying textures?
Coordinator
Nov 2, 2014 at 12:23 AM
Edited Nov 2, 2014 at 12:31 AM
This name mangling is how VS 2013's content pipeline tries handle making the names 'unique'. Personally I would have preferred a GUID or just not worrying about it. As such, the texture names internal to a CMO are a bit of a mess. Have you added your texture DDS files to your project as content? They would normally be converted by VS 2013 to the mangled name as well.

What would probably work better is to have your 3DS Max model reference the original image in PNG, JPG, etc. and not pre-convert the DDS files. That way, when your image file is processed by VS 2013's content pipeline, it ends up matching up with the final name embedded in the CMO model.

Really this is just an issue for your loader to resolve. The code in the VS 3D Starter Kit is pretty naïve. You could try using the Model class in DirectX Tool Kit to load your model instead possibly with a custom IEffectFactory interface. If you look at DirectX Tool Kit's implementation of the DGSLEffectFactory, you'll see it has some code for parsing these crazy names to handle the pixel-shader matching, so you could do something like that as well.
Nov 2, 2014 at 2:14 AM
Thanks for the tip. I did leave the original image extension this time, didn't remove the Texture1 parameter, and put the generated DDS with the ugly filename into my project, but it still refuses to show up (and I get no complaints if I straight up delete the DDS from my project). Should I have the un-DDS'd textures that 3DS Max references directly inside the VS project (asset) folder, or should where they are not matter?

I am actually using the Model class and DGSLEffectFactory--basically just using the code from the sample code. Right now I'm just using BasicEffect in an attempt to get the one diffuse texture showing.
Coordinator
Nov 2, 2014 at 6:36 PM
Edited Nov 3, 2014 at 7:26 PM
You don't need the 'ugly' name in your project. They are generated by VS 2013 automatically from the source images if you add those to your project's asset folder.

BTW, you may find the 'cmodump.cpp' utility on the DirectXMesh site a useful debugging tool.