Search Unity

Ray Tracing with Native Plug-in

Discussion in 'General Graphics' started by afuzzyllama, Jan 30, 2021.

  1. afuzzyllama

    afuzzyllama

    Joined:
    May 19, 2010
    Posts:
    20
    RTUnity.gif
    Above screenshot shows hardware accelerated ray tracing in Unity3D using the latest (1.2.162.1) Vulkan SDK with a custom render pipeline.

    Code can be found here:
    https://github.com/afuzzyllama/UnityRayTracingPlugin

    The code might be super smelly (I'm not really an experienced Vulkan or C++ dev) and I wouldn't advise building anything around it, but it was a fun experiment and I figured I'd share.
     
    Last edited: Feb 11, 2021
    NotaNaN and radiantboy like this.
  2. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    1,633
    This seems huge!.. Can it work with built in render pipeline? guessing not. nice work!.
     
  3. afuzzyllama

    afuzzyllama

    Joined:
    May 19, 2010
    Posts:
    20
    I'm not sure, but maybe? Currently, it makes a call to the ray tracing shader and then blits the result to the camera currently being rendered. My goal was to replace the rasterization pipeline with a pure ray tracing one, but it might be possible to call the ray tracing shader and apply its output like a post process?

    However, I have a feeling Unity has a team dedicated to that since they have ray tracing as part of the HDRP already. Looks like their focus is the DirectX implementation. I used Vulkan because 1) I already did it as a standalone side project so I was basically porting over some code to Unity and 2) maybe someone on Linux wants to ray some rays!
     
    radiantboy likes this.
  4. btristan

    btristan

    Joined:
    Oct 15, 2018
    Posts:
    95
    Any chance this works on Linux? If not, could you give me a quick summary of what I'd have to change to get this working on Linux?
     
  5. afuzzyllama

    afuzzyllama

    Joined:
    May 19, 2010
    Posts:
    20
    I have no idea if it will work on Linux or not, but if you can get it building then maybe? The only area you'd have to consider is the "PluginSource" since that is what is specific to the platform.

    The only starting points I can give you is to look at PlatformBase.h and add define UNITY_LINUX and then in vulkan.h add the vulkan headers for Linux.

    Also in /Vulkan/RayTracer.cpp you might need to add a Linux Vulkan extension that adds surface support.
     
    btristan likes this.