>>Sjoerd De Jong: Welcome Last talk of the day or at least in this room I am going to talk about ray tracing, which means a “Hands-on Look at Ray Tracing in Games – Extended Edition” I wanted “Extended Edition” in the title Unfortunately, that did not make it to the booklets or the TV screens outside, but it is very much an extended edition This is based on a talk I did at GDC at the learning theater two weeks ago or three weeks ago I cannot remember; time disappears But I went back from GDC, I had a couple more meetings with the ray tracing engineering team, and there was a lot of new information that came forth from that Here is a one hour version that goes a lot further in optimization and performance This is not necessarily about how to make pretty graphics with ray tracing, which is what most people focus on, what most people want to do, which is totally understandable But as a game developer, I wanted to know, how does this impact my workflow? How does this impact Asset creation? Where is ray tracing fundamentally different from rasterize and what we have been doing for the past few decades? What do we have to pay attention to? How do you optimize for that? That is really the angle I am going to start off with what I did at GDC, just explain to you how this works, how to set it up just to get ray tracing up and running But to be honest, there is not a huge amount to say there It is pretty straightforward You enable a few options; you are good to go But the real thing comes to, how do you really work with it? That is the focus of the talk My name is Sjoerd De Jong I am the Evangelist for the Unreal Engine in Europe and Middle East I lead the team and essentially we do the outreach and the growth of the Unreal Engine, any regards It is a mix between a lot of different departments and jobs But I have been using the Unreal Engine for 20 years, so I have a long technical background I have made my own games in my own studio, worked for AAA Studios I have done all kinds of different things Even so, my job now mostly consists of emailing, unfortunately I use these kinds of opportunities to go back and do something deep, technical, and really try to understand it, and then try to explain it in a way that makes sense I am not an engineer I am an artist, I am a designer or anything in that direction I want really basic language It is a ray, it starts here, it hits something, it goes there, and it is slow because of that reason Expect that. I want this to be understandable, because to be honest, I do not understand it myself if I do not do that Let us start What we are going to do is we are going to mix ray tracing with traditionally-rendered elements This is not going to be 100 percent ray traced, because that is not realistic for games What I want to have here is a case, this is how we would see ray tracing in the next half a year or year in games, which is not going to be 100 percent ray trace It is going to be a mix We are going to use soft shadows and reflections primarily I will have a brief word about translucency, but I will skip forward on that quite fast A brief word about ambient occlusion and global illumination as well, and then again, a lot on optimization and performance This is what we are going to build That is a demo that I put together We have a train driving though a subway station We will get back to that later on Let us intro some of this first Before we start in the Editor, what we have supported in 4.22 now is we have got soft shadowing for all types of lights We have got reflections that are very well implemented We have got ambient occlusion We have got a first pass global illumination, and that should be noted it is really a first pass and it does not do radiosity It is only the bouncing of light, and it is really, really, heavy Translucency, image based lighting in general, clear coat Materials are supported and we actually have geometry LODs If you have not watched my GDC talk, I pointed out that geometry LODs are not supported Meanwhile, or around the time of GDC, they are now supported We support Static and Skeletal Meshes and some basic BSP support and Niagara particles What we do not support is we do not support World Position Offset If you have foliage, grass, or something that is moving in the wind, that is a tricky one You can do that, but ray tracing – the reflections, for example, simply will not show that the grass is moving Landscapes are not yet supported That is coming in in 4.23 most likely Instance Meshes and foliage are not yet supported Again, you can use it, it just will not appear in any reflections or no shadows will be cast from it Cascade particles will never be supported because we are phasing out cascades Splines, not supported, and it is not multi-GPU We are working on that, but it is surprisingly difficult to get this to work, multi-GPU It is only a single GPU that can run ray tracing right now, but it is coming in the future I also want to point out, what you really, really want to do is you want to do full-on path tracing

