Simulation / Modeling / Design

Ray Tracing in Unreal Engine 4: Top 10 Developer Questions

We recently hosted Ray Tracing in Unreal Engine 4, a webinar now available on-demand that guides you on best practices for producing real-time ray-traced reflections, global illumination, shadows, and more.

At the end of the webinar, we hosted a Q&A session, and received an overflow of excellent questions from the audience. Our speakers, Richard Cowgill and Allen Bourgoyne, provide answers to ten of the most common questions.

What’s the difference between NVIDIA GeForce, TITAN, and Quadro RTX GPUs when used for ray tracing?

From a platform standpoint, GeForce and TITAN are designed for PCs, and Quadro for workstations. All the RTX versions of these cards give great ray tracing performance. As you go up the product stack, performance and GPU memory capacity will go up.

The TITAN RTX GPU provides 24 GB of GPU memory, so it has the potential to work with larger renders than GeForce GPUs. The Quadro RTX 8000 has 48 GB of GPU memory, so the largest and most complex renders that require the most GPU memory are target workloads for Quadro cards.

What are the advantages of ray tracing over normal graphics?

Ray tracing is used to create photorealistic images. Before ray tracing, “tricks” were used to try to create photorealistic images, using standard graphics techniques to emulate shadows or reflections. There are always limitations when using these “tricks” to simulate photorealistic images. For example, shadows or reflections don’t look quite as they would in the real world.

With ray tracing, we are actually tracing the path of light through the scene, so the result is accurate as to what it would look like in the real world. All of the various components of the scene, such as reflection, transparent objects, and shadows, look natural. Ray tracing provides a level of realism in graphics that was just not possible with traditional graphics techniques.

Ray-traced caustics will provide translucent colored light refraction and reflection, and it will impact everything from water and stained glass windows, diamonds, lenses, and much more.

How much memory does a basic RTX setup require for development?

This depends on the complexity of your scene. Ray tracing requires two new memory allocations: Top Level Acceleration Structure (TLAS) and Bottom Level Acceleration Structure BLAS.

In essence, the BLAS contains all the raw data loaded to memory that ray tracing will need to consider, but hasn’t yet processed. It’s common for the BLAS to be hundreds of megabytes in size.

The TLAS is typically way smaller and is the only relevant or considered geometry that ray tracing will do it’s work against. It’s common to see a BLAS of 500 MB and a TLAS of 5 MB—it can be that big of a difference.

It is true that this memory will come out of your GPU, but this is partly why RTX cards are designed with a lot more memory than past cards. They have more than enough extra memory to handle the additional processing ray tracing requires.

You can see your TLAS/BLAS memory usage with the console command stat d3d12raytracing.

I’m using UE4 to make a feature film and I have an RTX 2080Ti. Can I join the NVIDIA Developer Program and get access to DLSS2?

Yes!  Anyone is welcome to be a part of our Developer Program and get access to our branch, tools, and new features.

Do shaders have to be optimized in any way to work better with RTX? Any particular attention we need to have during texturing, for example?

Keep in mind that 98% of everything in the material system works the same. The main thing to be aware of is the Ray Tracing Quality Switch Replace node in the material system. This is for optimizing reflection costs.

Past that, it’s good to be aware that a few material functions will work differently or not at all. World Position Offsets (WPO) can work on individual meshes (but not foliage or HLOD meshes) if the mesh is flagged to make use of WPO in its instanced settings (in the details pane of the editor). Pixel Depth Offsets (PDO), often used for stencil-alpha mesh blending, will not work with ray traced shadows.

But if you want to keep compatibility with PDO materials in ray tracing mode, I’d recommend you set your project up to flatten PDO values globally to zero when the user turns ray tracing on.

What’s a good resource for those just starting out with ray tracing?  I’d like to understand how it functions from the ground up!

A good place to start is Epic’s Unreal Documentation on Ray Tracing. Not only does it go over the feature set, it makes clear what works and what doesn’t. It’s also good to learn the basics of ray tracing as a concept, separate from game engines. Besides, we have some explanations on the basics on the ray tracing definition page, as well as on the ray tracing resource page. But there are many good sources to learn all about ray tracing. Understanding those fundamentals will help you make sense out of what is going on in real time. 

Is there a limit for the number of light sources used with ray-traced GI? Most demos I’ve seen use one global light source and are based in an open, natural environment with no artificial lighting, but especially City Sets need many more lights to be realistic.

No limit.

What is the performance difference with a large number of light sources in rasterization (deferred) vs ray tracing?

Not much! If we’re talking about dynamic lights that don’t cast shadows, UE4 can render lots of these. I wouldn’t say they’re free, but they’re very inexpensive. And it won’t matter if your scene is raster or ray-traced, non-shadow lights are treated the same and you can render lots of these. 

However, when they cast shadows dynamically, they get much more expensive. How many you can render will depend on a number of factors. What is the light touching? How complex are the lit objects? How much do they overlap? One assumption is that however many of these types of lights you can handle in raster you can handle a similar amount in ray tracing.

As a general ballpark, that might be only a handful of lights, so think about tightening up your radiuses and culling lights based on distance whenever possible.

Is there a way to control which model uses rasterization and which one will use ray tracing?

Yes! Each mesh has a rendering flag to make it visible to ray tracing. Any mesh taken out of ray tracing will still render, it will just be rendered using raster systems. So no reflections or ray-traced shadows. Some objects may not need to be ray-traced (distant skybox meshes are a good example), and taking them out of ray tracing consideration can be an important optimization for many scenes.

Also worth noting that any mesh taken out of ray tracing will not count towards TLAS/BLAS memory, so that distant skybox art you have won’t add to the ray tracing memory either.

These sorts of decisions are dependent on what’s important to your project. Like any game, the more selective processing you can do on objects, the faster the system will be, and the higher your frame rate ultimately. I wouldn’t do any optimizations that aren’t necessary to achieve your goals, so if you’re hitting your performance target then you are good to go.

RTXGI adds soft shadows and bounce light to an otherwise flat scene.
Same scene without RTXGI (65fps on a GeForce RTX 2080 Ti).

Realistically, when will (if ever?) games use light emitting objects only, with no “lights” as we have today?

This is a good question, and if you pay attention to what we’re up to, we’re getting closer. We have two technologies on the horizon: RTXDI (direct illumination) and RTXGI (global illumination). I spoke about RTXGI in the webinar and how it’s right around the corner for UE4 users.

RTXDI will be coming later on, but it seeks to achieve what you’re asking about. RTXDI has the capability to render millions of lights from emissive surfaces and emit accurate soft shadows from all of them. We’ve posted some early information about RTXDI and its development, there will be more on this coming soon.

Bottom line is, ray tracing is opening up new possibilities in rendering that even a few years ago were thought to be impossible.

Next steps

We invite you to learn more about ray tracing on our ray tracing resource page: we have plenty of videos, blogs, webinars, and more to help you get started. Also, GTC starts October 5, 2020. Register now to secure an early bird registration rate and come learn about the latest breakthroughs in graphics. 

And if you’re familiar with ray tracing, enter our Real-Time Ray Tracing with RTX On contest and share your work with the world. The selected winner will receive a high-end professional Quadro RTX graphics card and a complimentary pass to experience all the sessions related to our latest graphics news at NVIDIA GTC. The contest runs through September 27, 2020.

Discuss (0)