NVIDIAGameWorks / RTXGI-DDGI

RTX Global Illumination (RTXGI)
https://developer.nvidia.com/rtxgi
Other
683 stars 55 forks source link

TestHarness Crash #61

Closed jirzynek closed 2 years ago

jirzynek commented 2 years ago

Hi,

I've noticed that TestHarness will crash if GLTF has missing materials (p.material == -1).

The code causing problems:

...
// Get references to the mesh primitive and material
const tinygltf::Primitive& p = gltfMesh.primitives[primitiveIndex];

===> const tinygltf::Material& mat = gltfData.materials[p.material];

MeshPrimitive m;
m.index = geometryIndex;
m.material = p.material;

// Set to the default material if one is not assigned
if (m.material == -1) m.material = 0;
...

Re-arranging the code like below fixes the problem for me:

...
 // Get references to the mesh primitive and material
const tinygltf::Primitive& p = gltfMesh.primitives[primitiveIndex];

MeshPrimitive m;
m.index = geometryIndex;
m.material = p.material;

// Set to the default material if one is not assigned
if (m.material == -1) m.material = 0;

const tinygltf::Material& mat = gltfData.materials[m.material];
...

J

acmarrs-nvidia commented 2 years ago

Hi @jirzynek - thanks for pointing this out. The latest release includes changes to address the problem. The Test Harness should now be able to successfully load GLTF files without materials. In this scenario, the default material will be used for all surfaces.