You want to do that We are absolutely nowhere near that Level I can show you really quickly in the Editor here just for fun There is actually a path tracing option in here, and what it does is this It builds up the scene literally as you would expect from a full-on path tracer This is the real deal You can see, this does not particularly fast This is where you really want to go You want to get to a point where you no longer rasterize anything The entire thing is path traced All of the bounced lighting, everything is dynamic and path traced if I take a predication 5 years, 10 years from that point Meanwhile, we are doing hybrids Let us get going First of all, we need to enable ray tracing That means we need a DXR compatible 3D card We need Windows 1809 or new, which is the last major Windows 10 upgrade It does not work without that last major upgrade, and we need to run it with DirectX 12 It only runs in DirectX 12 In my shortcut here, and it is going to be very small for you to read probably, but it says -DX12 We are running the Editor in DirectX12 Having done that, in the Project Settings, I simply enable “ray tracing” and “compute skin cache,” and that is it If you look here for ray tracing, ray tracing enabled If you enable that, it also automatically asks you for compute skin cache I believe “support,” “compute skin cache” as a requirement for ray tracing, but that is it Right now, we have the Editor up and running in ray tracing You can see the performance here too It runs surprisingly well Obviously a decent computer, but it runs really surprisingly well That is going to be a thing, a team that is going to come back This is much more realistic to use in today’s hardware than you might imagine To set up some basic ray tracing here, we have got a point light, got a character, got a shadow This is not ray traced There is a setting in the properties of the light that says, “cast ray trace shadow.” It is that easy. You say, “yes.” You have ray trace shadow It is very straightforward In fact, it is enabled by default I had it disabled for the demo The softness of the shadow is controlled by the light source, source radius of the light It is 16 If I make it 0, it is very defined again, and the larger the number, the softer it gets It can control how large the light is It is very straightforward, easy to do Let me disable this for a moment Similarly so, you can do this with spotlights, for example, just take a different kind of light here for a moment Here is a spotlight You can see it casts these very harshly-defined shadows They are a little big Jaggy as well These are not ray trace shadows Again, same thing I enable it there, I get soft ray trace shadows That is it. There is nothing special to add there But that brings us to rectangular lights Rectangular lights we have added in, I don’t know, Version 4.18, I think I cannot remember entirely About a year ago when we did the first version of ray tracing What we showed at GDC a year ago at ray tracing, we completely rewrote that, by the way That is why it took a year for this to get released This is Version 2 Rectangular lights have been in the engine for a while, but they never fully worked Because in order to do rectangular lights well, you need ray tracing, because you cannot calculate the shadows of a rectangular light otherwise We have extended them a little bit for this first ray tracing release If I add in a rectangular light here, see what it does? I will set it to “movable.” You can see already it is a nice soft light we have got over there Essentially, the Source Width and Height controls obviously how large it is If it is very small, I get a very concentrated shadow again, and then it can define the light to be whatever size I want We also got these – little bit of an edge to it in 4.22 That is controlled by Barndoor Angle or Barndoor Length That is essentially helping you control how it falls off You can see instead of having a very strongly-defined line here where – put it back here like that – it is a very strongly-defined line where the rectangle light is present You can redefine it a little bit with Barndoor Angle and do something like that But that is it There is one other really cool property That is Source Texture That is actually nothing to do with ray tracing, so you can use this even without ray tracing You can use the rectangular lights without ray tracing, but if you use them with dynamic lighting, by the way, the shadows will be completely incorrect But for example here, on this tube light on the ceiling, you can see I have a rectangular light that matches the rough shape of the two tube lights Let me enable that It lights, obviously But it has a Source Texture which is mimicking those two tube lights By doing that, not only is the light actually cast from that texture so it is more accurate – it is actually two cylinders giving light or two lines giving light – but it also gets reflected in the reflection If you look in the wall, you can see right there we have got that That is the texture That is not this That is not the emitted Material you are looking at

