>>Mattias: Good morning.Thank you so much for coming. This is our seriesof tech talks for today. This is the first one.It is called, Causing Chaos: The Future of Physics andDestruction in Unreal Engine 4. I am Matthias Worch,I am the Design Lead at Epic GamesSpecial Projects, and I am oneof four speakers today. I am going to tell youa little bit about how to build interactiveexperiences using Chaos. Joined by two coworkers today. First we have Jim VanAllen,Senior Technical Artist. He’s going to talkabout the art of destruction. Mike Lentine, the leadphysics programmer on Chaos, will illuminatethe tech behind Chaos. We are also joinedby Jeff Rous from Intel, and he’s going to talka little bit about how we made Chaos fast. Chaos is our upcomingphysics system, which is going to be the mainphysics system in Unreal Engine. It is stillin active development, so we are workingon it right now, but there is going to bean early access version of it in 4.23,which is coming out very soon. It is going to haveall of the code as well as some content examples that we used to make the demothat we are showing. Now, Chaos is a completephysics system. It is going to do everythingthat you expect a physics system to do in Unreal Engine. It also happens to bereally good at destruction, so when we wanted to reveal itto the world at GDC, that’s what we created. We createdthis destruction demo. I hope you have seen itat this point. We showed it at RTLas well yesterday, but I do have a short clip here.I cannot get enough of it, so even if you have seen it,I hope you like this. >> Breaking news:Robo resistance leader K-OS has broken into a RoboReady Research lab and stolen topsecret military hardware. A recall agenthas been dispatched. Okay, Agent 38,it is renegade recall time. [LASER BLASTS] >> Good thing it isa bank holiday. She is getting away! Activate rocket boostand get after her. I am compensatingfor your lack of skill with higher caliber weaponry.She is on the move again! Let us see her teleportout of that one. Now would be a good time to figure outwhat that thing actually does. [OMINOUS MUSIC],[BUILDING CRUMBLING] >> Oh, that is not good.On the bright side, you have been approvedfor mandatory overtime. [MUSIC] >> Mattias:: Allright, so let us start by talking aboutdesigning with Chaos and how you create interactiveexperiences around this. The creative behind this demoitself which you can play, is rather easily explained.
is rather easily explained. We wanted to create an homageto old light gun games. When you are playing this, you actually havetwo Vive controllers and you get to shoot at it,and it makes it a lot of fun. You get to smash upan entire city. We wanted to make sure that youactually had a goal during that, so you are going afterthis little robot called K-OS, or K-O-S. You get to use destructionas a tool. If you want to authorsomething like this, I want to give youa little bit of an idea of what you have to play with. Everything that you have seen,everything that is in this demo was completely createdin Unreal Engine. We did not use any outside toolsother than obviously you go into Photoshopto create Textures, et cetera. But all the destruction toolsare actually in Unreal Engine. The reason I like pointing thisout is because it shows you how tightly integrated Chaosis with Unreal Engine 4, right? It is actually partof the Engine. We will come back to thatagain and again. Everything you see in this demo and that you can play isrendered in real-time as well, and we are using a regularhigh-end gaming PC that you could buyin stores right now. There is a difference betweenrendering something in real-time and actually simulatingsomething in real-time, and obviously everything hereis super heavy on simulation. Let us unpack thatstatement a little bit. Everything that we show you issimulated in real-time as well, with one caveat.We only do it when needed. We are going to go into thata little bit deeper. It gives you a really good idea of how Chaos worksunder the hood. As I go through the demothat we created, there are threedistinct sequences. There is the first onewhere we are hunting K-OS through the streets and she is trying to hidebehind various pillars and we keep flushing her out. Everything hereis 100 percent real-time. We have the entire first sectionstreamed in as well. We are not beingreally creative about it. We do not know whereyou are going to shoot, so as we are going past this, all of this is happening100 percent at one time. Then we go over some buildings.We stream out the first section. This stream this one in,and this is where K-OS starts hiding inside buildings,so we upgrade our arsenal and we just start smashing upthe entire buildings. Once again,both of these buildings, including RoboReady Headquarters, 100 percent just runtimein real-time. We do not doanything special here, and everything hereis simulating at runtime. Then we get tothe third sequence, which is a little bit different. This is a cut sceneat the very end
This is a cut sceneat the very end where we are crumbling an entirecity block as this huge robot– Somebody told meshe is called Mildred. I did not know that. It is rising and crumblingthe entire city block. This one was actuallypre-simulated. We did this in Chaos, but thenwe baked this out as a cache which we are playing backat runtime. Now, even though we areplaying back a cache, it does not mean that this isnot still a dynamic system. If you understandthat a little bit better, I think you havea really good idea of what Chaos is actually doing underthe scene, behind the scenes. We can, if we want to,actually pre-cache simulation and we can bake them out. That is actuallyreally useful to us and to youbecause it allows us to [inaudible]something, right? If we have a reallygood destruction that we do notwant to be dynamic, that we wantto make sure happens exactly at the same timeevery single time, we can actually do thatand we can pick the perfect one. It also allows us to domass destruction at performance, because something likethat third sequence where we are crumblingan entire city block – you could not dothat at current hardware. Even though we arecaching this out, everything that we are doingin a pre-cache simulation is still createdusing exactly the same tools, it is using the same datatype behind the scenes. It is calleda GeometryCollection, which has all ofthis destruction in it. What is really cool about Chaos is that even thoughsomething is pre-cache, any partof the pre-bake simulation can still become activeat any time. As we are replayingthese giant caches, if you now want to make itan interactive experience, for example,by giving a player or any other interactora weapon, the parts that youstart interacting with can become active. You might have10,000 rigid bodies – I am kind of making upa number – falling down,and that is pre-cached and it is playing backperfectly at performance. But then you shootat a small portion of it, and 400 of thoseactually become active. They start interacting,and they do exactly – they react to every outsidestimulus that you would expect. In Chaos, destructionis never static. This is never a staticcache that just plays back exactly the same thingthe same way. It can actually react toanything that you throw at it. Chaos can react tothe dynamic World State, and by doing it, you createsomething that looks amazing, is incredibly performant,but still can react to everythingthat you need to at runtime.
epic games download to everythingthat you need to at runtime.
to everythingthat you need to at runtime. If you wanted to create a scenewhere you put a player at the bottom of this building,for example, but you do not knowwhere the player is actually going to standand you want the player to react because there are giant chunksof debris falling down on herand you give her a weapon and then you wanted to actuallybe able to shoot that up, you can do that with Chaos. If this was a completely staticpre-baked simulation which came outof an outside package and you just played that backas an alembic or something,you could not do that. But here, the player can shoot at the specific partsof the simulation which she wantsto interact with, and she can crumble thatand survive that situation. That is actually a game changer, because I have beenmaking games for 20 years, and a lot of timesin these kinds of situations, you have to put the playerin a bubble. Because you need to know exactly where the playeris going to stand because everythingthat is raining down will not be able to interactwith it in any shape or form. That is the big difference here. Chaos can do all of thisbecause it is a system. It is a first-class citizenin Unreal Engine, and it lives alongsideall of the other systems that simulate your runtime worldin the first place. Chaos can be triggered,it can be queried, and it can actually send eventsto the other systems as well and can interact with that. That creates some incrediblytight integration between all of the systems. You know all of the thingswhich are going on in Unreal because all ofthe gameplay systems can really tightly integrate. This was important to usbecause Chaos is so cool because it is a messy system. You never quite knowhow the next destruction is going to happen.That is cool. That is part ofthe satisfying experience. But it does make itunpredictable, and because nothingever plays out the same, especially if the playeradds some uncertainty into it, you need to make sureas a designer if you are creating thisas an interactive experience that you have toolsto actually deal with that. Chaos lets you createruntime system like AI, et cetera, that can accountfor all of that chaos because they can interact withthe destruction after the fact. I am going to give yousome examples of how that actually can happen.When we are really talking about creating completelyinteractive experiences, maybe you can hook upafterwards. This is a topicwe could talk about for a while. But some simple examplesof what we did in the demo to kind of demonstrate howyou can interact with Chaos –
to kind of demonstrate howyou can interact with Chaos – the super simple oneis actually a kill Field. One of the issuesyou might again have with a completely pre-bakedstatic vertex cache is that once you are bring that downon part of the playing Field, that part is off limits becauseyou have just blocked it off and you cannot do anythingabout it anymore. AI couldn’t navigatethrough it anymore. If you accidentallyblock an exit, the player will notbe able to exit anymore. It is very feasible to justcreate a simple kill Field, rain down destruction onthat entire street right there, but then create kill Fields that only crumblethe specific parts of that area that you need to crumble. You can also create AIthat actually shoots that up. You can pretty much sanitizethe part of the playing Field that you are interested inand make sure that the action can continuein a runtime environment. Now we come back to Chaosnever being static. The destruction is not static, so it is never this allor nothing proposition. You either completely clutterit up and then it is offlimits or not. Now of course,as we are talking about systems, AI is one of the big onesthat we immediately think about because when we are creatingan interactive experience, we have autonomousagents, right? We have AI like enemies thatactually want to interact with, that we want to interact withand shoot at, and they need to be ableto navigate all of that. We have done a lot of heavyplumbing already and made sure there is support for Chaoswhen it comes to AI systems. NavMesh is fully supportedon GeometryCollections, so in this example,it is actually a Static Mesh in here at the bottom,and that has NavMesh, and then we haveGeometry Collections on the top and AIcan navigate on that and they can do everythingthat you expect an AI to do. You could actuallycreate dynamic NavMesh, which could bemodified by debris. You are going to have someperformance implications there, but if you wanted to havethat bridge destroyed and have piles ofdebris invalidate NavMesh down at the bottom and then AI can navigate aroundit, that is totally possible. We did not actuallydo this for our demo because we did not need it. We created something likea Snow Plow or a Cow Catcher, I think is what Jeff,our lead engineer, called it, where AI could walkand kick away some of the debris to make sure that they donot collide with it correctly. But you can dream bigif you really want to think about using this in the game or somethingthat is truly interactive, because the AI can queryall of this destruction, so they might be able to usea large chunk of debris as dynamic cover,for example, and you can createa really cool cover shoot out of it,something along those lines. An AI of course needs to reactto the destruction as well. This is really where these kindsof systems come alive when you have a robotstanding in the scene and they are reactingto all the destruction that is happening around them.Again, we put in this demo to make sure that some ofthis support is already there. The first thing you are going tothink about of course is that you want to use destructionas a tool to kill people. These are some early examples of when we actually broughtthis online. Every Chaos destruction eventis going to give you information about what the debrisactually is and how much mass it has. Then you can triggerappropriate effects. If it is big enough, you are going to trigger deathright here. If it is small enough, you mightjust play a flinch or hit react where the AI reacts to stuffhitting it but does not die. You can of course take thisa little bit further because you alsoget a location where these hit eventsactually happen. You are going to heara little bit later of how you can actually filter and make sure you are notgetting information overload from all the destructionhappening around you. In this case,we can play a flinch event and jump to the side because of where the destructionactually happens. Of course,if something happens above, we can play the appropriatereaction as well. If you are thinkingabout using this in an interactive experience or even makinga game around this, this is how AI can startreally integrating with Chaos in the first place.These are autonomous AI agents. As a designer, I want to be ableto work with Chaos as well and have some tools so I can actually get eventsand act on those as well. I want to give yousome examples here. One of them is just,how do I detect damage and how do I react to a pillar,for example, getting shot up? Which is what happens a lotin these kinds of demos, in this demo specifically.We created a little Blueprint which we callthe Destruction Detector, and it was listening tohow much damage has been dealt to a specificGeometryCollection that we put inside that volume. We could have listenedto everything everywhere, but I am veryspecifically interested in what is happeningto this pillar. Then I can subscribe to thatand I can create an event and I can say for example, if this specific pillaris getting destroyed, trigger an event and move on. All of the demo progression thatyou see in our playable demo is gated that way.You actually see that happening. I am shooting a specific pillarand enough damage has been dealt and then we are moving on. Instead of just listeningto damage dealt to a Geometry Collection,I could also look at the mass and I could detecthow much debris has fallen and how much a pillar has beendestroyed along those lines. This is the Blueprintthat we are actually using here. You can see we are gettinga ChaosBreakEvent and I can act on that. I get informationlike the location, but I can also get mass. If I wanted to createsomething like, fill a container with enough debris and there isa scale or something like that, and then I want to actwhen that entire container has been filled,this is how I could do it. I can also integrate that backwith what the AI is doing. What I want to doin these kinds of games or interactive experiencesin the first place is have AI react to it. If I want to invalidate cover,I can tie those together and say, you know what,this is valid cover until it has been destroyedto a certain degree, and after that, move on. You actually see K-OSdo that a lot. Whenever she is zooming aroundin the first section, it usually happens because Ismashed up one of those pillars and I invalidate cover that way.This hopefully, especially if you are a gameplayprogrammer, you have done this. It gives you a good idea of theheavy plumbing is there. Chaos as a systemcan fully communicate with the gameplay systemsand it can go both ways and you can startbuilding things around that. One final piece of informationbefore I hand it off, because this is a questionthat everybody is going to have and we probably get asked,and that is networking. This is a big topic and there are more qualifiedpeople to talk about it. What I will tell youas a designer looking forward is that Chaos is builtwith networking in mind because it is going to be our primary physicssystem of the future. What I like about Epic is thatwe are a production company. We make these toolsto make our own games, and you know what kindsof games we make. Then we also hand themoff to you. If you look at the kindsof games that we are making, we are certainly thinkingabout networking and we are going to make surethat Chaos is supported in the kind of experiencethat we create and I think alsothe kind of experience that you are creating. With that, I am goingto hand it off, because I think we should heara little bit more about how you actuallymake stuff look good and what is happeningunder the hood. I am going to give itto Jim VanAllen. [APPLAUSE] >>Jim: Thanks, Matt. Thanks forcoming out today, guys. I am excitedto talk to you today about the art sideof the Chaos demo. We had a really talented teamon this project, and I can tell youit has been a lot of fun playing with this systemover the past few months. I was putting thispresentation together – sorry,I have to adjust the thing here. I started to ask myself,as an artist, what do I really wantfrom a destruction system? Here is what I want.I want to take random geometry, fracture it intoa random pattern, allow a random user to hit itwith random forces in random locations, and control exactlyhow it looks. To boil it all down, it all revolves aroundone key word, control. This is what I really want. I want something that looks liketotal chaos to you, but behaves exactly likeI want it to, runs in real-time, and maybe meets the needsof our design environment art and engineering teams. For me, everythingin this system revolves aroundthis one concept. All that starts herewith a new type of Asset that we are callingGeometry Collections. Geometry Collectionsare built specifically for destruction in Unreal. Mike is going to give youmore detail in a few minutes, but here are some key pointsif you are an artist. Geometry Collectionscan be built from one or more Static Meshes, including those gatheredtogether in Blueprints or even nested Blueprints. Geometry Collections let youchoose what to simulate, and they offerincredible flexibility in terms of how you organizeand author your destruction. Once we haveour Geometry Collection, we need to break it into pieces. Aside from a few items that werehand modeled into large chunks, every piece of geometryin the Chaos demo was fractured in Unreal. Just as an aside there, we wereallowed to use anything we want. We could have usedoffline tools or whatever. But it just – being ableto fracture in-Editor made the whole process somuch easier and it is awesome. We can fractureeach part individually and we can apply one patternacross multiple pieces. We have standardVoronoi fracture, but we also havea suite of options that let you dialin a specific look. You can do radial fractures,clustered Voronoi, planar cutting with noise, whatever you need to getthe most natural results. In a budget consciousenvironment, we do sub-fracturing, which lets an artist controlwhere to add complexity. Each time you sub-fracture, an extra Level is addedto the Geometry Collection. The Chaos system keepstrack of each sequent Level and stores that informationinto something that an artist can control,which we call a cluster. Now, here is an exampleof a mesh where each fracture Level is combinedinto its own set of clusters. These are a bit differentfrom other systems in that the Chaos solver treatseach node like a single object until enough strain is appliedto cause a break. When we are simulatingLevel 1 here, the system is only calculatingthose pieces. Conversely,if we turn of clustering, every single leaf node falls. Not super efficient,but it also does not look great. By tweaking our cluster’sstrength values, we can therefore get a resultthat looks good and performs as optimally as possible. If you are like meand you are too disorganized or I call it artistic to meticulously keep trackof each fracture and its cluster level,we have an awesome tool that lets you flattenthe hierarchy and procedurally set upyour clusters for you. This allows you to effectivelyspan fracture an entire building and sort it outafter the fact. You can reduce a reallycomplex fracture to 5 or 10 objectsif you need to. Because you can haveas many Levels as you need, you can explicitly controlthe density of each Level, which lets you control how -sorry, lost my track there. Controlling how difficult it isto break each Level is one of those wonderful times when performanceand art requirements align and make something awesome. The next concept we need todiscuss is the Connection Graph. This is a lightweightconnectivity map that is a bit of a differentparadigm for destruction. Here we have a fewstatically anchored pieces, but everything else in the scenehas the potential to be dynamic. Rather than swappingfrom kinematic to dynamic like many other systems,our system applies strain, which in turns breaks theconnections and chaos ensues. We have found this to be a greatway to maximize interactivity while still retaining control over the amountof active rigid bodies. We have everything set up.We see how it works. How do we interact with it?We do that with Fields. Fields are the way that artistscan directly interact with and control simulations. Fields can be used to controlany attribute on any partof your Geometry Collection. You want to vary your mass,make something static, make the corner more breakablethan the middle, apply some force – all this is controlledwith Fields. Fields are created andcontrolled through Blueprints, and in this example,we are applying some strain followed bya bit of linear force. Radial falloff volumes control where the strainand the force is applied. Because this isa modular system, you can stack Fields together,use noise multipliers, and do just about anythingyou can imagine. This example is the basis for aWeapon Field that runs on impact and can be expandedto do sticky bombs, high-caliber weapons,and rockets. Next, I will show youthree specific Field types that we used. Anchor Fields,they anchor things. They do exactly what you think.They lock the nodes in place. In this Level,we used Anchor Fields to lock the top and bottomof the pillars and walls just to controlhow much things collapse. These Fields are often the base upon whicheverything else is built. This is a fun one.It is a Strain Decay Field. This applies strainto the Geometry Collection. With enough strain, you breakconnections and the pieces fall. One of the really cool featuresof this system is that the strain requiredto break each cluster can be tuned by the artist. This allows you to specificallytune your simulation for aesthetic quality,gameplay interactivity, or performance as needed. In this example, the StrainField is being animated upwards and applying some force. The box underneathis a Culling Field that keeps it from getting crazy and reapplying the strainover and over again. It is a lot of fun to play with. Finally, this is a Sleep Field.It is pretty straightforward. They put things to sleep. Butit is a really powerful tool. Here is a video to illustratewhat is going on. No?Oh, yes. Yes, it is. Good. Did not know if thatwas going to work. Sorry. Any object that movesbelow predetermined velocity is put to sleep. Sleeping objects can wake upand start simulating again if they are hit by a weapon. Aesthetically, this keeps piecesfrom rolling around like crazy and being distracting. Finally, it gives youdirect performance throttle over a large area.As you can see here, I can completelydestroy this gameplay area without any noticeabledrop in performance. Finally, we are goingto talk about caching. With caching, high-fidelitysimulations can be pre-cached and played back in real-time resulting in a kinematicGeometry Collection. This means that you will be able to author large-scaledestruction events and still allow interactivitywith the player and the environment. That is my overview. I hope it gives you an ideaof how artists can control just about every aspectof the Chaos system. I cannot wait to seewhat kind of crazy destruction you guys create with this. Now, here is Mike Lentine,our Lead Physics Programmer, to talk aboutthe technical side. [APPLAUSE] >>Michael: Hello, thanks, Jim. I am Michael and Irun our Physics Team at Epic. When we set out to create a newphysics and destruction system, we first wanted to figure outwhy we were doing this. We had two primary goals.The first was to give the power to our content creatorslike Jim and Matthias to generate the resultsthat you have been seeing throughout the courseof this talk and in our demo. The other is we wantedour system to be scalable. This means effectivelytwo different things. We want to be ableto create a single setup that goes all the wayfrom a phone-powered device all the way to kind ofa high-end PC. We also wanted to be ableto continue to scale as we get more and morecomputational power over time to hundreds of thousandsor millions of objects. In order to do this,we had to develop a number of different techniquesthat I am going to go through. The first oneis non convex collisions. As you create sortof polygon soup and you start fracturing it, you are not going to come upwith every object being convex. The traditional waysof dealing with this are either to collide it against the Mesh itself,which gets really expensive, or to use convex combinationapproximations. Unfortunately,those can get expensive depending on howmany convexes you have. If you have too littleor too few number of convexes, then you geta pretty poor approximation of the actual object and you cannotget the desired behavior that you see kind of herein this example. What we did is we came up witha completely different collision representation that allowed usto create fractured pieces that were art directed,accurate, and fast. You have heard a little bitabout Fields. We did use them a good amountin sort of the demo, which this video is from. The primary ones that we havetalked about thus far are things like strain or force applicationin order to break up buildings. But Fields in general are a muchmore powerful concept than that. They are really just an objectthat you can place into a scene that essentiallygive you control over any propertyof the physics simulation. For example, if you wantedto take the ground here and change the frictionbased on certain areas, you could take a Box Field,put it down over your ground, and then makethat part slipperier or stickier for your physics simulation. This is an example that is muchsimpler than the one Jim showed. Then I am going to go throughin a little bit more detail that we used in our demo. The first nodeyou can see on the left is a radial falloff Field,so basically it just has a value and then starts falling offas you get further and further away from that pointin space that you specify. We then add essentiallysome random noise to it and we have a numberof different nodes for how you apply noise. Then we combine those twowith a culling Field that basically turnsthat radial Field into a sphere, adds the noise into it, and then we apply that in thiscase as a torque application every time essentiallythe weapon is shot in our demo. We have talked about how Unreal is tightlyintegrated with Chaos, and this is extremely importantfor things like destruction when it comes to variousdifferent other systems in the game such as Niagara,audio, and gameplay events. The two primary eventsthat we utilized in our demo are collisionand breaking events. Collision events happenevery time two objects collide, which is pretty intuitive. Breaking eventsare somewhat similar, except they happenwhen an Object essentially breaks apartfrom the building. One thing that Matttouched on earlier is this can get unwieldypretty quickly. When you are making destruction, you expect to seea good amount of smoke and dust. But if you wereto spawn particles every time you had a collisionor a breaking event, you would just be inundatedwith huge amounts of smoke and you would not beable to see anything. We provided a number ofdifferent filter mechanisms to try to reduce that. For instance,for smoke and dust, what we did is weessentially created a grid. We essentially hashedthe various events kinds of into that grid and then spawned say oneparticle system for each cell in that grid to reducethe amount of dust and smoke that you end up getting.Another example is for audio. You do not necessarilywant every single event to generate a sound. What we did is we basicallytook all the events, we sorted by mass, and the ones that were heaviestessentially generated sounds whenever destruction occurred.This gives us a way so you can hearall kinds of the big events, but you do not hearall the noise at the same time. Then of course, for gameplay,Matt went over how we used that to create reactionsfrom Characters. A big component of this systemwe mentioned before is scalability. Caching is one wayto achieve scalability, but we really wantedto make every part of the Chaos system interactive.The system we came up with was essentiallyan interactive caching system. The way this effectively worksis you record your sim in Unreal using the same toolsas we talked about. It will run at sayfive frames per second, maybe one frame per second, depending on however complexa scene you want to do. It will record that simulation.It will then essentially – there are a numberof different ways you can use to play it back. But one way to getthe max of interactivity is you will register essentially all those Objectswith the physics system. It will effectively be sleeping while they are playingback the cache, so they have very,very little cost. But they will be set up, and so if any of them collidewith something that is simulatableor interact with a Character or anything like that,they can go active. In this scene, I think we had300,000 or 400,000 Objects through this cache playback, and if we were to startinteracting with these Objects, then we could be maybesimulating a few hundred but still have kind ofthat scale of 400,000 Objects being usedas part of your destruction and not have to paythe cost of doing so. Another thing which we did,which was fairly important but a little bit under the hood,is we redid the way that Physics talks to the Enginefrom a threading perspective. This is optional, but right now,if you download Unreal Engine 4.22 or before, physics runs as partof the game thread. This is a fairly simple model, but it does not give youa lot of control as to how physicskind of interacts with gameplay. One of the things we didwas completely decouple that so we can have a completelyseparate physics thread. This gives us a numberof different cool features. One is the abilityto set whatever time step you wantfor a physics tick. If you want to doa fixed time step, which is important for thingslike networking situations, then it is very easy to do so. If you want to run physicsat a super high tick rate compared to a gameplayfor very accurate interactivity if you are not runninga huge number of Objects, you can do that as well. If you want to have highlyinteractive gameplay and a lot of physics simulatingbut you do not necessarily need it to run quiteas fast as gameplay – if you are ticking gameplayat 60 hertz, you can tick physics at 30 hertz and get twice the amountof computational power than you would traditionallyin the Engine. We covered upon GeometryCollections a couple times. What exactly is GeometryCollection? It is an Actor representationthat we use for rendering a destructible Object. It is somewhere between sort ofa Static Mesh and the Skeletal Mesh representationsinside the Engine. The Static Mesh is just a wayto represent a single Object which can be transformedthrough space. If we were to try to representthis many pieces via a sequence of Static Meshes, the cost of the overheadof Static Meshes would get far too largefor that to be useful. Typically, the way to avoidthat is to use Skeletal Meshes, which give youthe concept of different bones with different transformson a single representation, which helps withthe rendering cost overhead. However, there are a numberof limitations with that system. One, there is a lot moreoverhead we need with Skeletal Meshesthan we need with destruction because it supports all sorts ofanimation tools like linear blend skinning.It also has fairly slow limits in terms of the number of bonesyou can simulate. To try to represent thisbuilding with Skeletal Meshes, you would still needprobably 100 or something Skeletal Meshes to represent it. A GeometryCollection is essentially a representationwhere you can have basically as many bones as you want,similar to a Skeletal Mesh where it does not supportany type of skinning essentiallyother than rigid skinning, which is all we needfor this kind of simulation. Because it is low costwith low overhead, we can have hundreds ofthousands of Objects in these. From a rendering standpoint,that means that essentially we can payone draw call cost per Material for something like this,despite the fact that it is breaking upinto thousands of pieces. One of the things we havekind of been harping on a little bit over and overis that everything is in Engine. I am not going to go throughfracture tools too much, but the really important point that we want to conveyis the ability to iterate and the abilityto see your results and not have to go inand out of external packages. That makes a reallypowerful tool for everyone. Jim touched upon Levels. What Levels is is effectivelyour destructible LOD system. This is not LODs froma traditional geometric sense, which is of course,depending on how far away, you are essentiallya different representation. This essentially determineshow much computational power you are going to spendon your destruction simulation depending on how muchspecify is available. If you have a piece of geometry where you break it upinto 10 pieces, each one of those piecesis 10 more pieces, and so on and so forth. What you can do on yourlow-end platforms is say, I am not going to want tobreak up anymore than the very first Level. Then you are only going to have10 pieces or so, but you will never havethe problem of needing to simulate way more pieces than you have the computationalpower available to do so. The other thing it gives youis scalability. As you break it up, you areonly ever considering the Level underneath the Levelthat is currently simulating. Even on a high-end platformwhere you want to be able to simulate a fairly largeamount of destruction, this entire scene is broken up into hundreds ofthousands of pieces, but we are only really everconsidering the 10 or so for each of these pillarsat any given time until they break up further. Finally, Jim kind of touchedon this as well, but it gives yousome cool-looking effects. We can do things like shootthe bottom and the top offof these pillars, get kind of the entire centerof the pillar falling, and then further break that upthrough forces and strains. The last thing Iwanted to talk about was dynamic strain evaluation. As we want to scale to largerand larger pieces of destruction in buildings, we need a way to authorhow these things break up without putting a huge amountof work on our artists to do everything manually. We talked a little bitabout the connection graph. What the connection graphis from a strain evaluation standpoint is each ofthose nodes and connection graph represent an Object, and each of the edgesthat connect those nodes essentially have an allowableamount of strain. That strain can be setwith Fields or a number of other ways that we kind of providein the engine. Then as we apply forces or decaystrain or whatever have you, those connectionsessentially break. This also helps us get an amountof cool rhythm with it, because if you essentially breakoff a corner of a building, you will essentially getthat entire corner falling like you sawwith the pillars example before. When you put allthese things together, we can do quitea bit of simulation. This was a muchheavier modification that gives you a sense ofjust how much destruction was put into the Levelthat we created and how many bodieswe can push through this system all running in real-time. Here, we basically applya huge amount of force and everything that we touchkind of crumbles pretty instantaneously. At the same time,all of this stuff was created in Enginevia our artists, and this is all runningin real-time. Now I would like to hand it overto my colleague Jeff from Intel. He is going to talk a little bitabout making Chaos faster. [APPLAUSE] >> Hey, I’m Jeff Rous. I am at Intel as a SeniorDeveloper Relations Engineer. I will talk to youabout making Chaos faster. At some point, you have gotall of those systems simulating like Michaeljust showed in the last video. You have to do all of thaton the CPU. What we did is we workedwith Epic to optimize the low-level solvers,the data structures, and improve thethread parallelism to make things even faster. One of the key learningshere is we learned that C++ is bad at SIMD.In performance critical areas, we integrateda tool called Intel ISPC and saw roughly 3x gains overthe existing scaler systems, so that was great.Now you can have even more thingssimulating at the same time. On the data structureside of things, we found a bottleneck in TSet, and if you know Unreal at all,that is a hash container. We were finding thatthat was a bottleneck when we were doing duplicateremoval in intersection testing. Switched that to TArray,remove and swap, and great. Now we are up and running again. Also, ParallelForcan be overused. Some oversubscription is good, but you do not wantto go overboard. If you have got thousandsof jobs going on at the same timeor tens of thousands, sometimes you can get intoa situation where the thread startor the work start overhead becomes too much and it is actually fasterto run it on a single thread. Batching is helpful here, especially if your data accesspatters are cache friendly. What is this ISPCthat I was saying? CPUs since the early 2000shave vector units that programmers can useto speed up their code. This is known as singleinstruction multiple data, and you can do eight floating point addsin one instruction, for example. We use this a lot in theChaos system to make it faster. One of the problemsis that with C++ it is hard to get to thecompiler to vectorize anything. The usual solution isto use compiler intrinsics, but you then have to updatewith new instruction sets. If you are working on PC, you also have towrite those for ARM or any other platformthat you want to support. This is where the ISPCcompiler comes in, because you can write it onceand it can work anywhere. ISPC gives you implicitparallelism in a language that looks like a shaderlanguage that runs on the CPU. Like a shader language,it assumes SIMD by default, and it looks a lotlike GPU shaders in the waythat they are executed. A big benefit, like I said,is you can write ISPC once, compile it to manyinstruction sets: SSE, AVX, AVX2, even ARM. It works on PC,console, Linux, Mac. If you are compilingfor multiple instruction sets, there is an autodispatch mechanism where it choosesthe right CPU instruction set, the best onethat your users support. You do not have to worry about doing compilerintrinsics anymore. We made good useof this in Chaos, and you can use itin your projects too. All you have to do is includea module in your Build CS, add ISPC files,include the generated header that comes out of that, and Unreal Build Toolwill handle the rest, including generating allthe different instruction sets, handles the linkingof the Object files, and you are up and runninghopefully faster than you were before. All of this was done to make itas seamless as possible for Unreal developers and of course the Chaos systemthat makes good use of it. What is it good for? It is good for densecompute-bound workloads like Chaos. Heavy math like physicsintersection testing, cloth, CPU vertex transformation. It is best withcontiguous memory, so when you are doing load,manipulate and store, like if you are workingwith a TArray of data, it works best whenthere are no data dependencies between operationsand very useful when combined with ParallelForbatching mechanism. If you remember, I said it acteda lot like GPU shaders. They do, with some differences. Whereas GPU shaders all runto completion independently, with ISPC,each lane, SIMD lane, runs one instructionof the program. The differences liesin that ISPC runs in lockstep, so all of those SIMD lanesrun all at the same time, so they are guaranteedto converge at the end. When you have branchesin your code, you will run the trueand then you will run the false, and that is fasterthan it sounds, but you get convergenceat the end there. One of the nice things thatthis gives you is the ability to do reductionsacross SIMD lanes. For example, if you are tryingto find the sum of an array of integers, that is very fast.We use that quite a lot. The bottom picture gives you anexample of what ISPC looks like. This is an RGBto gray simple function. What we have hereis convert N values using three multipliesand two adds. With AVX,when you are running eight wide, you can do eight of thoseat a time. Two of those operations can befused into FMA instructions, so you are going even faster. This functionis roughly eight times faster than the scalerimplementation without needingto use intrinsics, and it remains readable. It works on everywherethat Unreal does. That is a bit about what Inteldid to help optimize the Chaos demo.Look for ISPC changes in 4.23 that are rolling outalong with Chaos. We have an ISPC talkif you are interested in hearing more tomorrow.Big thanks to my co-presenters, who I will invite back upon the stage. Thank you. [APPLAUSE]