microsoft / DirectXTK12

The DirectX Tool Kit (aka DirectXTK12) is a collection of helper classes for writing DirectX 12 code in C++
https://walbourn.github.io/directx-tool-kit-for-directx-12/
MIT License
1.48k stars 393 forks source link

PBREffect factory should support materials without textures #58

Closed mgubisch closed 3 years ago

mgubisch commented 5 years ago

I'm loading my model from an SKDMesh file containing several meshes with different materials. Some of these Materials don't have textures because they are intended for HUD an should use a rendered texture on the fly

PBREffect factory throws an exception in this case causing the application to crash. I implemented a workaround disabling Texture support for the specific mesh if at least 1 Texture is missing just by checking all the Textureindices against -1 before effect creation.

Would be great to have this on master, and issue only a warning (or debug message) instead of an exception, perhaps with the possiblity to force the exception?

walbourn commented 3 years ago

I've thought about this one a bit... The problem is that not having the textures leaves the model in a 'dangerous' state. It would throw an exception if you tried to render it.

Perhaps a better solution would be to use 'default' 1x1 textures for your models and then you can replace those at runtime? defaulttxt.zip