Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on March 30, 2023, between 5 am & 1 pm EST, in the Performance Profiling Dev Blitz Day 2023 - Q&A forum and Discord where you can connect with our teams behind the Memory and CPU Profilers.
    Dismiss Notice

Is the real-time ray tracing really ray tracing

Discussion in 'General Graphics' started by MikeyJY, Nov 25, 2021.

  1. MikeyJY

    MikeyJY

    Joined:
    Mar 2, 2018
    Posts:
    526
    The nvidia RTX GPUs that are promoted and the games that have the real time RTX option. Is that really ray tracing in the true sense of the word? Because the ray tracing used in baked CGI is 100% not computable in real-time.
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    11,995
    Traditional ray tracing works by shooting rays out from the camera and finding the first surface the ray hits. Then for lighting it shoots rays out from that point towards the lights in the scene to see if there’s anything between it and the light source. Transparent surfaces, as well as reflective and refractive surfaces, then shoot out a ray to find another surface.

    RTX GPUs are perfectly capable of doing this in real time. Really GPUs have been able to do this to some degree without specialized hardware for a long time. But it doesn’t offer a lot of benefits over rasterization for most things, apart from more accurate complex reflections and refractions. Sure you can get perfectly sharp shadows, but most of the time you don’t actually want perfectly sharp shadows. To get blurry shadows with raytracing you need to shoot out a bunch of rays in slightly different directions towards the light source(s) to see if you hit each light’s “volume” instead of just its punctual position, and that’s expensive.

    Now almost all modern CGI is using some form of path tracing, which is ray tracing that instead of just tracing from the hit surface toward the lights bounces many rays randomly in all directions, potentially hundreds or even thousands of rays per pixel per object hit. These rays hit new surfaces and emit even more rays. Some rays may hit lights, some rays may hit surfaces that are lit, and the lighting for each surface is the sum of all of light from the surfaces the rays hit. This is very expensive, and certainly not something we can do in real time.



    Except we can, and some RTX enabled games do. The trick, as with many techniques for modern real time rendering, is to do the work over multiple frames. Or do things at a lower resolution than the screen resolution. One advantage of raytracing is it doesn’t need to match the screen pixels at all, you can ”spender more rays going to the places and directions that are important. On top of that there are a ton of modern techniques for reconstructing images from fewer rays that, while not 100% accurate, are close enough to be indistinguishable from the massively more expensive “ground truth”.


    https://developer.nvidia.com/blog/rendering-millions-of-dynamics-lights-in-realtime/

    Of course, no game is using this. Not yet at least. And there’s a big difference between a tech demo running on the latest, fastest GPU that doesn’t have to also do things like have an actual game running at the same time, and something that can be used in a game that can run on hardware real people have.

    For real games they’re almost universally still using default rasterization for most things. Generally what raytracing is being used for is to augment the existing rendering techniques games already use. A really common one is for games to use raytraced ambient occlusion. This is much more accurate and more stable than screen space ambient occlusion common in games now for the last 15 years. You don’t get the AO disappearing on the edges of the screen or when objects pass in front of each other. Reflections are also a really common use case, as they can be real accurate reflections which is impossible when using rasterization. But usually the raytracing is being used to get surfaces visible in the reflection, and then lighting those surfaces using rasterized shadows, without AO, and without secondary reflections or using the same cube maps that would have been used when not using ray tracing.

    Some games do use raytracing for lighting and shadows. Sometimes using a simplified version of the scene to calculate the ambient and bounced lighting. Or using raytracing just for “contact shadows”, or the sharp shadows near where an object touches a surface / self shadows, and using traditional rasterized shadows for the blurrier shadows elsewhere.
     
    Torbach78 likes this.
  3. MikeyJY

    MikeyJY

    Joined:
    Mar 2, 2018
    Posts:
    526
    I saw on YouTube RTX GPUs being promoted to run Custom RTX Shaders for Minecraft, and I was: Who on earth buy a GPU to run minecraft ray tracing and that's not even ray tracing in the true sense of the word. From what you explained I understand that that thing can be called ray tracing, however it doesn't offer that much of a difference, besides some minor enhancing effects. I thought that ray tracing is what cycles is in blender which takes about 1 seconds to update the render buffer on a decent gpu. In conclusion(if I understood correctly), real-time ray tracing is really ray tracing, however you can't get an immense render quality difference in real-time.
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    11,995
    So, funny thing about Minecraft RTX. That’s running the equivalent of a full CGI movie level path tracing. Shadows, reflections, refraction, bounced lighting, everything, is fully raytraced. Minecraft is currently the most raytraced RTX game out there.

    As for “who would buy an RTX GPU to run Minecraft?” People who want to play Minecraft with all of the visual bells and whistles on, which is a surprising number of people.