2
$\begingroup$

In this YouTube video, the creator mentions that reflections in Unreal Engine 5's Lumen "work by tracing the path of light as it bounces off of surfaces in the game world." Does this mean that Lumen uses raytracing? I thought that this was difficult to do in real time on consumer hardware. But more importantly, how can I implement the same technique? Can I do that with OpenGL or Vulkan? How much of the existing rendering pipeline do I in that case need to re-implement myself, and how much of it can I reuse?

Side note: I don't only plan to use it for reflections, but also for transparent objects that bend light in various ways (for which rendering to a texture doesn't work because there is not a single point from which to do that rendering), but I—perhaps somewhat naively—assume that reflections and refractions can both be implemented using the same or very similar techniques.

$\endgroup$

1 Answer 1

3
$\begingroup$

Whether you use Lumen with hardware acceleration or not, Lumen is based on ray tracing. Software mode uses signed distance fields (SDF) to find intersections along a ray and so called cards to store lighting on geometry. Hardware accelerated ray tracing finds intersection using triangle-based geometry, which can be more precise if the original geometry also is made out of triangles.

You might find this interesting: "https://knarkowicz.wordpress.com/2022/08/18/journey-to-lumen/", the history of Lumen. I would imagine that a lot of optimization was required, they use a LOD system as an example.

I assume that you want to ray trace SDF:s in your program. Since I don't know enough about your project, I will just assume that you have triangle meshes. An approach is to use a SDF volume centered around each mesh object, inject them into a BVH and trace the SDF volumes along the ray (I think this is the unreal approach). Cards are harder to implement, maybe a volumetric approach is easier in your case?

$\endgroup$
4
  • $\begingroup$ Thanks for the answer and for the link! I understand that Lumen has a software rendering mode, but why would anyone choose not to use hardware acceleration since pretty much every computer today has a GPU? $\endgroup$ Mar 14, 2023 at 0:08
  • $\begingroup$ Why do you assume that I'm going to use signed distance fields? Yes, I have triangle meshes—doesn't that mean that I naturally want to use more or less standard computer graphics techniques as much as possible, which are not SDF-based? They seem superior compared with SDFs to me (I imagine they are both quicker and more exact) if you can use them without losing quality. Or isn't that possible for some reason when doing ray tracing? $\endgroup$ Mar 14, 2023 at 0:18
  • 2
    $\begingroup$ By hardware acceleration I mean specific hardware that computes the triangle or BVH intersections tests, like the RT cores in the RTX gpus. Software ray tracing does not need that specific hardware to work. I assumed you wanted to use SDF:s as that is what Lumen in known for (in a way) unless you specifically target GPU:s that can accelerate the triangle intersection stage. With that said, triangle intersections are possible without them but there might be more work maintaining acceleration structures. $\endgroup$
    – Mathis
    Mar 14, 2023 at 7:13
  • $\begingroup$ Yes, I specifically target GPUs. Does that mean I can re-use OpenGL's (or Vulkan's) triangle-intersection functionality, including the accelerating structures for testing for triangle intersections that it has already created, in the ray tracer? Do you know if there is any documentation or guide that explains how to do that somewhere? It would be great if I didn't have to implement my own triangle intersection test but could re-use as much as possible of OpenGL's (or Vulkan's) already existing functionality to do that (and other things, such as vertex interpolation, if that is possible). $\endgroup$ Mar 15, 2023 at 13:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.