That is the actual texture If I clear this out, it gets brighter because there are more white pixels without having a texture present It may be a little bit hard to see This is just a rectangle you see in the reflections It also improves your reflections It actually makes the light fixtures show up in reflections Again, that does not really have anything to do directly with ray tracing Now, we have seen point lights and spotlights What I have done in this environment is I have done a lot of mixing This is what I mean It is really hybrids The real environment – this is my test environment I will switch to the real Level in a few minutes But just if you look at the Level without lighting, this is the Level All of these lights floating around are really low-intensity ambient lights, for example They are all static I just baked the whole thing In fact, in the image that you saw, most of the lights have been baked except for a few hero lights, if you want to call it like that Those are ray traced That is how I am combining it Most of it is just traditionally lit, but a few lights, the really important ones are all ray traced Then the reflections are ray traced on top of it That is definitely the way forward for the time being, and that gives you really good performance as well obviously But you also have got skylights and directional lighting I have an indoor environment, so there is not a huge amount I can say about those here But I have a got a little bit of an outdoor area here with teapots Just to show you what would happen if I were to add them, here is a directional light It is immovable as well; it does not really matter But the same thing, it has a setting here, “Cast Raytrace Shadow” and it has a “Source Soft Angle.” That is basically it There is not too much to it Sorry, it is that one, rather, not this one It is the “Source Angle.” You can see now it softens out That is it That is the directional light Skylight, same thing There is really not too much about setting this up You can switch this on the fly as well, by the way You can easily build a game that supports ray tracing You just turn off the properties or some of the rendering features, and you have it scalable It can go from ray tracing to non-ray-tracing There is nothing too particular about it Skylights does not have “Cast Raytrace Shadow” enabled by default I can enable that But you can see this is considerably more noisy Some of this is definitely work in progress. This is Version 1 We probably need at least 2, 3, 4 Unreal Engine releases to really get to a proper state Could you ship a game right now using the current implementation? Probably not entirely recommended, I would say But what you can do – this is the most important part – is you can see how it would work and you can look at what the impact would be on your content and then base your decisions on that and roll along with it over the next year or so There is also a setting here, if the auto-save is on It says “Samples for Pixels” for “Ray Tracing.” If I increase that, well, that is how many pixels we cast Obviously, we get rid of the noise because it gets much finer It does impact performance, not in this simple test scene, but that would have had a considerable impact on performance, of course It depends a little bit on what you are looking for, how much performance you are willing to give But by default, this one is currently a bit noisy and will probably work out in a later version Good I have one really interesting picture here This is that same outer environment with lots of teapots The top one is cascaded shadow maps This has completely nothing to do with ray tracing The bottom one is ray traced shadows Directional light, a bunch of teapots, nothing else there This runs at 52 FPS for cascaded shadow maps The ray traced one runs at 73 FPS There is a really important message there It is that ray tracing is not necessarily slower It could in fact be faster than what we have been doing before It really depends on what you are building and how you are building it That is a really important thing to take away What we think might happen is that we are probably going to see ray traced shadows, perhaps some directional lights first, because there is only one directional light, so that is ray traced But all the other lights might continue to be just regular dynamic shadows, something like that The reason why this is faster in this particular case, by the way, is because these teapots are high poly They are about 100,000 polygons or so for each teapot Cascaded shadow maps does not like that It is sensitive with polygon count Ray tracing does not care about the polygon count for this particular example There is a point at which ray tracing starts to catch up because it gets exponentially worse kind of with the cascaded shadow maps where ray tracing just does not care about the polygon count That is what happens Also, one really nice thing with ray trace directional light – you can see if I do this, normally, if you would not use ray tracing, what would happen is that the shadows would fade out You have got this common problem as you have it in games At some point, if you are far enough away, you just lost your shadows Ray tracing does not have a range You will never have a minimum range For example, if I go back here and I say, “Ray Tracing Enabled,” I can go as far away as I want It has no range That is a major benefit You will never that really rather annoying fading of shadows anymore on outer environments

