Building High-End Gameplay Effects with Blueprint

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello everyone my name's Chris Murphy I'm an unreal engine evangelist I handle Australia New Zealand and Southeast Asia and today I'm gonna be covering building high-end gameplay effects using blueprint now we're gonna have to be stepping through a couple of things to really get this working because at the moment we have this nice pretty field that we can say and it looks good but I'd really I'd love to destroy it I just run a big all laser through the entire thing so we will so today we're going to be covering a couple topics to do that and the first of those is looking at bland scape system within unreal now after we go through landscapes we're going to be looking at blueprints themselves what are they how can we use them beyond blueprints we're then going to be looking at render targets now render targets are how we computationally draw something onto a texture so we're gonna use that as a way of leaving a nice wake of destruction behind a little laser and wherever we move it and then of course we're gonna be integrating that render target into the blueprints so that we can pass some script in and create a more holistic effect now to begin with I actually want to go arguably a little bit off-topic I actually want to begin by looking at landscapes themselves and give you a quick idea of how these things work now essentially landscapes allow you to paint different materials and sculpt a larger terrain in any way that we see fit so I'm gonna get a paint I'm gonna select dirt and I'm gonna draw this in and you'll notice that we're able to actually just draw in sections and have areas that are dirty in areas that are grass but of course you can also see that within the grass layer we have something rather interesting going on whereby we have this heathering happen so we have these these flowers popping up every now and then within it and that's because that's actually part of the grass material itself and I'll go into that in just a little bit and of course if you're unfamiliar with landscapes the other thing you might be interested in is that you can just deform the geometry however you see fit there are various tools to do weird and wonderful things but I'm not going to be going into them too heavily today instead I'm actually gonna open up the landscape material when we're gonna dive straight into that so this this is the part where I'm gonna be a little bit off-topic because honestly whenever someone setting up a land material they often make what I would argue is a little bit of a mistake and then is that if you look at this material you'll see that I have dirt layers grass layers and then I have a blend over here now some of you may be looking at this and saying well Chris why do you have multiple dirt layers and the thing is is actually not different kinds of dirt which is maybe what you expect it's not different kinds of soil it's nothing like that instead what happens is we have a macro dirt and we have a micro dirt whereby I get the material for dirt and I make one of them really really big which means at a distance I don't see any tiling because it looks great from afar okay but of course if I was to have that it would look good from afar but up close it would look far from good because you would just have these big old textures run on you and over look hideous right so the way around that is I actually use a distance blend to merge between a tiling texture that's up closed and under your feet and if we were to look at this very carefully we're going to zoom in so it's a little bit more obvious I'm just going to move towards this dirt if you look at it as i zoom in you'll see there's a threshold about there where I'm actually switching between dirt types can you see that so obviously because I'm moving so quickly and we're looking out for it it stands out a little bit but in situations like this all tiling is gone but if I was to look down on my fate it actually looks quite nice so this is a technique that I really really encourage people to look at because when you're setting up landscapes it's super important now I'm gonna apologize ahead of time we're gonna be making something pretty powerful in this session but it is gonna result in me having to go reasonably quickly because they keep me on a tight leash of 25 minutes so we're going to be powering through so if I do lose you you have my apologies but you're more than welcome to catch me after the session we can discuss various things and I can point you in various directions what you may have missed now that blend that I mentioned is happening through here and it's done by just looking at a position in the world I'm gonna right click and you can see that the mask changes as I get farther away when it's black it's one thing when it's white it's the other thing I'm gonna be utilizing that kind of blend in what we do beyond this so to begin with we've got our landscape we can see what's going on here but it would be really nice if we started to assemble a laser so I'm gonna right-click now and I'm gonna create a new blueprint now blueprint is Unreal Engine scripting language it's what we use to bind various elements together so you can write code you can do all sorts of crazy stuff within blueprint or you could set them up as just a nice way of having certain visual assets that are tied into one another so we're gonna be doing that now we're going to be setting it up such that we have a blueprint that's actually based on an actor now for anyone that's unfamiliar with it an actor refers to something that has a transform essentially and a transform is a location a rotation and a scale so essentially anything that can be placed in the world is typically gonna be inheriting from actor I'm gonna get this and select it and I'm gonna call this VP shockwave actor we're gonna open it up now you can see that when I pop it open we have a couple of things on-screen but most importantly in the center there's the viewport which shows you any elements of the the blueprint itself that are currently active and then on the left hand side we have the components so that's actually where we add things to the blueprint itself and I'm going to go ahead and add a particle system component and I'm just going to call this beam effects and I'm gonna set this beam effect to be the beam that I created earlier now I know a lot of people have seen Niagara which is the new effect system that Unreal Engine has coming in this effect is not done in Niagara this is using cascade so it is it is still obviously sufficient for what we need to do but in future you will be able to create some pretty powerful effects so I've added the beam effect but if I was to look at the base of this you'll see that we have something that honestly I'm not really a fan of see how the beam just kind of just caps out I'd really like to add something in the bottom of this to really have you know finalize and add that little bit of polish so I'm gonna add a static mesh component and when I add a static mesh component I'm just gonna call it beam cap and I'm gonna set it to a 3d mesh that I had from earlier called lava blog if you were to look at lava blog you can see it's it's only barely appearing underneath there but it can scale this up to two times its size and you can now see that we have a nice tessellating mesh that's going to be the the ooze kind of coming out of this beam now for something like this I've gone ahead and we're working with something from earlier but it's worth noting that while in cascade you can set up a 3d mesh as something that's within the effects I haven't in this case and the reason for that is that it's a Tesla lighting mesh and tessellating meshes can't be used within cascade so I've it is an extra component now if I was do you compile and go back to here and just drop this into my map I would have a beam that was doing its job in exploiting and disrupting the serenity so if I look at this then when I go up close we have all of these rocks flying in the air and this big explosion effect happening but what we don't have is grass that cares in any way about what's going on so it's time for us it's not looking at how we can actually create an effect that's gonna let us do that now for us to do that I'm gonna actually be working on the landscape itself and building something kind of creative into it first off I'm gonna disable the grass because you can see that these 3d meshes are being placed through the material itself in this landscape output I'm gonna hold down one and add a constant and just turn off the grass so that there's no 3d meshes being placed I'm then gonna go up top and I'm temporarily gonna disconnect to the main section of the landscape and I'm gonna work here by dragging off of this and making a material now when I make a material I'm gonna add a texture so if you think about how this material is going to work if we want to have a big trail of distract distraction going behind us we're gonna have to basically project that texture from top down is it from with me on that we're gonna need something that shows you where the trail is and to do that what we need to do is first off have some sort of way that the texture can be projected such that it aligns with the rest of my environment so to do that what I'm gonna do is add a texture and I'm gonna set this to be just an arbitrary texture ue4 logo works I'm gonna get that and just plug it in now getting it apply and let it recreate the landscape and you'll notice that my landscape is gonna be a little less pretty but it'll demonstrate the first issue that we have to kind of go and fix which is that when I apply a texture to a landscape it's not automatically getting that texture and just plucking it down over the whole thing instead it's tiling over and over and over again so I need to get this to be the size of my landscape and to do that what I'm gonna do is look at the current worlds position of the pixel we're rendering when I get the world's position what I'm able to do is say look I don't care about excellent so I don't care about the Zed axes I only care about the X&Y coordinates because because we're projecting downwards Zed doesn't matter also guilty confession I really enjoy using the word the letters ed whenever I'm referring to an American audience it's like a nice guilty pleasure for me as an Australian so I'm gonna get this world position and I'm going to apply a component mask now that gives me the X and y and for anyone the one is wondering why it says R and G it's because RGB hold the values for x y&z now within this I'm then gonna get my orangey and I'm gonna divide it by a value so that we can kind of normalize it to the map itself so I'm gonna divide this by fifty thousand four hundred and for anyone that's going that Chris why would you divide something by fifty four thousand four hundred that's a ridiculously big number the reason is is that by default the standard Unreal Engine landscape size when you've just clicked create is fifty thousand four hundred units across and that's information that I'm probably going to keep until the day I die these numbers just stick in my head so we've got this and it's a it's Sonic you're under out I'm gonna pull this backwards and we're gonna look at the landscape and you'll see now that the Unruh logo is actually being projected across the entire thing which is great because it means that when we get ourselves a Destruction texture going into it we're going to be able to use that texture to now be projected into the world so to move beyond this I'm gonna go ahead and I'm gonna right-click in the content browser and I'm going to create what's known as a render target now a render target as I mentioned earlier is a texture that can meet modified at runtime so it's gonna be something that we can kind of fool around with and paint the destruction trail onto it I'm gonna set this arti destruction to be the texture that we're using I'm getting it apply so it renders in background and now it's time for me to move on to the next step now if you think about how we're working here we have a landscape that's going to allow us to have destruction being painted through it okay and that landscape is gonna have to show this effect now this this effect of the destruction is going to have to have the texture itself to hold the information but more importantly we need to have some way to save that information to the texture now to do that we need to create another material that is going to hold the brush which is essentially going to be given all sorts of information and then it's going to get rendered down to that render target so I'm gonna create a new material then I'm gonna call em underscore arty brush now if anyone is worried about this brush that I'm about to make and they're looking at this going Chris that's a whole lot of math what are you making me do it's worth noting that this is available within the content examples of the learn tab so you can pull it down for yourself and set it up now if we're setting up something like this I'm going to need to know a few things first off I'm going to need to know the position of the force that's being applied in the world I'm getting it the force position and we're going to find its position relative to a standard texture coordinate so if I get my texture coordinates and I look at this I can see that this gives me the cool one that's running from 0 to 1 on the x and y axis or the red and green which is why we get one one down in the bottom right hand corner which is what makes up RNG being by the value of one now I'm going to find the distance from that current X&Y position to an x + y position that I'm reading in and again you have my apologies for this if this does just kind of jump over people's heads just a little bit I know I am going reasonably quick so I'm gonna get the force position and I'm only going to get once again only care about the X&Y I'm gonna find the distance and you'll notice that when I find the distance between those two I get a gradient coming from the upper corner and that's because as I get further and further away the value gets bigger and bigger which means that it goes away from black a value of 0 and approaches 1 a value approaches white which is the value of 1 now that I've got the distance what I'm going to do is I'm gonna set this false position by default to be 0.5 0.5 which will just put it in the middle of my brush now for here I'm gonna flip it so that we have white in the middle and black on the outside it's gonna look a little bit strange because it's actually going from black to gray which means I'm now going from white to gray so it'll look a little bit strange for just a moment but I'm gonna read in the next variable that's important to me which is going to be the force size I'm gonna set the force size to be 0.5 and I'm going to subtract the inverse of that from my current brush once again this material is in the content examples and you can pull this straight out so we've now got something that looks a bit more appropriate for a brush and that means that I'm going to do the last little thing that I need to do which is saturate it which clamps it to a value between zero and one and after I've saturated it I'm going to multiply it against the scalar that says this is how strong I want it to be which I'm going to call force strength and I'm going to set that to a value of 0.5 it's plugged in you're gonna go to emit now this may seem that the brush is now done I've got myself a nice radial fall-off but there is one last thing I need to do which is if you think about how a trail of destruction moving through the world would work it needs to keep the previous render target in like in place because we're keeping like it was smearing that white value of the the destruction through the texture itself and at the moment this would actually be painting black and white into the texture so what I need to do is tell this to be an additive blend by going down to my blend mode and that will now add this to the previous render target resulting in it allowing me to create a trail so I've got those set up and getting it apply and save and it's time for me to go back into my blueprint and do something a bit more interesting every time this pops up I forget just how bright it's gonna be on my screen so we've got this in place I'm gonna go to my construction script and I'm going to start modifying what I've created so in my construction script for anyone that's unaware a construction script holds these scripts of when an object is first constructed so when you add it to the world it's going to execute this and in this situation what I wanted to do is create something in memory that's gonna hold a reference to my my brush so I'm gonna say create a dynamic material instance and make it equal to the brush now you may have done something like this before if you're ue4 user typically people do something like this when they're working with like setting the color of an object or doing something like that but you don't actually need to do it to a 3d object in the world interestingly enough you can just have the material existing in memory and then we can play with it there so I'm going to create a tunnel dynamic material instance and I'm going to promote this to a variable as something that we can store and I'm just gonna call it a brush mid mid standing for material instance dynamic so I'm gonna go to my event graph which handles the code that executes while the game is playing and I'm gonna create a new custom event called draw a location and within draw at location what I'm going to be doing is just setting those parameters that I previously inside of my material over here so the first thing I need to do is set this force position so I'm gonna go get my brush bid and I'm gonna say set vector and just set a vector parameter the vector parameter I'm setting is called force location and I'm going to set that to be a value that's normalized between zero and one so it's going to tell me where we are relative to that big square that we're projecting onto the environment now to do that what I'm going to do is I'm going to look at my current location and I'm just gonna divide my current location by the size of the map which we established before flicked which we established before is fifty thousand four hundred you know Rach click promotes a variable and I'm gonna call this map size and just plug that in and it's now time for me to quickly do this to the other variables so I'm gonna get my brush mid once again and I'm gonna set the scalar parameter for force size now the size of the brush I typically would want to be a value of 1024 it's just 10 meters however I'm going to have to divide that you're gonna have to divide that by the map size so again it's a value between 0 and 100 1 great plugged in and then finally the last thing that I need to do is set the force strength so I'm going to connect that again and say for strength now what I'm going to be doing here is setting the strength to be equal to the time since the last time I rendered it multiplied by a number to do that I need to get the Delta time which is the time since the last tick and I'm just gonna multiply this by a number that's gonna control how powerful it is which xx seems like a good fit now that I've done that I need to render this to the texture and to do that I'm just gonna get the brush and I'm gonna right click and it'll say render to texture oops render material sorry there we go draw material to render target I got it in the end I'm gonna get that and it's going to say which texture the one that we created which material well we want to set it to the brush mid so it's rendering this to that and how do you compile and save I would need to do one last little thing on tick I'm gonna call draw at location compile save so if I was to go back to my shockwave actor and just zoom in can he hit play oops that was a good trick falsification for size for strength location sorry about this everybody I've clearly made one tiny mistake in my material force position had to happen eventually I see what I've done I called it force position and I called it force location good trick I'm like this should be working fantastic okay so now that I've said that you can see that as I drag this through the world we've got something that it works okay it's gonna start to be the the important part of our effect two things I want to change first off I want to open up my render target and I'm just going to increase the quality of this from 256 to 512 be aware that when you do this you're getting something that is going to be when I double the resolution it's four times the overhead because it's double X and double Y so one two three four so I've set that I'm gonna hit save and now it's time for me to go and I'm gonna start building this effect so there we go we can see that's a much nicer smoother circle of we're painting I'm gonna start building this effect back into my landscape itself so I'm getting it stopped and I'm gonna open my landscape so let's go back into the simple landscape and it's time to to kind of clean this up a bit so first thought may need to tell this I need to have I've got mask fits between zero and one right and moreover it's zero we want to have it equal to my previous landscape and what I'm gonna do is set it so that whenever at 0.5 that's when it's going to be charred ground and whenever it's 0.5 to a value of 1 that's when I kind of want to have some lava and general destruction coming up so I've gone ahead and already made a material function ahead of time called charred ground which I'm going to be using for this so to do this if I just quickly preview this chod ground effects so I'm just moving these down I preview this charred ground effect I'm just gonna copy these UVs over to it if I was to preview this effect it would look like this preview it and you can see that it's charred and looking kind of gooey and then when at the moment I've set it to a sine wave for testing that's going to raise the lava height and drop it again so what I'm gonna do here is I'm going to tell it to blend as I said between the existing material and the chod ground material and as I mentioned I need it to be whenever it's a value between 0 and 0.5 which means I'm gonna look up the existing texture and if I multiply it by 2 what that means is every value that was previously 0.5 is now going to be a value of 1 right so 0 to 0.5 is now going to be a value of 0 to 1 I'm gonna tell it to I'm gonna clamp it using a saturate node which is basically saying ignore everything off to 1 and everything below 0 and I'm gonna connect that to my alpha and then from my lava height whenever it's 0.5 to 1 I'm gonna do a very similar piece of functionality whereby I get this value I subtract 0.5 thus making it between negative 0.5 and 0.5 I'm going to multiply that by 2 thus making it a value between negative 1 and 1 saturate it which makes it a value between zero and one and district I just yep throws away all of the extra values and then I'm gonna connect that into here and I know I'm moving quickly but feel free to talk to me after the session so now that I've plugged that back in it's worth noting I've kept the actual material off in the sense that the start of the grass material off so it's gonna be rendering the sanded landscape but it's not going to be putting my 3d meshes in just yet that's because I want you to generally see how this effect works it's times like this there we go so you can see here that if I would see it play we've got the start of something interesting and of course they're gonna nicely link up because that black to white mask is now give us something that's just a little bit cooler now for us to finish this effect off what I'd really like to do is add the grass back in but I actually need to tell it to hide the grass in certain locations so to do that what I'm going to have to do is look at this render texture that we've got and remember that the render texture is just existing in memory and the great part of that is it means that any existing material can also reference that render target okay so what I'm going to do is I'm just going to reconnect the grass over here and then I'm going to just copy and paste this and I'm just going to open up the the materials for the grass and the flowers so I'm going to get the grass open it up and I'm gonna be a little bit cheeky and I'm just going to ignore everything that we have here and essentially just get this multiplied now at the moment this multiply goes between its it's white it's white wherever it's being lasered and it's black wherever it's not being lasered but if you think about it if we were to flip that around so that was it was black wherever we've lasered and white where if we haven't lays it and yes lays it is not really a word I'm gonna be going ahead flipping it around and then just multiplying that against the existing opacity mask so I'm gonna get this I'm gonna flip it and to flip it I do what's known as a 1 minus a which we saw earlier and I'm gonna multiply that against the existing opacity mask and then just plug that in fantastic I'm gonna hit apply I'm gonna grab all of this control C and I'm gonna open up the the heaven and within the Heather I'm gonna paste this in and do the exact same thing and I know this is quite ugly but it's cuz I've only got 25 to get through a giant laser you need apply and I'm just gonna give this a second while it builds the shaders fantastic so you can see here that the grass is being affected by it and the there we go the Heather's kicked in as well now so as I hit play I'm able to now move this beam and all of the 3d meshes that were in that way and then you know if I wanted to go the the whole way through this I could get that and make it blacken the the grass as it gets close up before I made it disappear and I could do all sorts of weird and wonderful stuff like that but at the moment this is working reasonably well you know we've got a pretty tired effect it's working pretty it's working quite nicely the only thing that I would like to do from here though is I'm gonna get stopped and I'm can anyone notice the problem with what's going on right now when I hit play my laser is not unlacing it's staying as it was okay so I actually need to clean this up and to do that I'm gonna go into my shockwave actor I'm gonna go to my chakra way back down I'm gonna create a new events and I'm going to call this a clear render target and when I call clear render target all I'm gonna be saying is call this little thing called clear render target 2d I'm gonna set it to just erase my current render target now the reason I'm doing it here is that I could say hey on begin play I want you to do clear render target but the reason I've made this a separate event is that if I click here I can hit this button called call in editor which now makes this event something that if I were to go into the world and select my shockwave I now actually get a button that whenever I click is just gonna automatically run that so when I click it all of my destruction is gone and if I hit play it's gonna just begin painting that destruction right back in there so that's what we're gonna be kind of it's all we're gonna be covering today in this session we have another session coming straight up afterwards if you have any questions I unfortunately run out of time I've gotta pass the server too short I think here who's going to be running through volumetric fog now if you want to ask me any questions I'll be lingering here for just a little bit and then for the rest of the day I'll be over in this community booth over here so you more than welcome to not just ask me anything you want and hopefully I can give you a better understanding of how Printworks otherwise enjoy the rest of GBC and I hope his talk was informative thank you very much [Applause] [Music]
Info
Channel: Unreal Engine
Views: 104,271
Rating: undefined out of 5
Keywords: Unreal Engine, Epic Games, UE4, Unreal, Game Engine, Game Dev, Game Development
Id: 67z5u8ZcEcw
Channel Id: undefined
Length: 26min 39sec (1599 seconds)
Published: Tue Mar 27 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.