All Projects → nvpro-samples → Vk_denoise

nvpro-samples / Vk_denoise

Denoising a Vulkan ray traced image using OptiX denoiser

Programming Languages

c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to Vk denoise

Vk raytracing tutorial
Vulkan ray tracing tutorials
Stars: ✭ 144 (+251.22%)
Mutual labels:  vulkan, raytracing
zig-gamedev
Building game development ecosystem for @ziglang!
Stars: ✭ 1,059 (+2482.93%)
Mutual labels:  vulkan, raytracing
Wickedengine
3D engine focusing on modern rendering techniques and performance.
Stars: ✭ 3,148 (+7578.05%)
Mutual labels:  vulkan, raytracing
Vk raytrace
Ray tracing glTF scene with Vulkan
Stars: ✭ 91 (+121.95%)
Mutual labels:  vulkan, raytracing
Diligentcore
Core functionality of Diligent Engine
Stars: ✭ 263 (+541.46%)
Mutual labels:  vulkan, raytracing
Raytracedshadows
This demo implements BVH construction and GPU traversal for rendering hard shadows.
Stars: ✭ 107 (+160.98%)
Mutual labels:  vulkan, raytracing
awesome-rtx
Curated collection of projects leveraging NVIDIA RTX technology (OptiX, DXR, VKR)
Stars: ✭ 73 (+78.05%)
Mutual labels:  vulkan, raytracing
Lift
Vulkan Path Tracer with Optix Denoiser integration
Stars: ✭ 30 (-26.83%)
Mutual labels:  vulkan, raytracing
CLUSEK-RT
Vulkan based C++ ray-tracing game engine.
Stars: ✭ 24 (-41.46%)
Mutual labels:  vulkan, raytracing
vulkan-raytracing
"Simple" Vulkan raytracing
Stars: ✭ 27 (-34.15%)
Mutual labels:  vulkan, raytracing
Flycube
Graphics API wrapper is written in C++ on top of Directx 12 and Vulkan. Provides main features including ray tracing.
Stars: ✭ 78 (+90.24%)
Mutual labels:  vulkan, raytracing
Vk raytracing tutorial khr
Ray tracing examples and tutorials using VK_KHR_ray_tracing
Stars: ✭ 461 (+1024.39%)
Mutual labels:  vulkan, raytracing
Gears Vk
Powerful low-level C++20 rendering framework for Vulkan 1.2, including Real-Time Ray Tracing (RTX) support, built atop Auto-Vk.
Stars: ✭ 71 (+73.17%)
Mutual labels:  vulkan, raytracing
Diligentengine
A modern cross-platform low-level graphics library and rendering framework
Stars: ✭ 2,142 (+5124.39%)
Mutual labels:  vulkan, raytracing
Nabla
OpenGL/OpenGL ES/Vulkan/CUDA/OptiX Modular Rendering Framework for PC/Linux/Android
Stars: ✭ 235 (+473.17%)
Mutual labels:  vulkan, raytracing
Quartz
Vulkan RTX path tracer with a declarative ES7-like scene description language.
Stars: ✭ 367 (+795.12%)
Mutual labels:  vulkan, raytracing
Vk mini path tracer
A beginner-friendly Vulkan path tracing tutorial in under 300 lines of C++.
Stars: ✭ 599 (+1360.98%)
Mutual labels:  vulkan, raytracing
Acid
A high speed C++17 Vulkan game engine
Stars: ✭ 838 (+1943.9%)
Mutual labels:  vulkan
Raytracinginoneweekend
RayTracing tutorial use Java&Cpp
Stars: ✭ 33 (-19.51%)
Mutual labels:  raytracing
Code Red
A Graphics Interface for DirectX12 and Vulkan
Stars: ✭ 27 (-34.15%)
Mutual labels:  vulkan

VK_DENOISE

This example will ray trace a glTF scene (-f <scene.gltf>) using a simplified path tracing technique and focus on the denoiser. Path-tracing is generally very noisy for the first frames and using a denoiser helps getting a converged image quicker. For the denoiser, we will be using the Optix7 denoiser.