Let us move onto the reflections I am going to switch Level to the real Level Here is the actual Level Most of this is baked What is not baked are the three red lights There is a red light there, there, and there There is a train going to come passing through the tunnel that is ray traced Everything else is baked But all the reflections are ray traced You can see just how good the reflections are Once you see this stuff, I cannot unsee it I cannot go back to non-ray-traced reflections right now This is the ray traced reflection That is absolutely air sharp That is the reflection If you move, you get a little bit of jaggedness and noise You can see there is a bit of artifact It is not entirely smooth But if you compare the two, you cannot see the difference It is really cool. There are a couple of problems here You can see there are a lot of black pixels The reason why there are a lot of black pixels right now is because by default – this is a good thing to do of a performance perspective – the number of bounces is set to 1, so there is only a single reflection bounce, which for games, please do that Please do not do what I am going to do now, because you will kill your performance In the Post Process Volume, we have added a number of the ray tracing options Not all of them, but a couple of common ones The “Ray Tracing Reflections,” “Maximum Bounces,” that is set to 1 Obviously, I am going to set it to 2, I get this You can compare this over here 1, 2, and you can keep on going, 3 But obviously, framerate is currently 28 At 1, I was at 120. It takes a little bit of performance What we are going to do in the future, by the way, is because this is heavy and this is also a problem We are thinking of doing a fallback where the second reflection is going to use screen space reflections or the reflection captures That is going to be the fallback That cost pretty much no performance, but we also avoiding having pitch-black shadows, pixels in there That is probably going to come in in 4.23 to make this a bit better There is one other thing that you want to highlight with reflections I have got a mirror over here Let me move the mirror up If you look at the shadows, you can see that is not the same, right? The shadows in the reflection are a bit problematic to do There is a setting that controls the shadows in reflections In fact, it says here, “Ray Tracing Reflections,” “Shadows” is set to harsh shadows I can obviously disable the shadows That would be good for performance You might want to do that in a game in early adaptions It does not look very good if you do that It can set it to soft shadows, “Area Shadows,” which would be the preferred option But it is rather noisy As technical reasons as well with the denoiser and what we can do in reflections and so on Again, it is a work in progress, and some of this needs further research and development “Harsh Shadows” is the default We looked at soft shadows and max bounces, but reflections, as you have already kind of felt, it has a really big impact on performance The soft shadows are surprisingly good You have seen that with the directional light Basically, I could have replaced all of the lights in my train station, my subway station with ray traced, soft shadowed lights, and performance would have probably been okay That is fine But the reflections, that is immediately, bam, you lose 90 percent of your performance We are going to get back to the reflections soon because there is a lot to say about optimization and why it takes performance Skip that for now Let us cover a couple of the other intro things Translucency Let us bring in a train Got a train sequence here I just remembered, I forgot to show you one really cool thing with the soft shadowing I am going to open up the other Level in a second just to show you that We have got a train here It has glass windows You can see the windows, they do not show any reflections In fact, if I look away, I do get reflections, but those are your screen space reflections that face in By default, you can turn on or turn off the reflections In fact, in the Post Process Volume, it says here, “Translucency,” and it says “Type,” “Roster.” If I set that to “Ray Tracing,” you can actually ray trace reflection on the glass You have got to enable that manually. It is a special case Translucency is difficult It is not entirely done, either As you can see again, there are black pixels here But even if I would have set the “Max Bounce” to 2, it does not actually affect this We cannot get rid of the black pixels in ray traced translucency right now Again, work in progress Feel free to experiment with ray traced translucency, if it works better or not There is one setting here somewhere for “Refraction.”

