Bulk update NvPro-Samples 03/18/21
This commit is contained in:
parent
a2b80ab819
commit
2da588b7e6
113 changed files with 3529 additions and 1508 deletions
|
|
@ -31,27 +31,11 @@ include_directories(${TUTO_KHR_DIR}/common)
|
|||
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
# GLSL to SPIR-V custom build
|
||||
#
|
||||
SET(VULKAN_TARGET_ENV vulkan1.2)
|
||||
UNSET(GLSL_SOURCES)
|
||||
UNSET(SPV_OUTPUT)
|
||||
file(GLOB_RECURSE GLSL_HEADER_FILES "shaders/*.h" "shaders/*.glsl")
|
||||
file(GLOB_RECURSE GLSL_SOURCE_FILES
|
||||
"shaders/*.comp"
|
||||
"shaders/*.frag"
|
||||
"shaders/*.vert"
|
||||
"shaders/*.rchit"
|
||||
"shaders/*.rahit"
|
||||
"shaders/*.rint"
|
||||
"shaders/*.rmiss"
|
||||
"shaders/*.rgen"
|
||||
"shaders/*.rcall"
|
||||
)
|
||||
foreach(GLSL ${GLSL_SOURCE_FILES})
|
||||
get_filename_component(FILE_NAME ${GLSL} NAME)
|
||||
_compile_GLSL(${GLSL} "shaders/${FILE_NAME}.spv" GLSL_SOURCES SPV_OUTPUT)
|
||||
endforeach(GLSL)
|
||||
list(APPEND GLSL_SOURCES ${GLSL_HEADER_FILES})
|
||||
compile_glsl_directory(
|
||||
SRC "${CMAKE_CURRENT_SOURCE_DIR}/shaders"
|
||||
DST "${CMAKE_CURRENT_SOURCE_DIR}/spv"
|
||||
VULKAN_TARGET "vulkan1.2"
|
||||
)
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
|
|
@ -59,7 +43,7 @@ list(APPEND GLSL_SOURCES ${GLSL_HEADER_FILES})
|
|||
target_sources(${PROJNAME} PUBLIC ${SOURCE_FILES} ${HEADER_FILES})
|
||||
target_sources(${PROJNAME} PUBLIC ${COMMON_SOURCE_FILES})
|
||||
target_sources(${PROJNAME} PUBLIC ${PACKAGE_SOURCE_FILES})
|
||||
target_sources(${PROJNAME} PUBLIC ${GLSL_SOURCES})
|
||||
target_sources(${PROJNAME} PUBLIC ${GLSL_SOURCES} ${GLSL_HEADERS})
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
|
|
@ -68,7 +52,7 @@ target_sources(${PROJNAME} PUBLIC ${GLSL_SOURCES})
|
|||
source_group("Common" FILES ${COMMON_SOURCE_FILES} ${PACKAGE_SOURCE_FILES})
|
||||
source_group("Sources" FILES ${SOURCE_FILES})
|
||||
source_group("Headers" FILES ${HEADER_FILES})
|
||||
source_group("Shader_Files" FILES ${GLSL_SOURCES})
|
||||
source_group("Shader_Files" FILES ${GLSL_SOURCES} ${GLSL_HEADERS})
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
|
|
@ -87,25 +71,8 @@ endforeach(RELEASELIB)
|
|||
#--------------------------------------------------------------------------------------------------
|
||||
# copies binaries that need to be put next to the exe files (ZLib, etc.)
|
||||
#
|
||||
_copy_binaries_to_target( ${PROJNAME} )
|
||||
_finalize_target( ${PROJNAME} )
|
||||
|
||||
|
||||
#install(FILES ${SPV_OUTPUT} CONFIGURATIONS Release DESTINATION "bin_${ARCH}/${PROJNAME}/shaders")
|
||||
#install(FILES ${SPV_OUTPUT} CONFIGURATIONS Debug DESTINATION "bin_${ARCH}_debug/${PROJNAME}/shaders")
|
||||
#install(FILES ${CUBIN_SOURCES} CONFIGURATIONS Release DESTINATION "bin_${ARCH}/${PROJNAME}")
|
||||
#install(FILES ${CUBIN_SOURCES} CONFIGURATIONS Debug DESTINATION "bin_${ARCH}_debug/${PROJNAME}")
|
||||
#install(DIRECTORY "../media" CONFIGURATIONS Release DESTINATION "bin_${ARCH}/${PROJNAME}")
|
||||
#install(DIRECTORY "../media" CONFIGURATIONS Debug DESTINATION "bin_${ARCH}_debug/${PROJNAME}")
|
||||
|
||||
#----------------------------------------------------------------------------------------------------
|
||||
# Copying elements
|
||||
# Media
|
||||
# target_copy_to_output_dir(TARGET ${PROJECT_NAME} FILES "${TUTO_KHR_DIR}/media")
|
||||
# Spir-V Shaders
|
||||
target_copy_to_output_dir(
|
||||
TARGET ${PROJECT_NAME}
|
||||
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
DEST_SUBFOLDER "${PROJECT_NAME}/"
|
||||
FILES ${SPV_OUTPUT}
|
||||
)
|
||||
|
||||
install(FILES ${SPV_OUTPUT} CONFIGURATIONS Release DESTINATION "bin_${ARCH}/${PROJNAME}/spv")
|
||||
install(FILES ${SPV_OUTPUT} CONFIGURATIONS Debug DESTINATION "bin_${ARCH}_debug/${PROJNAME}/spv")
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# NVIDIA Vulkan Trace Rays Indirect Tutorial
|
||||
# NVIDIA Vulkan Trace Rays Indirect Tutorial
|
||||
This is an extension of the [Vulkan ray tracing tutorial](https://nvpro-samples.github.io/vk_raytracing_tutorial_KHR/).
|
||||
|
||||
We will discuss the `vkCmdTraceRaysIndirectKHR` command, which allows the
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ void HelloVulkan::setup(const vk::Instance& instance,
|
|||
AppBase::setup(instance, device, physicalDevice, queueFamily);
|
||||
m_alloc.init(device, physicalDevice);
|
||||
m_debug.setup(m_device);
|
||||
m_offscreenDepthFormat = nvvk::findDepthFormat(physicalDevice);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
|
@ -220,8 +221,8 @@ void HelloVulkan::createGraphicsPipeline()
|
|||
std::vector<std::string> paths = defaultSearchPaths;
|
||||
nvvk::GraphicsPipelineGeneratorCombined gpb(m_device, m_pipelineLayout, m_offscreenRenderPass);
|
||||
gpb.depthStencilState.depthTestEnable = true;
|
||||
gpb.addShader(nvh::loadFile("shaders/vert_shader.vert.spv", true, paths, true), vkSS::eVertex);
|
||||
gpb.addShader(nvh::loadFile("shaders/frag_shader.frag.spv", true, paths, true), vkSS::eFragment);
|
||||
gpb.addShader(nvh::loadFile("spv/vert_shader.vert.spv", true, paths, true), vkSS::eVertex);
|
||||
gpb.addShader(nvh::loadFile("spv/frag_shader.frag.spv", true, paths, true), vkSS::eFragment);
|
||||
gpb.addBindingDescription({0, sizeof(VertexObj)});
|
||||
gpb.addAttributeDescriptions(std::vector<vk::VertexInputAttributeDescription>{
|
||||
{0, 0, vk::Format::eR32G32B32Sfloat, offsetof(VertexObj, pos)},
|
||||
|
|
@ -597,13 +598,12 @@ void HelloVulkan::createPostPipeline()
|
|||
m_postPipelineLayout = m_device.createPipelineLayout(pipelineLayoutCreateInfo);
|
||||
|
||||
// Pipeline: completely generic, no vertices
|
||||
std::vector<std::string> paths = defaultSearchPaths;
|
||||
|
||||
nvvk::GraphicsPipelineGeneratorCombined pipelineGenerator(m_device, m_postPipelineLayout,
|
||||
m_renderPass);
|
||||
pipelineGenerator.addShader(nvh::loadFile("shaders/passthrough.vert.spv", true, paths, true),
|
||||
pipelineGenerator.addShader(nvh::loadFile("spv/passthrough.vert.spv", true, defaultSearchPaths,
|
||||
true),
|
||||
vk::ShaderStageFlagBits::eVertex);
|
||||
pipelineGenerator.addShader(nvh::loadFile("shaders/post.frag.spv", true, paths, true),
|
||||
pipelineGenerator.addShader(nvh::loadFile("spv/post.frag.spv", true, defaultSearchPaths, true),
|
||||
vk::ShaderStageFlagBits::eFragment);
|
||||
pipelineGenerator.rasterizationState.setCullMode(vk::CullModeFlagBits::eNone);
|
||||
m_postPipeline = pipelineGenerator.createPipeline();
|
||||
|
|
@ -901,7 +901,7 @@ void HelloVulkan::createTopLevelAS()
|
|||
tlas.reserve(m_objInstance.size() + m_lanternCount);
|
||||
|
||||
// Add the OBJ instances.
|
||||
for(int i = 0; i < static_cast<int>(m_objInstance.size()); i++)
|
||||
for(uint32_t i = 0; i < static_cast<uint32_t>(m_objInstance.size()); i++)
|
||||
{
|
||||
nvvk::RaytracingBuilderKHR::Instance rayInst;
|
||||
rayInst.transform = m_objInstance[i].transform; // Position of the instance
|
||||
|
|
@ -1036,27 +1036,22 @@ void HelloVulkan::updateRtDescriptorSet()
|
|||
// 8 =====================================================================================
|
||||
void HelloVulkan::createRtPipeline()
|
||||
{
|
||||
std::vector<std::string> paths = defaultSearchPaths;
|
||||
|
||||
vk::ShaderModule raygenSM =
|
||||
nvvk::createShaderModule(m_device, //
|
||||
nvh::loadFile("shaders/raytrace.rgen.spv", true, paths, true));
|
||||
vk::ShaderModule raygenSM = nvvk::createShaderModule(
|
||||
m_device, nvh::loadFile("spv/raytrace.rgen.spv", true, defaultSearchPaths, true));
|
||||
|
||||
// Miss shader 0 invoked when a primary ray doesn't hit geometry. Fills in clear color.
|
||||
vk::ShaderModule missSM =
|
||||
nvvk::createShaderModule(m_device, //
|
||||
nvh::loadFile("shaders/raytrace.rmiss.spv", true, paths, true));
|
||||
vk::ShaderModule missSM = nvvk::createShaderModule(
|
||||
m_device, nvh::loadFile("spv/raytrace.rmiss.spv", true, defaultSearchPaths, true));
|
||||
|
||||
// Miss shader 1 is invoked when a shadow ray (for the main scene light)
|
||||
// misses the geometry. It simply indicates that no occlusion has been found.
|
||||
vk::ShaderModule shadowmissSM = nvvk::createShaderModule(
|
||||
m_device, nvh::loadFile("shaders/raytraceShadow.rmiss.spv", true, paths, true));
|
||||
m_device, nvh::loadFile("spv/raytraceShadow.rmiss.spv", true, defaultSearchPaths, true));
|
||||
|
||||
// Miss shader 2 is invoked when a shadow ray for lantern lighting misses the
|
||||
// lantern. It shouldn't be invoked, but I include it just in case.
|
||||
vk::ShaderModule lanternmissSM =
|
||||
nvvk::createShaderModule(m_device,
|
||||
nvh::loadFile("shaders/lanternShadow.rmiss.spv", true, paths, true));
|
||||
vk::ShaderModule lanternmissSM = nvvk::createShaderModule(
|
||||
m_device, nvh::loadFile("spv/lanternShadow.rmiss.spv", true, defaultSearchPaths, true));
|
||||
|
||||
std::vector<vk::PipelineShaderStageCreateInfo> stages;
|
||||
|
||||
|
|
@ -1064,74 +1059,71 @@ void HelloVulkan::createRtPipeline()
|
|||
vk::RayTracingShaderGroupCreateInfoKHR rg{vk::RayTracingShaderGroupTypeKHR::eGeneral,
|
||||
VK_SHADER_UNUSED_KHR, VK_SHADER_UNUSED_KHR,
|
||||
VK_SHADER_UNUSED_KHR, VK_SHADER_UNUSED_KHR};
|
||||
rg.setGeneralShader(static_cast<uint32_t>(stages.size()));
|
||||
stages.push_back({{}, vk::ShaderStageFlagBits::eRaygenKHR, raygenSM, "main"});
|
||||
rg.setGeneralShader(static_cast<uint32_t>(stages.size() - 1));
|
||||
m_rtShaderGroups.push_back(rg);
|
||||
// Miss
|
||||
vk::RayTracingShaderGroupCreateInfoKHR mg{vk::RayTracingShaderGroupTypeKHR::eGeneral,
|
||||
VK_SHADER_UNUSED_KHR, VK_SHADER_UNUSED_KHR,
|
||||
VK_SHADER_UNUSED_KHR, VK_SHADER_UNUSED_KHR};
|
||||
mg.setGeneralShader(static_cast<uint32_t>(stages.size()));
|
||||
stages.push_back({{}, vk::ShaderStageFlagBits::eMissKHR, missSM, "main"});
|
||||
mg.setGeneralShader(static_cast<uint32_t>(stages.size() - 1));
|
||||
m_rtShaderGroups.push_back(mg);
|
||||
|
||||
// Shadow Miss
|
||||
mg.setGeneralShader(static_cast<uint32_t>(stages.size()));
|
||||
stages.push_back({{}, vk::ShaderStageFlagBits::eMissKHR, shadowmissSM, "main"});
|
||||
mg.setGeneralShader(static_cast<uint32_t>(stages.size() - 1));
|
||||
m_rtShaderGroups.push_back(mg);
|
||||
|
||||
// Lantern Miss
|
||||
mg.setGeneralShader(static_cast<uint32_t>(stages.size()));
|
||||
stages.push_back({{}, vk::ShaderStageFlagBits::eMissKHR, lanternmissSM, "main"});
|
||||
mg.setGeneralShader(static_cast<uint32_t>(stages.size() - 1));
|
||||
m_rtShaderGroups.push_back(mg);
|
||||
|
||||
// OBJ Primary Ray Hit Group - Closest Hit + AnyHit (not used)
|
||||
vk::ShaderModule chitSM =
|
||||
nvvk::createShaderModule(m_device, //
|
||||
nvh::loadFile("shaders/raytrace.rchit.spv", true, paths, true));
|
||||
vk::ShaderModule chitSM = nvvk::createShaderModule(
|
||||
m_device, nvh::loadFile("spv/raytrace.rchit.spv", true, defaultSearchPaths, true));
|
||||
|
||||
vk::RayTracingShaderGroupCreateInfoKHR hg{vk::RayTracingShaderGroupTypeKHR::eTrianglesHitGroup,
|
||||
VK_SHADER_UNUSED_KHR, VK_SHADER_UNUSED_KHR,
|
||||
VK_SHADER_UNUSED_KHR, VK_SHADER_UNUSED_KHR};
|
||||
hg.setClosestHitShader(static_cast<uint32_t>(stages.size()));
|
||||
stages.push_back({{}, vk::ShaderStageFlagBits::eClosestHitKHR, chitSM, "main"});
|
||||
hg.setClosestHitShader(static_cast<uint32_t>(stages.size() - 1));
|
||||
m_rtShaderGroups.push_back(hg);
|
||||
|
||||
// Lantern Primary Ray Hit Group
|
||||
vk::ShaderModule lanternChitSM =
|
||||
nvvk::createShaderModule(m_device, //
|
||||
nvh::loadFile("shaders/lantern.rchit.spv", true, paths, true));
|
||||
vk::ShaderModule lanternChitSM = nvvk::createShaderModule(
|
||||
m_device, nvh::loadFile("spv/lantern.rchit.spv", true, defaultSearchPaths, true));
|
||||
|
||||
vk::RayTracingShaderGroupCreateInfoKHR lanternHg{
|
||||
vk::RayTracingShaderGroupTypeKHR::eTrianglesHitGroup, VK_SHADER_UNUSED_KHR,
|
||||
VK_SHADER_UNUSED_KHR, VK_SHADER_UNUSED_KHR, VK_SHADER_UNUSED_KHR};
|
||||
lanternHg.setClosestHitShader(static_cast<uint32_t>(stages.size()));
|
||||
stages.push_back({{}, vk::ShaderStageFlagBits::eClosestHitKHR, lanternChitSM, "main"});
|
||||
lanternHg.setClosestHitShader(static_cast<uint32_t>(stages.size() - 1));
|
||||
m_rtShaderGroups.push_back(lanternHg);
|
||||
|
||||
// OBJ Lantern Shadow Ray Hit Group
|
||||
vk::ShaderModule lanternShadowObjChitSM = nvvk::createShaderModule(
|
||||
m_device, //
|
||||
nvh::loadFile("shaders/lanternShadowObj.rchit.spv", true, paths, true));
|
||||
m_device, nvh::loadFile("spv/lanternShadowObj.rchit.spv", true, defaultSearchPaths, true));
|
||||
|
||||
vk::RayTracingShaderGroupCreateInfoKHR lanternShadowObjHg{
|
||||
vk::RayTracingShaderGroupTypeKHR::eTrianglesHitGroup, VK_SHADER_UNUSED_KHR,
|
||||
VK_SHADER_UNUSED_KHR, VK_SHADER_UNUSED_KHR, VK_SHADER_UNUSED_KHR};
|
||||
lanternShadowObjHg.setClosestHitShader(static_cast<uint32_t>(stages.size()));
|
||||
stages.push_back({{}, vk::ShaderStageFlagBits::eClosestHitKHR, lanternShadowObjChitSM, "main"});
|
||||
lanternShadowObjHg.setClosestHitShader(static_cast<uint32_t>(stages.size() - 1));
|
||||
m_rtShaderGroups.push_back(lanternShadowObjHg);
|
||||
|
||||
// Lantern Lantern Shadow Ray Hit Group
|
||||
vk::ShaderModule lanternShadowLanternChitSM = nvvk::createShaderModule(
|
||||
m_device, //
|
||||
nvh::loadFile("shaders/lanternShadowLantern.rchit.spv", true, paths, true));
|
||||
vk::ShaderModule lanternShadowLanternChitSM =
|
||||
nvvk::createShaderModule(m_device, nvh::loadFile("spv/lanternShadowLantern.rchit.spv", true,
|
||||
defaultSearchPaths, true));
|
||||
|
||||
vk::RayTracingShaderGroupCreateInfoKHR lanternShadowLanternHg{
|
||||
vk::RayTracingShaderGroupTypeKHR::eTrianglesHitGroup, VK_SHADER_UNUSED_KHR,
|
||||
VK_SHADER_UNUSED_KHR, VK_SHADER_UNUSED_KHR, VK_SHADER_UNUSED_KHR};
|
||||
lanternShadowLanternHg.setClosestHitShader(static_cast<uint32_t>(stages.size()));
|
||||
stages.push_back(
|
||||
{{}, vk::ShaderStageFlagBits::eClosestHitKHR, lanternShadowLanternChitSM, "main"});
|
||||
lanternShadowLanternHg.setClosestHitShader(static_cast<uint32_t>(stages.size() - 1));
|
||||
m_rtShaderGroups.push_back(lanternShadowLanternHg);
|
||||
|
||||
vk::PipelineLayoutCreateInfo pipelineLayoutCreateInfo;
|
||||
|
|
@ -1257,7 +1249,7 @@ void HelloVulkan::createLanternIndirectCompPipeline()
|
|||
// Compile compute shader and package as stage.
|
||||
vk::ShaderModule computeShader = nvvk::createShaderModule(
|
||||
m_device, //
|
||||
nvh::loadFile("shaders/lanternIndirect.comp.spv", true, defaultSearchPaths, true));
|
||||
nvh::loadFile("spv/lanternIndirect.comp.spv", true, defaultSearchPaths, true));
|
||||
vk::PipelineShaderStageCreateInfo stageInfo;
|
||||
stageInfo.setStage(vk::ShaderStageFlagBits::eCompute);
|
||||
stageInfo.setModule(computeShader);
|
||||
|
|
|
|||
|
|
@ -60,13 +60,10 @@ public:
|
|||
void createTextureImages(const vk::CommandBuffer& cmdBuf,
|
||||
const std::vector<std::string>& textures);
|
||||
|
||||
nvmath::mat4 getViewMatrix()
|
||||
{
|
||||
return CameraManip.getMatrix();
|
||||
}
|
||||
nvmath::mat4 getViewMatrix() { return CameraManip.getMatrix(); }
|
||||
|
||||
static constexpr float nearZ = 0.1f;
|
||||
nvmath::mat4 getProjMatrix()
|
||||
nvmath::mat4 getProjMatrix()
|
||||
{
|
||||
const float aspectRatio = m_size.width / static_cast<float>(m_size.height);
|
||||
return nvmath::perspectiveVK(CameraManip.getFov(), aspectRatio, nearZ, 1000.0f);
|
||||
|
|
@ -113,7 +110,7 @@ public:
|
|||
nvmath::vec3f position;
|
||||
nvmath::vec3f color;
|
||||
float brightness;
|
||||
float radius; // Max world-space distance that light illuminates.
|
||||
float radius; // Max world-space distance that light illuminates.
|
||||
};
|
||||
|
||||
// Information on each colored lantern, plus the info needed for dispatching the
|
||||
|
|
@ -129,7 +126,7 @@ public:
|
|||
int32_t offsetY;
|
||||
|
||||
// Filled in by the host.
|
||||
Lantern lantern;
|
||||
Lantern lantern;
|
||||
};
|
||||
|
||||
// Array of objects and instances in the scene. Not modifiable after acceleration structure build.
|
||||
|
|
@ -172,7 +169,7 @@ public:
|
|||
nvvk::Texture m_offscreenColor;
|
||||
vk::Format m_offscreenColorFormat{vk::Format::eR32G32B32A32Sfloat};
|
||||
nvvk::Texture m_offscreenDepth;
|
||||
vk::Format m_offscreenDepthFormat{vk::Format::eD32Sfloat};
|
||||
vk::Format m_offscreenDepthFormat;
|
||||
|
||||
// #VKRay
|
||||
void initRayTracing();
|
||||
|
|
@ -180,18 +177,18 @@ public:
|
|||
|
||||
private:
|
||||
void fillLanternVerts(std::vector<nvmath::vec3f>& vertices, std::vector<uint32_t>& indices);
|
||||
void createLanternModel();
|
||||
void createLanternModel();
|
||||
|
||||
public:
|
||||
void createBottomLevelAS();
|
||||
void createTopLevelAS();
|
||||
void createRtDescriptorSet();
|
||||
void updateRtDescriptorSet();
|
||||
void createRtPipeline();
|
||||
void createLanternIndirectDescriptorSet();
|
||||
void createLanternIndirectCompPipeline();
|
||||
void createRtShaderBindingTable();
|
||||
void createLanternIndirectBuffer();
|
||||
void createBottomLevelAS();
|
||||
void createTopLevelAS();
|
||||
void createRtDescriptorSet();
|
||||
void updateRtDescriptorSet();
|
||||
void createRtPipeline();
|
||||
void createLanternIndirectDescriptorSet();
|
||||
void createLanternIndirectCompPipeline();
|
||||
void createRtShaderBindingTable();
|
||||
void createLanternIndirectBuffer();
|
||||
|
||||
void raytrace(const vk::CommandBuffer& cmdBuf, const nvmath::vec4f& clearColor);
|
||||
|
||||
|
|
@ -202,7 +199,7 @@ public:
|
|||
nvvk::RaytracingBuilderKHR::BlasInput m_lanternBlasInput{};
|
||||
|
||||
// Index of lantern's BLAS in the BLAS array stored in m_rtBuilder.
|
||||
size_t m_lanternBlasId;
|
||||
size_t m_lanternBlasId;
|
||||
|
||||
vk::PhysicalDeviceRayTracingPipelinePropertiesKHR m_rtProperties;
|
||||
nvvk::RaytracingBuilderKHR m_rtBuilder;
|
||||
|
|
@ -224,8 +221,8 @@ public:
|
|||
// Buffer to source vkCmdTraceRaysIndirectKHR indirect parameters and lantern color,
|
||||
// position, etc. from when doing lantern lighting passes.
|
||||
nvvk::Buffer m_lanternIndirectBuffer;
|
||||
VkDeviceSize m_lanternCount = 0; // Set to actual lantern count after TLAS build, as
|
||||
// that is the point no more lanterns may be added.
|
||||
VkDeviceSize m_lanternCount = 0; // Set to actual lantern count after TLAS build, as
|
||||
// that is the point no more lanterns may be added.
|
||||
|
||||
// Push constant for ray trace pipeline.
|
||||
struct RtPushConstant
|
||||
|
|
@ -241,14 +238,14 @@ public:
|
|||
// -1 if this is the full-screen pass. Otherwise, this pass is to add light
|
||||
// from lantern number lanternPassNumber. We use this to lookup trace indirect
|
||||
// parameters in m_lanternIndirectBuffer.
|
||||
int32_t lanternPassNumber;
|
||||
int32_t lanternPassNumber;
|
||||
|
||||
// Pixel dimensions of the output image.
|
||||
int32_t screenX;
|
||||
int32_t screenY;
|
||||
int32_t screenX;
|
||||
int32_t screenY;
|
||||
|
||||
// See m_lanternDebug.
|
||||
int32_t lanternDebug;
|
||||
int32_t lanternDebug;
|
||||
} m_rtPushConstants;
|
||||
|
||||
// Copied to RtPushConstant::lanternDebug. If true,
|
||||
|
|
@ -261,12 +258,12 @@ public:
|
|||
// Barely fits in 128-byte push constant limit guaranteed by spec.
|
||||
struct LanternIndirectPushConstants
|
||||
{
|
||||
nvmath::vec4 viewRowX; // First 3 rows of view matrix.
|
||||
nvmath::vec4 viewRowY; // Set w=1 implicitly in shader.
|
||||
nvmath::vec4 viewRowX; // First 3 rows of view matrix.
|
||||
nvmath::vec4 viewRowY; // Set w=1 implicitly in shader.
|
||||
nvmath::vec4 viewRowZ;
|
||||
|
||||
nvmath::mat4 proj; // Perspective matrix
|
||||
float nearZ; // Near plane used to create projection matrix.
|
||||
nvmath::mat4 proj; // Perspective matrix
|
||||
float nearZ; // Near plane used to create projection matrix.
|
||||
|
||||
// Pixel dimensions of output image (needed to scale NDC to screen coordinates).
|
||||
int32_t screenX;
|
||||
|
|
|
|||
|
|
@ -34,10 +34,10 @@
|
|||
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE
|
||||
|
||||
#include "imgui.h"
|
||||
#include "imgui_impl_glfw.h"
|
||||
#include "imgui/backends/imgui_impl_glfw.h"
|
||||
|
||||
#include "hello_vulkan.h"
|
||||
#include "imgui_camera_widget.h"
|
||||
#include "imgui/extras/imgui_camera_widget.h"
|
||||
#include "nvh/cameramanipulator.hpp"
|
||||
#include "nvh/fileoperations.hpp"
|
||||
#include "nvpsystem.hpp"
|
||||
|
|
@ -110,15 +110,13 @@ int main(int argc, char** argv)
|
|||
}
|
||||
|
||||
// setup some basic things for the sample, logging file for example
|
||||
NVPSystem system(argv[0], PROJECT_NAME);
|
||||
NVPSystem system(PROJECT_NAME);
|
||||
|
||||
// Search path for shaders and other media
|
||||
defaultSearchPaths = {
|
||||
PROJECT_ABSDIRECTORY,
|
||||
PROJECT_ABSDIRECTORY "..",
|
||||
NVPSystem::exePath(),
|
||||
NVPSystem::exePath() + "..",
|
||||
NVPSystem::exePath() + std::string(PROJECT_NAME),
|
||||
NVPSystem::exePath() + PROJECT_RELDIRECTORY,
|
||||
NVPSystem::exePath() + PROJECT_RELDIRECTORY "..",
|
||||
std::string(PROJECT_NAME),
|
||||
};
|
||||
|
||||
// Requesting Vulkan extensions and layers
|
||||
|
|
@ -180,16 +178,16 @@ int main(int argc, char** argv)
|
|||
// Creation of the example
|
||||
helloVk.loadModel(nvh::findFile("media/scenes/Medieval_building.obj", defaultSearchPaths, true));
|
||||
helloVk.loadModel(nvh::findFile("media/scenes/plane.obj", defaultSearchPaths, true));
|
||||
helloVk.addLantern({ 8.000f, 1.100f, 3.600f}, {1.0f, 0.0f, 0.0f}, 0.4f, 4.0f);
|
||||
helloVk.addLantern({ 8.000f, 0.600f, 3.900f}, {0.0f, 1.0f, 0.0f}, 0.4f, 4.0f);
|
||||
helloVk.addLantern({ 8.000f, 1.100f, 4.400f}, {0.0f, 0.0f, 1.0f}, 0.4f, 4.0f);
|
||||
helloVk.addLantern({ 1.730f, 1.812f, -1.604f}, {0.0f, 0.4f, 0.4f}, 0.4f, 4.0f);
|
||||
helloVk.addLantern({ 1.730f, 1.862f, 1.916f}, {0.0f, 0.2f, 0.4f}, 0.3f, 3.0f);
|
||||
helloVk.addLantern({8.000f, 1.100f, 3.600f}, {1.0f, 0.0f, 0.0f}, 0.4f, 4.0f);
|
||||
helloVk.addLantern({8.000f, 0.600f, 3.900f}, {0.0f, 1.0f, 0.0f}, 0.4f, 4.0f);
|
||||
helloVk.addLantern({8.000f, 1.100f, 4.400f}, {0.0f, 0.0f, 1.0f}, 0.4f, 4.0f);
|
||||
helloVk.addLantern({1.730f, 1.812f, -1.604f}, {0.0f, 0.4f, 0.4f}, 0.4f, 4.0f);
|
||||
helloVk.addLantern({1.730f, 1.862f, 1.916f}, {0.0f, 0.2f, 0.4f}, 0.3f, 3.0f);
|
||||
helloVk.addLantern({-2.000f, 1.900f, -0.700f}, {0.8f, 0.8f, 0.6f}, 0.4f, 3.9f);
|
||||
helloVk.addLantern({ 0.100f, 0.080f, -2.392f}, {1.0f, 0.0f, 1.0f}, 0.5f, 5.0f);
|
||||
helloVk.addLantern({ 1.948f, 0.080f, 0.598f}, {1.0f, 1.0f, 1.0f}, 0.6f, 6.0f);
|
||||
helloVk.addLantern({-2.300f, 0.080f, 2.100f}, {0.0f, 0.7f, 0.0f}, 0.6f, 6.0f);
|
||||
helloVk.addLantern({-1.400f, 4.300f, 0.150f}, {1.0f, 1.0f, 0.0f}, 0.7f, 7.0f);
|
||||
helloVk.addLantern({0.100f, 0.080f, -2.392f}, {1.0f, 0.0f, 1.0f}, 0.5f, 5.0f);
|
||||
helloVk.addLantern({1.948f, 0.080f, 0.598f}, {1.0f, 1.0f, 1.0f}, 0.6f, 6.0f);
|
||||
helloVk.addLantern({-2.300f, 0.080f, 2.100f}, {0.0f, 0.7f, 0.0f}, 0.6f, 6.0f);
|
||||
helloVk.addLantern({-1.400f, 4.300f, 0.150f}, {1.0f, 1.0f, 0.0f}, 0.7f, 7.0f);
|
||||
|
||||
helloVk.createOffscreenRender();
|
||||
helloVk.createDescriptorSetLayout();
|
||||
|
|
@ -301,7 +299,7 @@ int main(int argc, char** argv)
|
|||
helloVk.drawPost(cmdBuf);
|
||||
// Rendering UI
|
||||
ImGui::Render();
|
||||
ImGui::RenderDrawDataVK(cmdBuf, ImGui::GetDrawData());
|
||||
ImGui_ImplVulkan_RenderDrawData(ImGui::GetDrawData(), cmdBuf);
|
||||
cmdBuf.endRenderPass();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue