Unity VFX Graph - Disintegrate and Dissolve Effect Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
today we are going to see how to create a disintegrated effect [Music] [Music] hi I'm Gabriel aguer currently developing rabbit's tail links below for more and I'm gonna show you this effect that can be used for an animated character or a static object which is commonly used when an enemy dies for example like in Demon Souls which by the way I once recreated similar effect but today I'm going to show you a more efficient methods so let's jump right into this and if you want to get this project it's all available on my patrons page as well as many many other assets that you can use for your games oh by the way shout out to UT for sponsoring this video they have an amazing sale going on in the unity asset store and it's a great time to finally get that asset you are looking for or that you didn't know about like for example Phil amplify bundle RPG Builder and my megapacts that have so many effects included and many more assets make sure to use the link below plus if you spend over 100 and use this code you get an additional 10 percent so as you can see in this case I'm using a character which is from mixam by the way you can pick up any character from this list and any animation yeah for this effect to work it doesn't necessarily need to be a character but for any object you use you need to turn on read or write on the model import settings otherwise VFX graph won't be able to spawn particles on the object right so I'm going to start by creating an empty game object rename it reset transform and drag and drop the character I'm going to use parent it exactly and well let's start with the dissolve Shader we are going to recreate basically what you are seeing here the default material from Unity a fraction of it actually which is the PBR settings the way directly in a folder we can start with the unlit telegraph or with a blank to the graph we can go ahead and create the material out of the Shader we created so you can see this in action directly in the object or in the character in my case I'm going to create two materials because this skin and mesh renderer as you can see it has two elements in the materials for two different textures in case your object doesn't use animation it will be a mesh renderer by the way and I'm going to replace the existing materials of this monster model it becomes pink that's because we don't have any Target I'm gonna say it's for Universal because I'm using urp and I'm gonna turn on allow material override so you can have control over all of these options directly in the inspector and that's pretty much it if we save it it should become gray the default color so like I was saying we need to recreate the default material from Unity basically the PBR settings and I'm only going to show you the main features of a PBR material like the Albedo and normals map so for the albed we are going to need the color the base color and a text to d4d Albedo text I'm gonna assign the default text that comes with this character and I'm going to sample the Albedo and then we can multiply the base color let me just say it's white color increase the alpha to 100 and set the mode to HDR just in case and then multiply these two together and we have the base column but if we save this yeah it becomes fully white because of the color but if you go to your model and assign the respective textures to respective Albedo textures you will get this that's the first step the Albedo Next Step is fairly simple you can also create texts for the metallic or smoothness properties I'm only going to create floats for the metallic and smoothness I'm going to say they are a slider metallic I'm going to leave it at zero for the default value add the smoothness I'm gonna leave it at 0.5 for the default value I'm going to connect them respectively and that's each for and that's it for these two last one is the normals texture the last one is the normals map I'm going to create a new text 2D and once we sample this if we assign the normal map texter to the normals as you can see it becomes orange that's because we need to say the type is normal and that's it one last thing you can do is connect this to a normal strand node to control well the strength of the normal maps you can also create a float for this I'm going to leave it at default value of 0.5 and then connect this to the normal input of the fragment function and that's it you have the base of a PBR material a very basic setup but it is a very important step for us now to create the dissolving effects you can create a group for this by the way right so the dissolving effect let me just fix here normal maps to sign them to the materials that I'm using for this character all right becomes it becomes really great look at this just with four properties Albedo smoothness metallic and normals for the dissolve we are going to use a procedural noise you can also use a texture for this a nice texture I'm going to use the simple noise and the first property I'm going to create is the dissolved scale so I can connect it down here and say the default value is 40. if we connect this directly to the alpha we have already the dissolve effect going on if I turn on the main preview and play with the alpha clip nothing happens just because we need to turn on Alpha clipping we need to enable it basically right here as soon as we do it as you can see in the main preview we are indeed eroding or dissolving the object so that's pretty much it now all you got to do is create a fault property for well to dissolve amount which is going to be a slider between 0 and 1 and it's going to connect to the alpha clip threshold with the default value of 0.33 but as you can see in the main preview we don't have any glow any outline for the dissolve we can control that by connecting the simple noise to a step node which will basically start clipping some values and if you connect this over mount to the in value nothing will change but if we add a very small value to the dissolve amount and replace this connection to the end of the step and then connect this to the emission as you can see we have now a white glow a white outline for dissolve only because we have added a small value down here which means that this will control the dissolved White so let's create a float for that with a default value of 0.02 for example all there is left to do now is add some color so let's create a property color property for this of color I'm going to pick a blue something like this and increase the intensity as well and finally we need to multiply this with the step node and replace this to the emission and that's pretty much it we have now a dissolved Shader if we save this as you can see in my character we don't have any transparency mostly because in the two materials that I'm using Alpha clipping is disabled so I'm going to enabled and as soon as I do it here we go looking very nice we have this dissolved amount the sliders that control the dissolve but for this to work out properly we are going now to need some code very simple basic code to control the dissolve amount property of the Shader so let's create a c-sharp script dissolving controller for example and add it to the empty the parent of the character I'm going to open this up and first thing we need is a variable public variable for the skinned mesh renderer so we can get the materials from the skin and mesh then we need a private material array to store those materials from the skin and mesh and on the start function we can say that if skin and mesh is different than null then the skin and materials array is going to be equal to the skin and mesh dot materials and in the update function now we can say that every time we press spacebar we are going to start the core routine we can call it the dissolve Co which we are going to declare down here and it's going to be an i numerator let's check if the skin and materials as any material first if the length is bigger than zero and while the skidded materials the first material for example we can get the float which is dissolving mod I'm going to talk about it in a moment while it is less than one we are going to increase and not decrease we are going to increase this all amount the name for the get float is the reference not the name itself of the property it's the reference of the property you can copy this if it doesn't have any name you can rename it to the reference just make sure that in the get float it's the same name the same string now up here we need a counter a float that's going to start at 0 and we are going to increment this counter with a dissolved rate that we are going to declare in a moment and now for every material in the skinned materials array for every material we are going to set float the dissolve amount float exact same name it's going to be equal to the counter like this and down here now we wait a little bit so we are going to use the yield return that's why we are using a carotene new wait for seconds we are going to wait for the refresh rate that we can declare appear let's copy the dissolve rate create a public plot for the solve rate default value of 0.0125 and the public float for the refresh rate which can be double of the dissolve rate 0.025 and that's pretty much it if you save these now and go to the character assigned the skillet mesh remember if you are using a static object it's going to be a mesh render and not skinned mesh once we have assigned the skin and mesh you can press play now make sure the solar Mount starts at zero by the way of the materials and every time you press spacebar here we go it dissolves away I'm using blue you can use red whatever color you feel like right awesome so that's a big step then our next step now is to add some particles to these and we are going to use VFX graph we want particles to come out of the character so create a visual effect graph rename it and parent this to the empty as you can see it should be below the character I'm going to press the edit button to open this up and we don't want this to emit particles forever right we want to control the duration that it emits particles so we can select the spawn block up here and say the loop duration is going to be constant as well as the loop count we want this to Loop one time and the duration can be a float with a default value of 1.5 for example and now it emits particles for a second and an F which is nice let's increase the particle count by setting the constant spawn rate to 2000 for example if we increase the rate well we need to increase the capacity of this system bounds can be manual and we are going to use this velocity a value that I like to use is one five one and then minus one two and minus 1. so it goes mostly up and a little bit to the sides that's for the motion of the particles down here we have the lifetime the duration of each particle it's way too much so let's decrease it to be between 0.2 and 1.2 but we want this to spawn on the surface of this monster of this character so we are going to need the skid and mesh position block remember if it's a static object you can use the mesh position block that's enough we need to feed the skin and mesh these skinned mesh so let's create a property for that the skin and mesh renderer connect it down here and now we can choose the placement if it's vertex Edge or Surface I'm gonna go with surface and then we still need to tell it the transform of this object to scale the rotation and the position so we can use a set position block and to these we are going to feed literally a transform block but first we need to tell it the current position of each particle so it doesn't get lost that position we are going to connect this to a transform position exactly and in order for this to know the scale the rotation and position of the character we need to transform property connect it right here and connect this to the set position if we save this as you can see we can feed the skin and mesh render drag and drop it but for the transform it's not that simple we are not going to input direct values from the character fortunately we have a VFX property binder a script that comes with VFX graph we are going to use in a moment for now let's control the size of this particles because we cannot see if they are spawning on the character let's use the set size before the set size of our life make sure it's random between something like 0.005 and 0.03 for example but now the set size of our life we need to say it's multiply and the curve is going to go from Big to small and that's it much better so like I was saying the transform we are not going to input direct values we are going to use a VFX property binder script that basically it asks for the property that we want to bind it's basically a transform literally the name of the property is also a transform you can copy from here Ctrl C Ctrl V add a Target in this case are the bones the root mixed ammo exports always the hips as the root so let's use that and here we go it's spawning with the right scale and in the right position and with the right rotation in relation to the character awesome now it's only a matter of making this beautiful so I'm going to give you a few tips but that's essentially the effect if you want to know more about character effects I have a tutorial about it by the way and if you want to know more about VFX graph we'll then check my channel so let's say that the color of a life is going to be in multiply the composition the alpha composition so we can fade out the particles let's remove this key exactly and now we can use a set color which we want to control in this Vector so I'm going to create a color property I'm going to set it to red but it should be blue anyway I'm also going to increase the intensity what I want to show you is how to trigger this via the script it's actually fairly simple let's go ahead here and import a library using Unity ngine.vfx so you can use VFX graph and we want the public visual effect property let's call it VFX graph for example and in the correcting in the numerator before checking if the skin and materials array as anything we can say if VFX graph is different than all then VFX graph.play and if we test this out now as you can see every time I press spacebar this character disintegrates himself cool right let's do the final adjustments for example let's switch this texture to the default particle that comes with unity or any other text that you have around that's better they become a bit smaller another thing you can do is select everything Ctrl C Ctrl V to duplicate this and let's create some dark particles they can rise up slower and move a little bit less maybe leave a little bit less as well the rate could be lower as well and down here we are going to multiply their size 10 times for example and the call is going to be black it's very important in the color of a lifetime that this Alpha key becomes super low like 40 for example I'm going to rename this to dark and the other one too bright because we want to say in the VFX graph in the inspector that dark is rendered before bright and as you can see it adds like a burning effect a burning touch if this was red it would look awesome I choose blue but I think you get the idea I highly recommend you to check out my other tutorials especially these ones because you will learn about particles and how to add other effects for this but yeah that's essentially it guys I hope you have enjoyed this if you want you can add a delay before the effect starts just synchronize with the dissolve Shader for example it's all in the spawn module choose before Loop and that's it [Music] and then triggered the animator to play the die animation and that's pretty much it and that's how I got here by the way you can as well add the turbulence in the update particle for an extra spicy touch so that's it guys if you want to support me that would be awesome you can get your hands on this project and many many other assets they are all available on my patrons page you guys will get plenty of stuff and you keep the channel alive I want to say thank you to each Patron that supported me last month and a special shout out to the top type patrons which are 3D sorcery al-shank kravai operation analog up Studios Achilles Benitez Studio cyber cradle Daniel Schmidt Dave game development Diego effect yellow El Sharif Jill's Walter Goblin plague guillerm trinda GMP Casey Miller Cannon and cell lucky Campbell Lee and ALT Mark Anum matersburg against Michael again Michael laid minazuki Mir mouth MOA mortar Naru natsims ngy or it's original game Chief pradeep Sano radioactive bullfrog ratchanan Revenant games very suit Will Hughes will boiling Champion Ling and in good that's you guys are amazing amazing thank you all for your amazing support it keeps the channel going it's very much appreciated I hope everyone has enjoyed this video and I truly hope to see you in the next one so thanks for watching and bye
Info
Channel: Gabriel Aguiar Prod.
Views: 46,658
Rating: undefined out of 5
Keywords: Unity tutorial, vfx, vfx graph, vfx graph tutorial, unity, visual effect graph, unity visual effect graph, unity vfx graph, unity visual effect, tutorial, shader, shader graph, unity shader graph, unity shader, fx, graph, visual effect graph unity, unity tutorial, unity effect, unity vfx tutorial, unity visual effects, visual effect graph tutorial, shader graph tutorial, disintegrate, dissolve, dissolve tutorial, disintegrate tutorial, unity enemy, unity kill enemy, dissolve enemy
Id: we406Hc_WrM
Channel Id: undefined
Length: 20min 44sec (1244 seconds)
Published: Tue Nov 29 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.