I would enable that, disable it In my scenario, if I enable it, it looks kind of weird It does not really quite work It looks a bit strange Feel free to experiment with that and see if it is better or worse with it enabled or disabled I will have it off also for the sake of performance I will sacrifice the glass in order to gain some extra performance Before I continue and go to ambient occlusion and GI, I would really like to show you the one thing that I just forgot to show I am going to switch back to the other Level, because this really shows you how cool ray tracing is If I go back here, if I disable that light or kill it, it is almost entirely dark I switch this to detail lighting Let me go full screen Actually, quickly get the train in first Full screen, and here is a train This is just awesome to see Just a soft shadowing as the train drives by to the platform and you get this For comparison, I can disable the ray tracing soft shadows somewhere in here You have a lot of R commands You are going to see this come back in a second as well as I start doing more in the optimizations But I can take the shadows, and say the shadows are 0 This is non ray traced This is what we are used to If you just see this again, it is just so incredibly unrealistic It is so nice to see this switch around to this, the nice soft shadows you have got In fact, you can go even further and do following I can say that this very large light panel here, which is a big rectangular light, I am going to enable that with ray tracing, and I am going to see what happens It is currently set to affect where it falls Now we have enabled it Obviously this casts shadow You can see here also, there is no global illumination enabled right now I have this disabled, so this is all pitch black There are a couple things to be aware of there Just take a look at what happens as a train occludes the light Just going to position my camera here, do it like this Train is coming in Let us let it drive through As it passes away, it really gradually smooths in the light on the surface again It is pretty much dark now, and as it passes by, you get this really subtle, soft, bright thing That is just cool to see this kind of stuff You would have never been able to do it in any other way but ray tracing Anyway, I just wanted to go back to show you that My colleagues are complaining that ever since I started with ray tracing, I have to keep telling them every day just how cool some of this stuff is I think they are getting annoyed There is ambient occlusion as well I am not really using that I disabled it here, in fact But again, feel free to experiment with it A lot of it is controlled again, over here as a CVar There are some here, “r.RayTracing.AmbientOcclusion.” I can just for fun – I can do this I do not see a difference, right? It depends on the quantity you have got I have got a rather dark interior subway station thing If you have got an outer environment, there is a lot of bright snow or something, it might do better But in my case, I disabled it to gain a little bit of extra performance It is not expensive, just gain a little bit of extra performance Another thing you can do is then the global illumination There is “r RayTracing.GlobalIllumination.” Experiment with it, but again, it is really heavy It is noisy It is a work in progress, but you can kind of see what might be possible in a couple of months or in a year or so from now We are going to start getting more and more in optimization Let me just take a step back and talk a little bit about the big picture In a big picture, in order of performance relative to how much payback you are getting for an expense that you are making, shadows are by far the best thing to do They are relatively cheap and they are very visible Shadows are really the first thing to look into Reflections are really expensive, but they are also really visible Probably in my opinion, they are the second thing to start moving into Translucency I am personally not using at all at the moment I think it might be very visible, but it is also kind of specific I think you can kind of work around it often It is a case by case basis Ambient occlusion, again, case by case basis It is pretty cheap But personally, in this environment, I am not noticing it in much benefit, so case by case basis Global illumination, super cool, super expensive Basically, you cannot use this right now In practice, you cannot That needs more time That gives you a little bit of an idea there You use the Post Process Volume and a lot of the CVars that you type at the bottom to control this You can use Stat GPU and the GPU profiler to look into it At the end of this presentation, I am going to show you what we are doing for 4.23, which is more than this You can see right now in stat GPU You get some basic stuff like ray tracing reflections and something else here, some ray tracing top Level acceleration structure, ambient occlusion You can see a little bit of it, but it is very simple You can also see ray tracing reflections

takes 24 milliseconds out of 35 Just a little bit expensive There are going to be more stats coming in 4.23 to help you get an idea and profile this You can Nsight for NVIDIA, for example It completely supports ray tracing If you are more technically inclined, you can analyze quite a bit of it Likewise, NVIDIA has a lot of tools that they released They are all ray tracing ready, so you can use all of those tools to really understand what are the rays hitting; where is the cost going? But they are not the most straightforward to use if you are not on the engineering Level I would personally go rather in this direction That is what I am going to do As an artist or a developer or designer, someone who is not an engineer, how do you actually use this stuff besides checking tick boxes? Let us start simple I have got a couple of basic options here I have got Screen Percentage, Max Ray Distance and Max Roughness I have set these somewhat hacky, but it is for the sake of the demo In “Level Blueprint,” I specified some of these Now we are waiting for the Blueprint to open It is found that ray tracing goes this fast, but opening Blueprint seems particularly complicated It might be that it is on a different monitor I do not think it is No, it is not Here is what I have in here I have turned off the “Dynamic Mesh Instancing” that we added in 4.22 just for the sake of displaying a particular feature later on, so ignore that Turn off “Ray Tracing Ambient Occlusion” there, 0 I set “r.RayTracing Reflections.MaxRayDistance,” and that is a good one It gets you a very small performance boost, but it is not going to do much, but it does not hurt adding it What you are doing there is you are limiting the rays from reflection to a maximum length If, for example, you have a long train tunnel, you are making sure that some of the rays cannot ever just keep on going until basically at the end of the tunnel where you would not be able to see them anyhow anymore You can limit You can call the distance It gives you slight performance boost It is not going to be much, but it is one thing you can do You can use “r.Reflections ScreenPercentage 50.” Essentially, obviously, you reduce the reflection quality to 50 percent That is a lot of performance, as you might imagine It also does not look very good Again, pros and cons You have got to see it case by case how it goes Right now, you get a little bit of a rendering artifact when you use it as well, which kind of adds up to the – well, it is not super useful right now But as we are solving this and improving it, that is probably going to be a good one to use You can have ray trace reflections, just not at 100 percent quality for performance We have got “SortMaterials,” and I am going to get back to that in a second in one of the next slides, because that could be a really important one, and that is part of a really fundamental understanding of how ray tracing works Then you can do a lot of things For example, you can disable the HeightFog in the reflections Gives a slight improvement You can do it for translucency as well, so you have a lot of those kinds of settings that you set Again, MaxRayDistance for translucency That is where I would start Set a couple of those settings But that only goes that far Where you are really going to start getting major improvements in performance is when you start looking at the Materials The Materials in combination with reflections, that takes everything The Roughness, for example What I did here is I built this improvised debug view mode We are probably going to look into perhaps adding this to the engine somehow as a standard feature What I did again is very much so improvised, so it is not entirely accurate, but it is going to illustrate what happens This is in my debug view mode It is just a blendable I made In fact, since we have the time, let me just open this up, give you an idea That is what I hacked together It is again, really, definitely improvised I take the Roughness, and based on Roughness value, I assign three different colors to it Then I try to do the same with Normal, but it did not work very well It was hard to do But what happens here? The different colors, green is obviously the fastest render The green pixels are the best, as it implies The yellow pixels are medium, and red is slow But why are those three different colors there? Because of their Normal values and their Roughness values It affects ray coherency The way ray coherency is affected in turn has a huge impact on the way the hardware has to render the race and calculate the race If a surface is 100 percent rough – the ceiling, for example, is very rough – if a ray hits that, we just kill it Because you are going to argue, you would not be able to see a reflection on that It is not very reflective Instead of rendering, calculating the ray tracing for those pixels, we are going to have those pixels fall back on regular reflection captures Everything that is green is not actually using ray tracing, which is obviously fast 100 percent Roughness, very fast Everything that is yellow is using ray tracing, but it has a very simple calculation to do that The ray coherency is very high If you have a surface that is 100 percent reflective, which the puddle of water is, then as the ray hits it, it just hits it and it bounces and that is it. Easy, right?

