Skip to content

Latest commit

 

History

History
 
 

base_sample

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

glTF Simple

img img

This sample is a glTF scene renderer with is using both the Vulkan rasterizer and ray tracer. The functionality is minimal, but offers enough to be a starting point for many other examples.

Loading Scenes

Loading a scene can be done using an argument: vk_base_sample.exe -f path_to_scene\a_scene.gltf

Or, after start up, drag&drop a .gltf scene in the main window.

Functionalities

Rendering Mode

Select raster or ray tracing, and ray tracing settings

img

Cameras

Position and camera manipulation style. Double click set the center of interest.

img

Environment

Clear color, tone mapping and 2 default lights.

img

Schema of the program

  1. The initialization of Vulkan and enabling extensions is done in main.cpp using the nvvk::Context
  2. Loading the glTF scene uses tinygltf and nvh::GltfScene to get teh data in an abstracted form.
    1. Each primitive has its own allocated buffer of Vertex and indices. (createVertexBuffer)
    2. Materials are only a subset of glTF and are in a separated buffer. (createMaterialBuffer)
    3. Textures are loaded and mipmap are generated. (createTextureImages)
    4. Array of matrices for each node are stored in a separate buffer. (createInstanceInfoBuffer)
  3. The infinite rendering loop is done in main.cpp, and define the following rendering loop skeleton.
  4. Ray tracing uses the RTX pipeline, in addition to the scene descriptor set, it adds the top-level-acceleration-structure (TLAS) and a reference to the offscreen image for writing the result.
  5. The raster is rendering in an offscreen framebuffer, sharing the same image as for the raytracer. It loops over all node and render each primitives. This loop is recorded in a secondary command buffer, to be more rapidely executed (no CPU overhead) on the next frames.
  6. The resulted image is then rendered in the swapchain frame buffer, using a fullscreen quad. A fragment program will also apply tonemapping.
  7. In the same last render pass, the Ui from Dear Imgui is rendered on top.

img

Note: This example is a modification of the ray_tracing_gltf tutorial.

Chapters