The OptiX denoiser is using Cuda, so our image will need to be shared between Vulkan and Cuda. The denoiser is actually requiring linear images, which are not available to Vulkan, so instead of directly sharing the images, we are creating buffers which are shared between Vulkan and Cuda and we are copying the image to the buffer, converting them to linear images.

External Memory

Only the buffers, which are the linear-image copy of the default tiled image, are created with the external memory flag. For the allocation, we are using a derived class of the dedicated allocator, which is adding the flag decoration on the buffer allocation and memory allocation. See also the examples on interop: https://github.com/nvpro-samples/gl_vk_simple_interop and https://github.com/nvpro-samples/gl_vk_raytrace_interop.

Timeline Semaphore

The denoiser is using Cuda and rendering is done with Vulkan, if we would simply add all Vulkan commands to a single command buffer, we would not be synchronized and the image to display will be sometime denoised, sometime not. We could add a hard synchronization on the CPU, making sure the ray traced is finished, denoised the image, wait for it, then display. But this would be losing a lot of the GPU cycle. Instead, we are adding a Vulkan timeline semaphore to signal when the ray traced image is rendered and transferred the buffer and a Cuda wait semaphore to hold the execution of the denoiser on the GPU. We add the inverse process at the end of the denoiser with a Cuda semaphore signaling the image is denoised and on Vulkan a wait semaphore to copy the buffer back to an image, tonemap it and display.

Nsight System

The following image was done using Nsight System, which is at the time of writing those lines, the only tool which can inspect both Vulkan ray tracing and Cuda simultaneously. In the following image; the rendering was set to start denoising the image after 10 iterations. It is quicker to render and not denoising each frame. Also, sometimes the denoiser is not that great with the first few frames, as the image is too noisy to reconstruct it correctly. After 10 frames, the denoiser will be apply on frame #11. Because the frame #11 is really long to do, the in-flight frames will be displayed before it even finishes.

vk_denoise2

This is a closeup on what is happening while denoising a frame. The first command buffer gets the ray tracing and image copy commands and is submitted. The Cuda wait semaphore is done before calling the OptiX denoiser. Cuda commands are called, but they won't be executed before the ray tracing is completed. At the end of cuda, Vulkan waits to take back the control and the second command buffer, which is transferring the buffer to image, tonemap and display will be executed.

vk_denoise2

Possible Modifications

The denoiser is setup to use RGB, ALBEDO and NORMAL buffers. All three buffers help getting a clearer image faster, but it is also possible to use only RGB + ALBEDO or RGB only. This information to the denoiser is done in DenoiserOptix::initOptiX(). By modifying the inputKind and re-running the example, you can see how the denoiser is behaving. Using all three buffers is especially useful with images having texture details, bumps, cracks and other fine details.

The other modification would be to tonemap the image before sending it to the denoiser and use the LDR denoiser training set. This could be better in some cases, as the training set was done on a less high variance, but this might not give radical improvements.

Results

Denoiser OFF

vk_denoise

Denoiser ON

vk_denoise2

Denoiser OFF

vk_denoise

Denoiser ON

vk_denoise2

Tags:

  • raytracing, path-tracing, GLTF, HDR, tonemapper, picking, BLAS, TLAS, PBR material, denoising, Cuda, interop

Extensions:

  • VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME, VK_NV_RAY_TRACING_EXTENSION_NAME, VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME, VK_KHR_MAINTENANCE3_EXTENSION_NAME, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME, VK_KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_EXTENSION_NAME, VK_KHR_EXTERNAL_FENCE_CAPABILITIES_EXTENSION_NAME, VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME, VK_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME, VK_KHR_EXTERNAL_SEMAPHORE_EXTENSION_NAME, VK_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME, VK_KHR_EXTERNAL_FENCE_EXTENSION_NAME, VK_KHR_EXTERNAL_FENCE_WIN32_EXTENSION_NAME,
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].