Skip to content

Commit 16e9df0

Browse files
object IDs are correct for instances
1 parent 7031e60 commit 16e9df0

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

examples_tests/22.RaytracedAO/dirty_source/ExtraCrap.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,9 @@ Renderer::InitializationData Renderer::initSceneObjects(const SAssetBundle& mesh
323323
}
324324
}
325325

326-
// set up BVH
326+
// this wont get rid of identical pipelines
327327
IMeshManipulator::homogenizePrimitiveTypeAndIndices(meshBuffersToProcess.begin(), meshBuffersToProcess.end(), EPT_TRIANGLE_LIST);
328+
// set up BLAS
328329
m_rrManager->makeRRShapes(rrShapeCache, meshBuffersToProcess.begin(), meshBuffersToProcess.end());
329330

330331
// convert to GPU objects
@@ -350,7 +351,7 @@ Renderer::InitializationData Renderer::initSceneObjects(const SAssetBundle& mesh
350351
}
351352
);
352353

353-
// set up Radeon Rays instances
354+
// set up Radeon Rays instances and TLAS
354355
{
355356
core::vector<ext::RadeonRays::MockSceneManager::ObjectGUID> ids(m_mock_smgr.m_objectData.size());
356357
std::iota(ids.begin(),ids.end(),0u);
@@ -361,7 +362,7 @@ Renderer::InitializationData Renderer::initSceneObjects(const SAssetBundle& mesh
361362

362363
core::vector<DrawElementsIndirectCommand_t> mdiData;
363364
{
364-
core::unordered_map<uint32_t,uint32_t> meshbufferIDToDrawID;
365+
core::vector<uint32_t> meshbufferIDToDrawID(gpuMeshBuffers.size());
365366
{
366367
MDICall call;
367368
auto initNewMDI = [&call](const core::smart_refctd_ptr<IGPUMeshBuffer>& gpumb) -> void
@@ -378,7 +379,7 @@ Renderer::InitializationData Renderer::initSceneObjects(const SAssetBundle& mesh
378379
m_mdiDrawCalls.emplace_back(call);
379380
};
380381
uint32_t drawBaseInstance = 0u;
381-
for (auto item : gpuMeshBuffers)
382+
for (const auto& item : gpuMeshBuffers)
382383
{
383384
const auto gpumb = std::get<core::smart_refctd_ptr<IGPUMeshBuffer>>(item);
384385

@@ -413,8 +414,8 @@ Renderer::InitializationData Renderer::initSceneObjects(const SAssetBundle& mesh
413414
}
414415
queueUpMDI(call);
415416
}
416-
for (auto cull : cullData)
417-
cull.drawID = meshbufferIDToDrawID[cull.drawID];
417+
for (auto& cull : cullData)
418+
cull.drawID = meshbufferIDToDrawID[cull.globalObjectID];
418419
}
419420
m_cullPushConstants.currentCommandBufferIx = 0x0u;
420421
m_cullPushConstants.maxDrawCount = mdiData.size();
@@ -473,7 +474,7 @@ void Renderer::initSceneNonAreaLights(Renderer::InitializationData& initData)
473474
{
474475
core::vectorSIMDf _envmapBaseColor;
475476
_envmapBaseColor.set(0.f,0.f,0.f,1.f);
476-
for (auto emitter : initData.globalMeta->emitters)
477+
for (const auto& emitter : initData.globalMeta->emitters)
477478
{
478479
float weight = 0.f;
479480
switch (emitter.type)
@@ -1051,7 +1052,7 @@ void Renderer::render(nbl::ITimer* timer)
10511052
m_driver->clearColorBuffer(EFAP_COLOR_ATTACHMENT2, zero);
10521053
}
10531054
m_driver->bindDescriptorSets(EPBP_GRAPHICS,m_visibilityBufferFillPipelineLayoutGPU.get(),1u,1u,descriptors+1u,nullptr);
1054-
for (auto call : m_mdiDrawCalls)
1055+
for (const auto& call : m_mdiDrawCalls)
10551056
{
10561057
m_driver->bindGraphicsPipeline(call.pipeline.get());
10571058
m_driver->drawIndexedIndirect(call.vertexBindings,EPT_TRIANGLE_LIST,EIT_32BIT,call.indexBuffer.get(),m_indirectDrawBuffers[m_cullPushConstants.currentCommandBufferIx].get(),call.mdiOffset,call.mdiCount,sizeof(DrawElementsIndirectCommand_t));

examples_tests/22.RaytracedAO/raygen.comp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ void main()
169169
bool frontfacing;
170170
vec3 emissive;
171171
{
172-
frontfacing = visBuffer[0]<0x80000000u;
173172
const uint objectID = visBuffer[0]&0x7fffffffu;
173+
frontfacing = objectID==visBuffer[0];
174174
const uint triangleID = visBuffer[1];
175175

176176
//
@@ -179,6 +179,7 @@ void main()
179179

180180
//
181181
emissive = nbl_glsl_MC_oriented_material_t_getEmissive(material);
182+
emissive = vec3(float(objectID),float(triangleID),0.0);
182183

183184
// normally we'd use MeshPackerV2's vertex attribute data for this, but now we read from temporary GBuffer
184185
const vec3 normal = nbl_glsl_NormalDecode_signedSpherical(normalBuffer);

examples_tests/22.RaytracedAO/resolve.comp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ void main()
2929
if (hit.shapeid<0)
3030
continue;
3131

32-
color.r -= float(hit.shapeid);//staticViewData.samplesPerPixelPerDispatch;
33-
color.g -= float(hit.primid);//staticViewData.samplesPerPixelPerDispatch;
32+
//color.r -= float(hit.shapeid);//staticViewData.samplesPerPixelPerDispatch;
33+
//color.g -= float(hit.primid);//staticViewData.samplesPerPixelPerDispatch;
3434

3535
// hit buffer needs clearing
3636
hits[rayID].shapeid = -1;

0 commit comments

Comments
 (0)