This sample demonstrates basic quad rendering using vertex and fragment shaders, building upon the concepts introduced in the solid_color
sample. It showcases the implementation of a simple geometry pipeline and the use of G-Buffers for off-screen rendering.
When RectangleSample
is added to nvvk::Application
, the onAttach(app)
method is invoked, performing the following tasks:
- Instantiates a memory allocator for efficient resource management.
- Initializes a debug utility for resource naming and visualization in Nsight Graphics.
- Creates the rendering pipeline via
createPipeline()
, defining the rendering configuration. - Generates vertex and index buffers defining the rectangle geometry in
createGeometryBuffers()
.
The onResize(w,h)
method manages G-Buffer creation:
- Color format:
VK_FORMAT_R8G8B8A8_UNORM
- Depth format: Dynamically queried to optimize for the current physical device
- The rectangle is rendered into the G-Buffer, not directly to the swapchain.
- G-Buffer contents are displayed using ImGui in
onUIRender()
.
Utilizes Vulkan Dynamic Rendering:
- Attaches G-Buffer color and depth targets.
- Executes primitive rendering.
- Shader Types: Vertex and Fragment
- Geometry: Single quad (rectangle)
- Rendering Technique: Off-screen G-Buffer rendering with ImGui display
- Vulkan Features: Dynamic Rendering