If the next ray comes in as well, it hits it, it bounces, it goes away. It is easy All of the rays are kind of doing the same thing so we can batch that I am going to get back to that in the next slide This is what I did not say at GDC I had a simple explanation there This is the complicated one As it hits it, it all goes in the same direction, and that impacts what it hits in the distance That is the next slide But that is a large ray coherency Direct pixels, though, are Roughness values between 0 and wherever your threshold point is Threshold point is the point at where it starts going green If you have a Roughness of 0.4 say, those pixels will render a lot slower than Roughness 0 That is what I am trying to visualize there I went through my environment and had to analyze the Materials and I started changing some of the Materials For example, the pipes I did not change But to be good and correct, I kind of have to go back and change the Roughness values of the pipes I am able to actually gain performance What you are going to get in games in the next year or so, you are going to get very shiny, reflective games, not only because the artists really want to show off what ray tracing does, but also because it literally runs faster That is not the full story Let me turn this off The full story goes like this It is about ray coherency, right? If it hits the rough surface – and this also goes for Normals If you have strong Normals, the same thing would happen When it hits a rough surface, the ray is going to be bounced away in a different direction It is going to change course That is the problem That means that all the rays that hit, they start going in different directions Your rays start to scatter in all kinds of different directions Therefore, since they are not all in different places, if the ray hits the table, it is going to probably go to the ceiling or somewhere there It is going to hit a lot of different parts of the ceiling That is slow; we cannot batch stuff together anymore The hardware is batching that in groups of a few dozen rays at the same time It is kind of like render states If you are changing the Material, the hardware has to change render states There is a cost associated with that That is where this comes from That means that the Mesh Fragmentation is the real cost for this issue Because as these rays that have hit the table go back up and they hit the ceiling, if the ceiling consists of a lot of different Meshes with a lot of different Materials, every ray is going to hit a different Material on the ceiling This ray is now unique from the ray that is right next to hit They hit different Materials, so they have to change states in between them If the Material is very reflective, all the rays go in the same direction, so they are much more likely to hit the same Mesh in the distance, which speeds up That is where this really comes from The more shaders you hit, the slower it is That has a lot of content implications It is not about draw calls It is about a number of shaders in the environment and where your rays are going I built a small test case that tries to visualize this It has been a week since I tried this, so I hope that my test survives I am going to have the courage to do this live and show you exactly what I mean, so I hope it survives Bear with me I have a Light in this Cube that I made This Cube is a little bit of a – there is this teapot in the middle – it is a lot of different Meshes with a lot of different Materials That is what it is Every color There are eight or nine different Materials here It is basically lots of cubes placed through a Blueprint next to each other Also, the problem is this computer is so powerful, it does not really help showing performance I am going to try to see what I can bump up The Post Process, the two reflection bounces or something probably does it Let us try to do that I actually want less performance. Maybe It is going to be hard to read for you This is 49 FPS I can probably go full screen Now that is now 21 FPS, right? This is kind of a bad scenario for ray tracing, because we have a rough surface You can see there is a normal map there, so the rays are going to get scattered Every time as a ray gets scattered, they are all going to hit lots of different Materials, because the whole thing is built up of different Materials It is kind of a terrible scenario You can see the performance is 21 But if I take this Cube – and I have an option here that says, “Use Instancing.” It does the same thing The geometry is exactly the same, the number of draw calls is the same, but it runs at 45 FPS We have doubled the frame rate just because of that Because all of these instances come from the same shader underneath the surface All of the rays are hitting the same shader It is significantly faster This is only using a single Material, and that also runs 45 FPS It is the same geometry again, it just assigned the same red Material to everything That has the same impact as only using instances What you ought to do – and I did not do this in my demo, because I realized this after I built it, so it was a good test case for me as well

