VAT Paintsplat! Andreas Glad Houdini for Games(英語字幕版)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Hi I'm Andras Glorious Houdini for games today we're gonna take a look at creating an awesome paint splash using vertex texture animation as well as creating a fancy decal to go with it if you're making effects for games today this is one of the tools you need to have in your tool belt it is a big one so if you're only interested in specific parts of the workflow follow the time codes in the description a quick heads-up before we get started I will be using some of the newer functionalities from the game development tool shelf so make sure that you have at least version one point ten the development branch or newer you'll be good to follow along alright let's get going with this we're gonna use a flip simulation to create the actual splash and the first part of that is creating a source so let's drop down a new geo node and call it source let's dive inside and get rid of the file and let's bring in a sphere to start off and we're gonna need this to be a polygon sphere with quite a bit of geometry so we can distort it so let's set the frequency to like six and let's also reduce the size a bit so the flip simulation isn't huge and takes forever cool so let's noise this upper bits and these is way to do that is by using a mountain sop so let's drop one in right now we're not looking for any specific shapes it this is just gonna be a glob of paint but we can make it look a bit more interesting by doubling the height of the mountain sop and that's cool but that's super spiky in so let's reduce the roughness a bit maybe remove it completely yeah so that could be a glob of paint or blood or whatever goopy stuff you were trying to do the shape is cool enough to at least use as a starting point for a flip simulation so let's drop down a null and give it a name that we can find in the dopnet work later something like source now before we start simulating there is one more thing that would be good to bring out of this geometry and that's some initial velocity that we can use to start off the actual simulation and there's a quick and dirty dirty way of doing this and that's by just using the normals of the mesh as the velocity so let's set their up right now so drop in a normal node and make sure that it's set to add normals to the points that way we actually have some normals to turn into the velocity and as you can see when you preview in the normals they have some interesting patterns going on so it's gonna give us a good noisy start to our simulation now to turn this into a velocity that the dope network can actually use let's drop down a fluid source node and then we're gonna go ahead and ignore most of the settings on this node as they are not relevant to what we're doing what we do want to check out though is the velocity volumes tab because here you can specify a source attribute that it's gonna use to generate the velocity field and we just gonna go ahead and tell to use the normals so type in N and now you can see a preview of the velocity field that's generating and it has that cool noisy feeling that we had in our normals now on the fluid source node you could add some curl noise and some vortices to make your simulation look more interesting but I'm gonna leave all of that experimentation to you and instead go ahead and drop down a null which I will call vel and that's it for our source now we can move on and actually start simulating and to do that we're gonna go to the particle fluids tab and click flip fluid from object we're gonna select our source and hit enter and once that's done cooking will be dropped into the dopnet there we go and that looks nothing like the glob of paint that we so carefully crafted before well to fix that we need to go into the flip fluid object node and find the initial data tab well I'm just gonna zoom back in on our fluid now under the initial data tab we need to specify the sop path to actually use the source node inside of our source about naming perhaps but there you go now we have the glob of paint like we expect it is however looking a bit thin so let's give it a few more particles by lowering the particle separation to about a half cool let's play this and see what the simulation looks like so far okay it falls with gravity and these probably the most boring simulations you've ever seen let's fix that by bringing in the velocity field that we set up to do that we're gonna drop down a source volume node and the first thing to set up here is the volume path so let's point that to our vel node in our source right there except and we also want to initialize flip and not smoke so set it to source flip next we need to tell it what to do without volumes specifically the velocity field right now it's do nothing because it's set to none now we wanted to add velocity to our simulation so let's set it to add and the last thing to do is set up the SOP to DOP binding so it actually knows what the velocity field is called so down in the velocity volume field just type in Vel on both sides and there we go now we're ready to bring in our velocity into our simulation so let's connect the source volume to the third input of the flip solver which is where you plug in anything that will update the velocity there we go and before we hit play again let's just go ahead and delete gravity since that's not doing us any favors but now when we hit play we get some much more interesting looking simulations happening we get some stringiness we get some droplets following along and it's all moving in a really cool splat like manner and if you want to tweak the look all you have to do is go back to this source and change the mountains sop to make the source look differently because the normals will update and that will update the initial velocities so you can keep tweaking that until you have a splash that looks the way wanted to I'm quite happy with the look of this so I'm not gonna go back and change it however I don't need 240 frames of this I'm gonna need maybe 40 50 frames so let's hit the timeline 50 and let it simulate through okay so the simulation is done and it's looking cool but now we need to turn this into a mesh so let's jump up and have a look at the notes that the flip from object created first let's get rid of the fluid interior because no one cares about the inside now let's dive into this source fluid node this ton of stuff here and we need well pretty much none of it let's connect the import source node to the particle fluid surface node and just get rid of the rest so the particle fluid service node is gonna actually mesh our particles that are coming in from the flip sim and the cool thing is that we can actually control how it meshes and calculates the surface and all of that stuff for example if you want to make it a bit chunkier you could increase the droplet size a bit and that will make all of it a look a bit more blobby but for this we're gonna leave it as it is and you can experiment with all these settings on your own however we are gonna play with the filtering because here you can find a road and if you've done an alpha erosion on a sprite before this is the same thing but in 3d on the actual volume so go ahead and enable the erosion and then right-click and delete the channel that's by default it's hooked up to another channel and we don't want that because we want to animate the erosion over time so we can make the mesh disappear in a natural-looking way over the lifetime of the particle so to do that let's go to about half way through the simulation and alt mouse click on the attribute to set a key and then we'll go to the end of the simulation to set another key and for this key you want to find a value where the erosion has remote almost all of the mesh not completely gone because you're still gonna pay for that frame but as it it's one frame for being gone so to speak so for this simulation maybe four is good value so you're gonna have to try that on your simulate and just see what looks natural as the simulation plays and the mesh erodes away so when we click our way through the simulation we can see that more and more parts of it are disappearing so that's cool the erosion is working there are however some artifacts showing up in the mesh as the mesh is eroding a through it these square looking holes here in there and that can be hard to get around but sometimes you get a better result if you're using this spherical method instead of the average position method however even if that doesn't fix it I wouldn't sweat about it because usually these things play so fast and they're so small in game it's not gonna show up anyway now would probably a good time to take a flipbook just to see what this looks like when it's playing especially now that erosion is there and that's done so as you can see we have a interesting looking blob that dissolves in an omnidirectional splat and it disappears in a natural-looking way so I think we're doing pretty good so far so before we move on let's actually save the file so we don't lose anything give the file a good name as that will be used in the cache later let's go away the paint splat and let's actually go ahead and set that cache up so it's easier to work with in the next step so drop in a file cache node and the only thing we need to change here is the end frame delete that channel because we want this to be 50 like so and hit save to disk and with that the simulation part of this mesh is done now we need to perform a few operations to prepare the mesh to be exported as a vertex animation texture to stay organized I'm gonna rearrange out these nodes a bit and drop down a new node to do the remaining operations in but first let's rename this source fluid node to erode so we know that's where the erosion setup takes place next let's drop down a new geo node and call it prepare mesh and let's drop inside we're gonna keep the file this time and we're gonna point that to the cache that we just saved out and to make it just a bit less confusing let's go up and actually disable the visibility on the erode node so we only see the cache that we're reading back in so the first thing I notice is that there's not much going on in the first few frames in the simulation and we're still gonna pay for that in the texture so let's just cut them out so let's drop down a timeshift node this allows us to just offset the whole simulation in time so if you go up and click frame you'll see that the expression is $F so it will display whatever frame is currently active so if we add 10 to that it will remove the first 10 frames of our simulation and that looks better but this also gives us an error when we get above frame 40 because there's no more geometry so let's cut our timeline down to be just between 1 and 40 cool so now we have all action and no filler the next thing to tackle is the polycount right now it's way to many points so you can see there it's quite dense and if you have a look we have 46,000 points at this frame that's not gonna fly so we're gonna have to polyReduce this but before we can do that we need to actually convert this mesh to polygons so let's just drop down a convert can leave everything a default it will generate this type of geometry we need now let's drop down a polyReduce so we can get this down to some same values the amount of points in the mesh is directly gonna affect the resolution of the vertex animation texture that gets generated by the end of this and since those textures can't be compressed it makes sense to keep it as low as possible however we don't want to go too low because then we will lose all of the definition so it's a bit of a balancing act the way I like to do it is set the target to output a polygon count because then you know how many Poly's you're getting at all times instead of a percentage of the original and a thousand is clearly not enough as we can see here so let's try something like 2500 points you could increase this a bit but you don't gain that much more detail so I think 2500 is gonna work fine for this simulation obviously yes you are correct this looks horrible and very harsh edges and everything but we're gonna fix that so let's start by dropping down an attribute blur we'll use that just smooth out all the positions like that but be careful though so you don't lose all of those cool interesting shapes so if you feel that you lost a bit too much you can adjust the step size to gain or get some of that back now while that helped a bit if we remove the wireframe and just look at the pure smooth shaded version of this we can see that we really have some harsh edges that we need to take care of so let's drop down a normal node and set that to points and that will give us some smooth and soft normals all over the place nice it's turned to look quite good for the low poly count that we're actually looking at but there are a couple more things that we should do before we start exporting the first one being cleaning up the mesh as you can see we have quite a few free floating points so let's drop in a clean node and that should take care of most of them you could go in and remove all of the geometry that has a surface smaller than a certain number but I found that it's usually not worth it and I just leave it as it is right now so the final thing we do before we actually export this as a texture is just to drop down a null and call it VAT_OUT so we can find it from the rock network later and that's it the mesh is not prepared to be exported so we can jump over to rock but remember that when you have all of this setup you could go back and just update the simulation and recache it just to get a completely different result and that is a really powerful thing if you want more variations to use effects in the end now let's jump over to the output context and here we're gonna drag in a vertex animation texture you can find that on the game dev tool shelf drag and drop that in and this has a few simple settings the first is the method and that will depend on what it is you're actually exporting we're exporting a fluid sim so we're gonna have set this to fluid because it has a changing topology then we need to point it to our VAT_OUT node that we set up like so and then we need to set a target poly count and we already set this to 2500 so let's just match that when you said I need the target texture size you need to keep a couple of things in mind simplified what you need to account for is the number of points on your mesh times the number of frames in your animation those will be the number of pixels you need on your texture so for a 1k texture you have 1 million pixels to play around with plus minus some so for mesh that's 2500 points and only 40 frames of animation we should be able to fit pretty much in a 512 so let's set it to that and it's not the end of the world if it doesn't fit anyway cuz it doesn't need to be a power of 2 or anything you can leave the paths as they are but you need to make sure that you normalize your data in series one space because that means you don't have to use the HDR texture which saves you some memory and you also wanna pack normal into alpha because they're doing some kind of black magic were they calculating the normals based on the information that's just in the Alpha Channel it's magic and awesome so just leave it there the color map we don't need to export since we're not doing explosions or lava or anything like that the frame settings we can leave because that's reading the current frames and the rest is just information that we'll use later so we can go ahead and hit your render and once that's done it's time to jump over to Unreal first let's bring in the results of that render so find the folder where you output it all and grab out the mesh and the texture just drag them into the content browser like so and you can leave everything at default and hit import all close down that let's have a quick look at what it is we've actually created now so let's first open up the position map and it's gonna look super broken but this is actually what it's supposed to look like if we look at the RGB we can see that these are just our positions and if we have a look at the Alpha these are the values that will be used to calculate the normals for our mesh so don't worry if it looks weird it's supposed to be the same thing goes for the mesh if you open that up you're gonna see there's just a mess of triangles but don't worry about it the shader will actually transform all these into position for every single frame so let's start building that material right now so right click hit new material and give it a good name something like M_VAT_FLUID_BASE let's open that up and now we can finally start building this mathematically quite challenging material or we grab the one that's included in the VAT Rob so if you jump back over to Houdini and go to the Rob and you can find the shader code section and open up the fluid version select all and copy and then jump back to unreal click somewhere in the material graph and it control V and you have a shader network let's move this to the side a bit so we can connect everything to the route and to do that you just paint-by-numbers all of the end nodes are marked so you can see where it goes this goes to base color the next one goes to metallic and so on all the way until you get to the ones that say this goes to custom UV zero because that one does not exist so to do that we need to add them so select the route and under material open up this little arrow and number of custom UV set up to three and you'll added the amount of UVs you need so now you can just keep painting by numbers that one and there's one more down here that goes to customU 2 now before the material is done there's one more thing to do and that is actually marked up here so you don't forget it make sure tangent space normal is off and that is again under that little arrow used and uncheck tangent space normal and you're done so go ahead and hit apply and close this down but before you throw this onto your mesh you need to set up a material instance so right-click the material and create material instance call that something fancy open it up and let's have a look at these settings so normals data needs to stay on pack normal needs to stay on and we're not gonna care about the color ramp because these are just based on the settings we use when we rendered the vertex animation texture out and we just need to make sure they match now the bounding box Min and Max we actually do need to set up and those values comes from the VAT drop so if you jump back to Houdini you'll see that there is a section called data for real-time shader and that's where we can grab the values so let's go ahead and grab the max and copy that jump back over and paste that in jump over and grab the min copy and paste that in as well and the next parameter is metallic and you can do whatever you want with this but I'm gonna leave it at zero then we need to fill in the number of frames in our simulation and a bit of a heads up on this one it's very easy to get the wrong number here it's based on if you start them frame 1 or 0 so what I recommend is actually jumping back over to the rock and check because it will say the number of frames that it exported so just use that number and you'll be golden 39 okay then the roughness Min and Max you can set that worth to whatever you want but I want it to be shiny so I'm gonna go between 0 and point 1 and then for Speed we want this to play back at full speed so let's set this to 1 now position map this is the big one we actually need to point this to a position map and everything explodes but we don't care about that because no one's gonna look hit save and you can close down this instance now to check out your handiwork let's drop in the mesh into the level like so get a nice cloud of triangle chaos that's cool and let's plug our instance into the material slot like that and there you go unlimited splashy goodness well at least as long as you're happy with it playing only as a static mesh endlessly looping and without any real control however all of that can be fixed first though there is a small issue that needs to be taken care of if you have a look at this frozen frame you can see that it almost looks like the meshes being shattered and that's because it's not using full precision UVs so let's enable that on the mesh right now so open the mesh up and under log 0? there's a tab called build settings and here you can check the check box that says use full precision UVs hit save close down the mesh yes save it all cool and now the mesh is looking a lot healthier and if caring a vertex animation into unreal was your only goal of today you've just succeeded but we want to do a bit more than that we want to create a particle system that emits these splashes when you hit something with your projectiles so let's start building that particle system and do the material tweaks that are needed for that to actually work so let's right-click and create a new particle system and it's called this something like FX_PAINT_SPLAT open that one up and the first thing we need to do is make sure that our particle system image meshes so let's set the type data to new mesh data and point the mesh to our splat like so and then we need to make sure that we can override the material so check that box and now we have our Chaos mesh again so the required note we can actually assign the material instance like that and while that's thinking let's drop the particle system into the level and remove the static mesh we don't need that anymore just drop that in there and in case you missed it we now have gianormous? particles on our hands that is because the initial size defaults to 25 in the particle system so let's go and reduce that a bit let's set the start size to something same like one so now we should be able to get a better view of what's going on so we have the sequence playing back on our particles but all the particles are playing it back at once and they also don't seem to be moving upwards as our particles did before we assign the mesh instead all of the meshes seem to be centered around the particle in meter and that's not really what we want and that means our meshes are not accepting the particle transforms and not only does that mean that the meshes won't follow the particles go in upwards it also means they won't accept scale over life or random rotations or anything like that so let's have a look at what we can do to fix all of this what it comes down to is that we need to alter the material so let's start out by duplicating the material we created just so we have a backup in case we break everything so it's called this _PARTICLE yes so we know what it is let's open that up and dive in cool so the first thing we want to tackle is the transforms and that can be found over here where the actor position is read in and added to the absolute vertex positions and we remove that and add in a particle position world space instead and all of our transform problems are sorted because now it will read in each individual particles transform instead of just the origin of the whole system without taking care of the next thing to tackle is to make sure that each individual particle can play back the sequence on its own so it's not synced across all particles and all that is taken care of by a bit of math at the very left of the material so by default it's based on time where it reads in time and splits it into individual frame chunks so we can progress one frame at a time this doesn't really help us since we don't want it to be based on time at all instead we want to control it over the particles life and we can do that by reading in a dynamic parameter instead we can actually get rid of this whole first section up to the multiply and just replace all of that with our dynamic parameters since we don't need the time to be a part of this at all so drop that dynamic parameter in and let's give it a cool name something like FLAME_SELECTION doesn't sound like a superhero but it's descriptive let's plug that into the ceiling node like so and now if we animate the frame select from 0 to the last frame of the particle life that will cause our animation to progress the way we expect it to so now we can go ahead and get rid of all this time stuff that we don't need anymore you know organize this up a bit okay so that's taken care of there's one more thing that we should do before we leave the material and that's giving yourselves a bit of control of the color of the particle so instead of the ramp we don't really need all of this stuff let's drop in a particle color node and plug that into base color like so now the material is ready to be used for particles so let's hit apply and have a look at our material instance and all we really need to do here is repoint our parent material to our new fluid particle version and that's it hit save and we're done so looking at the particle system again now we can see that a few things have changed firstly the meshes are now following the particles upwards so that's cool the second thing is that they are not actually animating through the sequence and that's because we haven't yet added the dynamic parameter so let's go ahead and do that right now so right click and go parameters dynamic and as always right-click hit refresh so it reads in the parameter names check the parameters and number zero should be our frame selects and it is so our distribution should be set to be a curve so let's set it to cause the curve and we need to add two points one for start and one for the end of the particle we can leave the starting point at zero zero but the end we need to change so the in value is 1 so the end of the particle life and the out value should be the final frame of our sequence which would be 39 and that's looking all kinds of trippy but it's actually doing what we wanted to it's playing through the sequence over the particle life for each particle but to make this a bit more easy to read what's going on let's add in a bit of random rotation to the system so we're gonna go ahead and right click and on a rotation we said in its mesh rotation and we can leave that at default so that's fine cool so we're actually starting to get somewhere that is starting to look quite interesting we get some cool shapes going on now we can start building up our particle system so let's start by giving it a bit of random size maybe between 0.1 and 0.6 would be enough yeah that's gonna be cool and now it's almost a bit too noisy so you can't even see that it's moving upward so let's just get rid of the velocity for now can add that back in or some gravity later that's all up to how you want the effect to look but what I want from this is to for it to look like a cool paint flat so we need to add some cool color because this is a very boring looking paint so let's head over to color over life and give it something nice and by nice I mean hot pink and for this I'm actually gonna remove one of the points and just have a static color through the whole particle life so let's get that color dialed in yeah there we go next we need to set up the loop since this is gonna be a one-off splat on impacts we don't want it to endlessly loop so let's go up to the required node and set the emitter loops to one so we've only played through once but we wanted to spawn a bit quicker so let's go to this spawn tab and set the constant rate to 0 and instead we use our bursts open that and let's burst five particles and that should be enough and as you can see now we kind of have a problem where the first frame of the sequence seem to be flashing on before the particle dies and that's a bit of a precision problem so we can do to fix that it's just lower the out variable? your dynamic parameter by one frame and that should all be sorted and another cool thing that you can do now that you control in the sequence with a dynamic parameter is that you can give the parameter a bit of a curve so maybe you want the blob to stay blobby for a bit longer and Dan goes super fast through the end of the animation you can totally do that by just adding in more points to the parameter and I encourage you to play around with this parameter because this is where you make the fake look really nice and snappy but for now I'm gonna leave it like this speaking of snappiness this is way too slow so let's have a look at the lifetime one second is way too long for these particles to live so let's reduce that is somewhere between 0.2 and 0.6 now there are a lot more snappy and quick and this you can also tweak depending on if you have gravity on them so you want them to fall but I want the East yes splat quickly and be gone and to that and to make it look a bit more violent and quick I'm gonna add one more emitter and I'm gonna do that by duplicating the one we have so let's just maximize this and right-click immature duplicate and this one I don't need as many up so let's go to the spawn and maybe yes use two three something like that like OB? two and then we're gonna use the initial size to just squish the mesh a bit so it becomes a thin burst of liquid it's a bit of a hack a better way would be to go back to Houdini and actually make a nice streaky fluid simulation and bring that in here like a blood squib or something but I'm gonna go with the squishiness because that's the quickest way of doing it and then I also want to make it a bit faster so I'm gonna reduce the life to 0.3 however really nice and quick bursts of liquid and when you play both emitters we get this nice one-two punch and now the splash is turned to look pretty cool okay it's looking okay let's go with that you should probably spend a bit more time here as tweaking all of your curves and your life times just to make it look snappy and the way you want it but I'm gonna move on and show the next step and that's actually setting up the blueprint to trigger this whenever your projectile hits a surface so if you're using the first-person start account like I am let's go to the first-person BP and then the blueprints folder let's open up the first-person projectile blueprint and in here we're mostly gonna build our own stuff but you can leave the notes there are there in case you want to go back so the first thing we want to do in this blueprint when the projectile hit is detected is to actually spawn an emitter so let's drop in a spawn emitter at location node like so and we want to spawn this on hits so let's bring the output from the event hit to our input we want to specify that we want to spawn our paint splat like so and the location we can get from the get location node that's already in here let's just hijack that plug into the location cool so now it will spawn a particle but the projector will keep on bouncing around and that's not really what we want so what we can do is that we can drop in a stop movement immediately node just to make it just not bounce and stuff so stop movement and grab that and that comes hook it up to the projectile already so that's good and the last thing we need to do right now is destroying the actors so the projectile doesn't stay just frozen and that node is already there so just plug that in and that's the base of our projectile done so we can actually hit compile and go ahead and test this you just hit play and now when we shooter things we get splattiness? so that's pretty cool it's doing what it should but it is showing us a pretty crucial flaw in this whole visual we don't have any decals and that makes it feel kinda lame luckily thanks to some of the new tools in the simpleBaker in Houdini it's real easy to make awesome decal textures so let's jump back to Houdini and make one right now for organisation's sake I've started a new Houdini zine but you could just as well do this in the previous one the first couple of steps are going to be very similar to the preview setup so I'm gonna just rush through them so I'm gonna start by dropping in a sphere and I'm gonna give that a bit of extra geometry and I'm going to started using a mountain sop again the shape of this is going to be very indicative of the eventual splash so you can always come back and tweak the values on the mountain sop so the process we're gonna go through is that we're gonna take this sphere convert that into a flip fluid and throw it on to a ground plane and then we're just gonna take a snapshot of the splash that ends up on the actual ground and bake that out into an alpha texture and the normal texture so to do that we're gonna race this ball up so we can throw it down to the ground we're gonna select the sphere we're gonna go to particle fluids and just like before convert that into a flip fluid then we're also gonna need a ground plane for this to collide with so go to collisions and drop in a ground plane this goes on forever in all directions so we can just leave it there and now we can jump into our dop network and see there it's all hooked up and ready to go we only need to do a couple of things in here the first one is on a fluid object we want to give it some downwards velocity and we do that in the initial data and let's check initialize velocity let's give it maybe -10 to start yes so it looks like it hits the ground with some force and if we play this now it kind of looks interesting but when it hits it looks like it's sliding and going on forever and that's not gonna make an awesome splash for us I mean it doesn't look bad but it could look better and I want this to look a bit goopy and thick so we can do is jump over to the physical tab and here we can give it a bit of bounce and also a bit of friction so it will do more violent bouncing but slow down quicker and that should give us an interesting splash look like that you can keep trying different balance and friction values as well as different velocities and also go back and change the shape of the actual blob that you're throwing down but I think this looks pretty good so let's work with this well let's first do some cleanup get rid of the interior hide visibility on the ground plane because we don't need to see that we're only interested in the fluid so let's jump into the fluid node and again we don't need most of this so let's connect the import to the fluid surface and be sure like that so that's where a splat looks like so that's pretty cool and we can delete the rest of the stuff because we're not gonna use any of that now what we are gonna do now that we have a nice-looking splat is that we're gonna bake this onto a plane and that will give us the textures that we can use as a decal so you can scrub through and find a frame that you think looks cool but still generic enough so it won't look bad when it's repeated a lot and I think this one is gonna work pretty well so before I start baking I'm just gonna go ahead and save the file so I can use the hip variables so let's just call this something descriptive like "Decal Splat Generator" that's cool hit accept okay so start the baking process first we need something to bake too? so let's drop down a grid and let's try and make it match the shape of the splat so we don't waste any space on the texture so maybe just scale it up a little bit so and I'll set it down just try to match it it doesn't have to be perfect next we'll drop in a simpleBaker like so we'll plug a grid into the first input which is the low and the splat as the high on the right so the simple Baker has a few settings but most of them are pretty straightforward so the only things that we are gonna want to bake out is actually the normal map and the opacity so we can untick ambient occlusion and vertex color and tick opacity or the Alpha we're also gonna want to lower our resolution to something like 512 but you're gonna have to base this on how big it's gonna be in game and how large shell text you can afford and that's really all there is to it so we can just go ahead and hit render and it will spit out two textures for us and once that's done you can enable the simpleBaker to see a preview of the result and if you get a mangled result like this you can debug it by jumping over to the material tab and set your diffuse map to display your normals and now you can clearly see that the normals are royally screwed they have a large black patch in the middle that makes nobody happy well that's because the splat was a bit too thick so the race didn't make it all the way through to actually bake the normals down so what we can do to fix that is we can jump over to the Advanced tab go down to Ray bias and increase this value let's say by a factor of 10 and then we can just hit render again and this time they came out looking silky smooth and just the way we want them well almost there are a couple of black spots still and I should probably increase the rate bias a bit more but it's such a small artifact that it's not gonna make a difference so I'm gonna leave it for now other than normals we can preview our alpha is to see how that looks and that looks exactly like the Alpha I would want for this kind of decal with the small caveat that this will only look good when it's static and not gonna be removed if you want to remove it you should probably spend some time in making an erosion map out of this but you can do that with a couple of actions in Photoshop but for a static decal this is perfect and with that done let's jump back over to unreal and as always the first thing to do is to import the textures so find where you save them grab both the Alpha and the normal and drag them into the content browser it's import as a normal map which is exactly what we want okay so now we need to start building a material for our decal so let's create a new material let's call it something like spat decal and let's open that up alright so the first thing we need is both our textures so let's go back to the content browser grab both the alpha and the normal like so and just drag it into the material and it will create a couple of texture samples for us maximize that again and before we plug this in there are a couple of settings we need to change from the root to make this actually behave like a decal so let's select the root and let's change the material domain to deferred decal like so I'm gonna set the blend mode to translucent and finally we're going to set the decal blend mode to D buffer translucent color normal roughness Vil it's the top one with all of the features D buffer decals are a special kind of decal that actually look good compared to the normal ones and to be able to use them you need to check your settings so jump over to your project settings and in here you're gonna search for Dbuffer and make sure that Dbuffer decals is ticked and if it's not ticked tick it and restart the editor right now if for some reason you're not able to use Dbuffer decals you can use the normal decal blend modes but it won't look any good really now back in the material we can start plugging things in so let's start by plugging our alpha into the opacity slot and the normal into the normal we're gonna need a color to match the hot pink of the particle system so let's drop in vector 3 and plug that into the base color and let's set the color of the vector to a nice pink like that that's this stuff and once that builds we can see that we have some kind of a splat going on on our preview sphere it's nice and thick but it's way too rough so let's fix that by dropping in a constant and plugging it into roughness and let's just leave it at 0 so it's nice and shiny and and delicious looking don't eat paint and that's looking nice and shiny and goopy and this is all we need for a material as it's gonna be a static decal so let's hit apply and let's check it out in the level and to do that all we have to do is grab the material and drag it into the level and there we go ah look at that the alpha and the normal map are working really nicely together to actually make this look almost like it has a bit of depth and that's really cool but static decals are boring so let's spawn this one when the projectile hits the surface and to do that we need to jump back into the projectile blueprint we worked in before and do a few tweaks first we need to actually spawn the decal so let's drop in a spawn decal node and there are two of these one just spawn the decal on location and one spawned it attached and I prefer to use the attached one because if you have physics going on in your level you want the decal to actually stay attached to whatever it is it hits so let's drop down a spawn decal attached let's plug that in then let's point it to them are actual decal so splat decal cool then we need a position and we'll give? the same we used for our particle system so let's just go down and find the get actor location node and plug that into location and then we need to change our location type because the default is keep relative offset and that will actually scale the decal based on this size of the object it hits and that can give you some real weird and unpredictable results and it really is enough to keep the position so let's set it to keep world position since decals are actually projected onto this surface they're shown up on you can get a streaky mess if you're seeing it from the wrong angle so to ensure that we see the texture on the object that we hit with our projectile we need to build a rotation and we can do that but grabbing the hit normal from the event and then we feed that into a make rotation from x because that's the axis it projects along so let's drop that down from x feed in the hit normal and that will give us the rotation we need and we can plug that straight into rotation cool next we need to set up our size and this can be whatever you want but I'm gonna make this one fairly large cuz it's large splat so let's set the y and z's to something like a hundred and fifty the x axis is a bit difference is that's the axis it's projecting along so we need this to be a thin sliver to make sure that we don't get a whole bunch of streakiness going on if it's intersection with the wall but we also need to make an adjustment to compensate for the fact that the hit normal is pointing into the wall while the decal needs to be projected in the opposite direction you could flip the hit normal before making the rotation but I find it easier to just give the decal a negative size in X so let's make it -30 and before we can go ahead and test this there's only one more thing to do and that's telling the decal what component to attach to and that's the very strangely named other comp on the event so let's connect those up and now we can hit compile and actually test this so let's hit play and there we go we got decal spawning now there we go it's looking cool however there is a problem if you shoot a bunch of these next to each other we can see that they're all rotated the same and that's not very cool and they're also bit small so let's make them a bit bigger maybe 200 is enough cool so let's add some random rotation and we can do that with an add relative rotation so we can drop that in and it's gonna default to a sphere but we don't care about that so just get rid of that thing go wait and plug in our decal instead we're also gonna plug in our input there we go and now we need to build our another rotator so let's drop in a make rotator like so and we can plug that into the rotation and we're only interested in the x rotation or the role because the other axes are already taken care of so what we need to do is that we need to drop in a random float in range so we can specify our range of how much randomness can we feed into the x and this range should be between 0 and 360 degrees so it can be rotated in any direction and with that plugged in it's all done let's hit compile and play let's see what we've got yo they are now randomly rotated and we can go ahead and paint the whole level don't paint the whole level because that's gonna be "super expensive" if you don't start removing these decals if you want to make a painting game look into render targets but this is gonna work perfectly if you just want a gun that shoots paint every now and then it looks pretty sweet so the next step for this would be to use the lifespan on this spawn decal node to actually drive a fade of these decals so they don't stay around forever and then of course you can start fining and improving the effect and making more decals so you can have some more variation when stuff is happening but I'll leave all that up to you you now have the tools to make something really really cool and I hope that you've learned something and as always thanks for watching
Info
Channel: Ryu Bizen
Views: 8,209
Rating: 4.9741936 out of 5
Keywords: Houdini, UE4, VAT
Id: khCfJdg2pyw
Channel Id: undefined
Length: 47min 20sec (2840 seconds)
Published: Mon Oct 01 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.