walbourn / directxtkmodelviewer

A SDKMESH/CMO model viewer using DirectX Tool Kit for DirectX 11
https://github.com/Microsoft/DirectXTK
MIT License
39 stars 14 forks source link

application crashed when loading D3D11 sample's .sdkmesh #3

Closed StanwieCB closed 6 years ago

StanwieCB commented 6 years ago

I was trying to view the raw geometry of D3D11's MultithreadedRendering11 sample by loading

DirectXSamples\MultithreadedRendering11\Media\SquidRoom\SquidRoom.sdkmesh

and the model viewer crashed.

I've also tried some other sample's .sdkmesh file and it threw errors as well.

So does it mean that the model view only supports single-mesh .sdkmesh file?

Many thanks!

walbourn commented 6 years ago

If you run the Debug build, you'll see the following output:

D3D11 ERROR: ID3D11Device::CreateInputLayout: The provided input signature expects to read an element with SemanticName/Index: 'NORMAL'/0, but the declaration doesn't provide a matching name. [ STATE_CREATION ERROR #163: CREATEINPUTLAYOUT_MISSINGELEMENT]

If you run sdkmeshdump.cpp on that model, you'll see it uses a compressed NORMAL format of:

NORMAL", 0, *D3DDECLTYPE_DEC3N*, 0, 12

Which his not technically supported by DXGI.

That sample treats that as DXGI_FORMAT_R10G10B10A2_UNORM which is not technically valid because it really should be DXGI_FORMAT_R10G10B10A2_SNORM which is not defined.

As a hack, you could make DirectXTK treat D3DDECLTYPE_DEC3N as DXGI_FORMAT_R10G10B10A2_UNORM but the result is questionable.

walbourn commented 6 years ago

If you do make this hack assumption, it still fails to load looking for a non-existent DDS file 'default' names that was put in there by an older exporter:

If you provide some kind of files for those, it will load.

walbourn commented 6 years ago

See the pull request for DX11 and DX12

walbourn commented 6 years ago

Try out the latest release. You'll still need to provide some kind of default.dds and default-normalmap.dds for that model.