In my demo, I took in content that we had laying around from previous examples None of this was set up correctly, so what I have now is actually I can get more performance out of it I have a lot of unique Materials My pillars is an actual Material My ceiling is a different Material My floor is a different Material Everything is a Material, not a Material Instance That does not help If I would have redone all of the content from scratch and I would have done the whole thing with one master Material, or two or three, a limited number of master Materials, and then everything is a Material Instance with as few Material Instance permutations as possible, that would have been significantly faster This just doubled the frame rate in my example That is what you have got to do You have got to limit the number of unique Materials If you do that, in the extreme case, it is the Roughness – the Normal and Roughness impacts of the Materials actually have almost no impact anymore on performance But in a very fragmented scene, the Normal and Roughness values of the Materials have a significant impact on performance We try to fix that automatically, but it is not easy to do We have a command here called r.RayTracing Reflections.SortMaterials That is designed to minimize the shader impact, so let us go back here Let us turn this back off Here is worst-case scenario running at 22 FPS Let us try to do this SortMaterials It disabled my default If I enabled it, it takes a bit of time to refresh the whole thing It is coming in. It is still 25 FPS Sorry, my bad I have pressed something, and I have pressed undo, which is really dangerous Probably do not do that Let me try this again just to compare. SortMaterials That is 0, 22 You can experiment with that a little bit and see what kind of impact it makes 25 It goes from 22 to 25 The thing is that it is really case dependent, case by case dependent What it tries to do is that as it casts the rays, it tries to find the rays that are going to hit the same shader and then group them together in one batch It tries to sort the rays as they are being cast It does not always work, so it is a setting to experiment with In general, the whole Material complexity has a big impact on ray tracing You can test with EnableMaterials 0 If you were to do that in the environment – let us go back to the actual Level I type “EnableMaterials” I was 30 FPS I am now 120 locked, so I probably have way more This shows you the impact You can use this as a test You can see just how much performance is actually lost in Material-related ray tracing work If you look in a mirror, for example, everything looks black But the geometry is still there You can kind of see there the geometry is there It is just all the Materials are gone The reflections are ray traced, but just not with Materials That has a huge impact on performance too In fact, because it has such a big impact on performance, there is another feature that we have added that can help you as an artist and a content developer You can kind of use this to improve things a little bit The performance is just quite bad here, so I am going to take away my three bounces and do one bounce We have a Material version of this I am going to change the Material that is on the bench There is “Instance” here, add the Instance It is going to compile the shader for a second If I now look in the mirror, I have a red bench It is not red over there, though What you can do is you can make the reflection different from the actual real world That has performance optimization implications Here is the Material Sorry, that is the Instance What I did here is there is an option called “RayTracingQualitySwitchReplace” where you can say, if it is normal, do that; but if it is ray traced, use this It only shows up in reflections or in the ray traced calculations But again, it really helps with performance For example, over here we have got this whole arm doing stuff Let us say that you would never see that For example, let us say you have detailed normal mapping You do not want to get to detailed normal mapping to show up in reflections Save a bit of performance there Have a branch there that essentially strips out if it is ray traced , just use 0.5 If you do this well across all of your Materials, that has a significant impact again on performance I have done this here and there as again, but the content was not – I did not build this content from the ground up, so to try to start modifying everything at a later stage was rather annoying Think of this early on Masked Materials are an issue in ray tracing, because when we have masked Materials, we have got to check the Material as the ray passes through As the ray travels through the world,

