Skip to content

Experiments in rendering using Vulkan and hardware accelerated Raytracing

Notifications You must be signed in to change notification settings

Senryoku/VulkanExp

Repository files navigation

VulkanExp

3D renderer written to gain some experience with Vulkan, and modern rendering techniques (mainly hardware raytracing). As the name suggests, this is just an experiment: Nothing is done, nothing is polished.

image

Features

  • Renderer
    • Rasterisation and Raytracing hybrid: Rasterized GBuffer and additional raytraced passes for effects (shadows/reflections).
    • Dynamic Diffuse Global Illumination (DDGI) : Presentation
    • Raytraced Shadows (Single source for now, a directional sun, could be easily expanded to a second one using the same output buffer.)
      • Single ray per pixel
      • Filtered by a depth-aware gaussian kernel.
      • Accumulated over multiple frames with reprojection and history invalidation.
    • Raytraced Reflections
      • Also 1spp and filtered in a similar way as shadows.

Todos

  • Decouple the Renderer from the Editor

Bugs

  • GI
    • Probes update sometimes generate a extremely bright spot, cause unknown (but disabling the sky doesn't solves the problem).
  • Probably a lot.

Major Features

  • Remove vertex color?
  • Scene
    • Save (!)
      • Decide on a format...
      • Support external resources (or not?)
      • Actually support all existing components and resources
      • Convert images to a common format? QOI?
    • Select Nodes
      • Create empty node, add 'components'
      • Disable Rendering (Update BLAS/TLAS and re-record Command Buffers)
    • Refer to assets with their path (avoid reloading the same one twice)
      • Refer to Materials by path/name (make sure names are unique on load)
    • Manually create new materials
  • Motions vectors
  • Some sort of (small scale) AO. Also raytraced? or SSAO? or even baked?
    • Also allow the use of texture AO.

Improvements

  • Reflections
    • Start by using SSR and raytrace only as a fallback (will probably need a bit of restructuring, doing SSR in a raygen shader seems to be horrible)
    • Correctly reproject reflections for temporal filtering (See http://bitsquid.blogspot.com/2017/06/reprojecting-reflections_22.html, needs a depth hystory)
    • Use motions vectors for reprojection and accumulation
  • Shadows
    • Sun Direction in UBO
    • Use motions vectors for reprojection and accumulation
  • GI
    • Optimise probe placement?
    • More refined probes state?
  • Move all rendering related code to its own class (Mostly remove all rendering code from Scene)
  • Many

Nice to have

  • Multisampling (Raster & RT)

Major Features, but not priorities

  • Skinned Meshes
    • Notes: Since the raytracing pass will require a BLAS update anyway, we'll use the underlying vertex buffer for rastering too, rather than computing the updated vertex position in a vertex shader, as we should in a raster-only pipeline.
    • FIXME: (Perf) Way too many GPU synchonisation everywhere (transfer wait queue idle).
    • TODO: Generate proper motion vectors.
    • TODO: Separate Skeleton Animation updates and Skinning.
    • TODO: Use a different mask for acceleration structure instances of dynamic meshes and static meshes. Do not disable irradiance probe inside dynamic meshes (since they're expected to move) by using this mask to avoid tracing dynamic instances on probe initialisation.
    • TODO: Support everything tied to skinning and animation with our scene format (save/load).

Scene Format

Heavily inspired by the glTF binary format, it consists of a header, followed by a series of chunks, each with their own header.

struct Header {
    uint32_t magic;    // "SCEN" (0x4e454353)
    uint32_t version;
    uint32_t length;   // Total file length, in bytes.
};

struct ChunkHeader {
    uint32_t length; // Length in bytes
    uint32_t type;   // "JSON" (0x4E4F534A) or " BIN" (0x004E4942)
};
// Immediately followed by 'length' bytes of binary data.

Build

Build using Visual Studio 2022 with c++20 preview support (/std:c++latest)

Dependencies

About

Experiments in rendering using Vulkan and hardware accelerated Raytracing

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published