Skip to content

Commit c54b918

Browse files
fortify OBJ loader against missing MTL files, change the type of PropertyElement after its converted from sRGB
temporarily disable the usage of NV barycentrics
1 parent 994fabc commit c54b918

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

examples_tests/22.RaytracedAO/fillVisBuffer.frag

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22
// This file is part of the "Nabla Engine".
33
// For conditions of distribution and use, see copyright notice in nabla.h
44
#version 430 core
5-
#extension GL_NV_fragment_shader_barycentric : require
65
#extension GL_EXT_shader_16bit_storage : require
76

87

98
#define _NBL_GLSL_EXT_MITSUBA_LOADER_INSTANCE_DATA_BINDING_ 0
109
#include "virtualGeometry.glsl"
1110

12-
11+
#undef NBL_GL_NV_fragment_shader_barycentric
1312
#include <nbl/builtin/glsl/barycentric/frag.glsl>
1413
layout(location = 2) flat in uint BackfacingBit_BatchInstanceGUID;
1514
layout(location = 3) flat in uint drawCmdFirstIndex;

examples_tests/22.RaytracedAO/fillVisBuffer.vert

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ layout(set=2, binding=0, row_major) readonly restrict buffer PerInstancePerCamer
1414
DrawData_t data[];
1515
} instanceDataPerCamera;
1616

17+
#undef NBL_GL_NV_fragment_shader_barycentric
1718
#include <nbl/builtin/glsl/barycentric/vert.glsl>
1819
layout(location = 2) flat out uint BackfacingBit_BatchInstanceGUID;
1920
layout(location = 3) flat out uint drawCmdFirstIndex;

src/nbl/asset/interchange/COBJMeshFileLoader.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ asset::SAssetBundle COBJMeshFileLoader::loadAsset(io::IReadFile* _file, const as
161161
std::replace(mtllib.begin(), mtllib.end(), '\\', '/');
162162
SAssetLoadParams loadParams;
163163
auto bundle = interm_getAssetInHierarchy(AssetManager, mtllib, loadParams, _hierarchyLevel+ICPUMesh::PIPELINE_HIERARCHYLEVELS_BELOW, _override);
164+
if (bundle.getContents().empty())
165+
break;
166+
164167
auto meta = bundle.getMetadata()->selfCast<const CMTLMetadata>();
165168
if (bundle.getAssetType()==IAsset::ET_RENDERPASS_INDEPENDENT_PIPELINE)
166169
for (auto ass : bundle.getContents())
@@ -370,6 +373,20 @@ asset::SAssetBundle COBJMeshFileLoader::loadAsset(io::IReadFile* _file, const as
370373
// eat up rest of line
371374
bufPtr = goNextLine(bufPtr, bufEnd);
372375
} // end while(bufPtr && (bufPtr-buf<filesize))
376+
377+
// prune out invalid empty shape groups (TODO: convert to AoS and use an erase_if)
378+
for (size_t i = 0ull; i < submeshes.size(); ++i)
379+
if (indices[i].size())
380+
i++;
381+
else
382+
{
383+
submeshes.erase(submeshes.begin()+i);
384+
indices.erase(indices.begin()+i);
385+
recalcNormals.erase(recalcNormals.begin()+i);
386+
submeshWasLoadedFromCache.erase(submeshWasLoadedFromCache.begin()+i);
387+
submeshCacheKeys.erase(submeshCacheKeys.begin()+i);
388+
submeshMaterialNames.erase(submeshMaterialNames.begin()+i);
389+
}
373390

374391
core::unordered_set<pipeline_meta_pair_t,hash_t,key_equal_t> usedPipelines;
375392
{

src/nbl/ext/MitsubaLoader/PropertyElement.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ std::pair<bool, SNamedPropertyElement> CPropertyElementManager::createPropertyDa
130130
result.vvalue = retrieveHex(desiredAttributes[0], success);
131131
for (auto i=0; i<3u; i++)
132132
result.vvalue[i] = core::srgb2lin(result.vvalue[i]);
133+
result.type = SPropertyElementData::Type::RGB; // now its an RGB value
133134
}
134135
break;
135136
case SPropertyElementData::Type::VECTOR:

0 commit comments

Comments
 (0)