it has to start evaluating the Material and the textures in order to figure out where it can pass through That is a lot slower Masked Materials are slow Try to avoid them where possible In 4.23, we are going to do some optimizations It is going to improve, but it will remain more expensive to non-masked surfaces That is not including regular overdraw and those kinds of issues you would regularly have with masked Materials Geometry-wise in general, kind of the same thing is true If you have geometry with a lot of small holes and spaces – let us say vegetation, fences, anything like that – the ray tracing is slow Because as the ray travels through the world, it goes through a narrow space As it goes through, it needs to check the nearby geometry You have got a lot of narrow holes It needs to do a lot of checking on geometry as it travels through the world That is slower In general, fixed, solid shapes are the fastest Architecture is very well-suited for ray tracing, for that matter Forest, nature, is definitely not The reason is masked Materials and a lot of small holes Then there is polycount in ray tracing With static scenes, ray tracing actually handles high polygon counts better than a rasterizer That is the first interesting one It is actually very good for polycounts in general What it does in ray tracing is we use an acceleration structure We essentially use the bounding box of the Mesh and we start creating some kind of bounding box hierarchy of the object We do this to avoid having to intersect rays against all the triangles You do not want to check all the actual geometry We are actually checking some kind of simplified acceleration structure from that That process is basically cached If you use a rasterizer, it has to convert this continuously The 3D model has to rasterize that result continuously frame by frame But in ray tracing, we only have to do this acceleration structure once High poly content is actually potentially slightly faster, and you can test it You can run some tests, check that out But it is potentially faster than ray tracing, but the problem is, skin dynamic Meshes, so Characters or such, they do have to be continuously recalculated, so we have to create that acceleration structure continuously for every frame because those Meshes are changing That is considerably slower, in fact Characters are slower to render, especially the higher poly they get in ray tracing But static geometry tends to be much more neutral in terms of polygon count The impact there is that it also takes a lot of memory Although memory crashes are quite common in ray tracing, it is memory-intensive The acceleration structure takes about 84 bytes per triangle in some of our test cases That is what you are looking at That adds up Skinned Meshes, so Characters and similar Skeletal Meshes, they have the biggest impact But in general, anything – the more high poly, the more this starts adding up But definitely Characters have a huge impact If you have a lot of Characters and you enable ray tracing, it is likely this might crash without memory, and then that would be the reason We do support memory Mesh Instance, by the way, just to point that out If you have got a high poly statue and you copy that statue four times in a Level, it is only converted in this acceleration structure once and stored in memory once It is not per Instance in the Level In 4.23, we are also adding more performance stats Just to bounce back to the earlier slide there This is work in progress what we had I think on Monday It comes in very hot It is probably going to change by the time we release 4.23, but we added ray tracing stats that shows you a little bit about where the memory is going, because right now it is pretty much impossible to see how much you are spending on ray trace memory You can see for some of the number of triangles in all the acceleration structures, and you can kind of use that to start going through some of that To wrap up, indoor is slower as well than outdoors Because if you have an indoor environment, the rays are always going to hit something We can never stop – we can never cull some of the rays If you have got an outer environment – let us say it is just a flat space with a horizon in the middle About 50 percent or so of the rays will disappear into the sky Those will carry almost no cost We simply stop the rays They are very cheap The rays that hit something, that is where the expense goes Outer environments you saw, therefore, you can just remove some of the rays Indoor environments, you always hit something The most ray-trace-friendly environment would be an outdoor city architecture and it is outdoors The worst would be indoor, a greenhouse Translucency, it is indoors, and it is vegetation with a lot of holes That is the takeaway you can take home Do not build greenhouses in ray tracing. Just do not Do not build jungles either, please. Do not build jungles

Just build cities and deserts It will be fine But you can try this in Unreal Engine 4.22 It is really, really fun to play with and experiment with, I think I had a great time building this. Enjoy, thank you [Applause] ♫ Unreal logo music ♫

You Want To Have Your Favorite Car?

We have a big list of modern & classic cars in both used and new categories.