ray_tracing__advance/raytrace.cpp
auto Raytracer::implicitToVkGeometryKHR(const ImplInst& implicitObj)
{
  VkDeviceAddress dataAddress = nvvk::getBufferDeviceAddress(m_device, implicitObj.implBuf.buffer);

  VkAccelerationStructureGeometryAabbsDataKHR aabbs{VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR};
  aabbs.data.deviceAddress = dataAddress;
  aabbs.stride             = sizeof(ObjImplicit);

  // Setting up the build info of the acceleration
  VkAccelerationStructureGeometryKHR asGeom{VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_KHR};
  asGeom.geometryType   = VK_GEOMETRY_TYPE_AABBS_KHR;
  asGeom.flags          = VK_GEOMETRY_NO_DUPLICATE_ANY_HIT_INVOCATION_BIT_KHR;  // For AnyHit
  asGeom.geometry.aabbs = aabbs;


  VkAccelerationStructureBuildRangeInfoKHR offset;
  offset.firstVertex     = 0;
  offset.primitiveCount  = static_cast<uint32_t>(implicitObj.objImpl.size());  // Nb aabb
  offset.primitiveOffset = 0;
  offset.transformOffset = 0;

  nvvk::RaytracingBuilderKHR::BlasInput input;
  input.asGeometry.emplace_back(asGeom);
  input.asBuildOffsetInfo.emplace_back(offset);
  return input;
}
//--------------------------------------------------------------------------------------------------
// Returning the ray tracing geometry used for the BLAS, containing all spheres
//
Returning the ray tracing geometry used for the BLAS, containing all spheres
Returning the ray tracing geometry used for the BLAS containing all spheres
auto Raytracer::implicitToVkGeometryKHR(const ImplInst& implicitObj)
{
  VkDeviceAddress dataAddress = nvvk::getBufferDeviceAddress(m_device, implicitObj.implBuf.buffer);
  VkAccelerationStructureGeometryAabbsDataKHR aabbs{VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR};
  aabbs.data.deviceAddress = dataAddress;
  aabbs.stride             = sizeof(ObjImplicit);
  VkAccelerationStructureGeometryKHR asGeom{VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_KHR};
  asGeom.geometryType   = VK_GEOMETRY_TYPE_AABBS_KHR;
  asGeom.flags          = VK_GEOMETRY_NO_DUPLICATE_ANY_HIT_INVOCATION_BIT_KHR;  
  asGeom.geometry.aabbs = aabbs;
  VkAccelerationStructureBuildRangeInfoKHR offset;
  offset.firstVertex     = 0;
  offset.primitiveCount  = static_cast<uint32_t>(implicitObj.objImpl.size());  
  offset.primitiveOffset = 0;
  offset.transformOffset = 0;
  nvvk::RaytracingBuilderKHR::BlasInput input;
  input.asGeometry.emplace_back(asGeom);
  input.asBuildOffsetInfo.emplace_back(offset);
  return input;
}
auto Raytracer :: implicitToVkGeometryKHR ( const ImplInst & implicitObj ) { VkDeviceAddress dataAddress = nvvk :: getBufferDeviceAddress ( m_device , implicitObj . implBuf . buffer ) ; VkAccelerationStructureGeometryAabbsDataKHR aabbs { VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR } ; aabbs . data . deviceAddress = dataAddress ; aabbs . stride = sizeof ( ObjImplicit ) ; VkAccelerationStructureGeometryKHR asGeom { VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_KHR } ; asGeom . geometryType = VK_GEOMETRY_TYPE_AABBS_KHR ; asGeom . flags = VK_GEOMETRY_NO_DUPLICATE_ANY_HIT_INVOCATION_BIT_KHR ; asGeom . geometry . aabbs = aabbs ; VkAccelerationStructureBuildRangeInfoKHR offset ; offset . firstVertex = 0 ; offset . primitiveCount = static_cast < uint32_t > ( implicitObj . objImpl . size ( ) ) ; offset . primitiveOffset = 0 ; offset . transformOffset = 0 ; nvvk :: RaytracingBuilderKHR :: BlasInput input ; input . asGeometry . emplace_back ( asGeom ) ; input . asBuildOffsetInfo . emplace_back ( offset ) ; return input ; }
Returning the ray tracing geometry used for the BLAS, containing all spheres
Returning the ray tracing geometry used for the BLAS containing all spheres
// Setting up the build info of the acceleration // For AnyHit // Nb aabb