Unity VFX & Shader Graph - Black Hole Effect Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey what's up guys welcome back to the real lab rat and today we are going to see something super cool my opinion which is out to create this black hole as you can see it has some distortion going on which is done in shadowgraph and it's basically a heat distortion shader which adds a really nice touch and then we got some spirals and some particles made with VFX graph as usual disease develop my patreon page in case you're interested I left a link in the description so without being said let's see how we can do this so first let's make sure that we go to package manager and that we have installed this Val FX graph and share the graph as well from there we can go ahead and create an unlit graph this is going to be our heat distortion shader and once you open it up you want to make sure that this one as the surface set to transparent you can also turn on two side okay so let me just duck these right here so we can have a better perception of how the heat starting works right so let's start with the note call it's in color and this gives us access to the cameras color buffer if you want to learn more I left a link in description to the documentation and once we connect these to the color input if we save these if we create the material out of this shader and then create for example a plane and assigned the respective material they will notice that it seems like it's transparent but in fact it isn't it is simply showing the current cameras color buffer and since we can assign it a UV theoretically speaking if we distort that UV we get a distortion so let's add a UV node and then a noise like a simple noise and we want to add them together and then assign two distinct color once we save this we get this totally distorted plane right now one way to control these desertion is with a power node if we increase this B value we get less Distortion but if you look closely you will notice that the image that we are getting is flippered that's because this is mapping what our camera is seeing to the UV of this plane but what we want instead is to pass the screen position and as you can see now we have the correctly map at Distortion now to control these distortion amount we are going to need a remap and we are going to remap one one is going to be our in value and we are going to create a vector two and we are going to connect to the in minimum and maximum the X is going to be 0 but Y is going to be controlled by a vector one call it distortion amount and once we save this as you can see zero is no distortion but if we start increasing the distortion amount we get what is expected which is a nice heat distortion really cool but we need to limit this so let's set the distortion amount to a slider all right so at this point we have these art edges the easiest way to fix them is by adding a text to D our main texture push it up here and for example whatever is black in this texture will have no distortion I'm going to use this texture but you can use the default particle it will work too but the area of distortion is very small and this texture is going to be multiplied with the simple noise just like these and connected to the Power Save it and now in my material if I assign again the texture as you can see we only have distortion exactly on the white area and everything between white and black is faded and we don't see any art edge great but we still need a few more things for example we can add a distortion scale to control the scale of the simple noise but what we really need is a twirl motion so let's say that well note that is going to be connected to our simple noise and as you can see the starts the simple noise juvies and it creates this nice spiral this nice twirl and we are going to need a vector one for the rotation amount another vector one for the barrel strengths the rotation amount is going to be multiplied with the time and if you press spacebar we can search for a rotate node connected to the twirl and then connect the rotation amount multiply it by the time to the rotation of the rotate a lot of rotation going on marais we got these rotating and if we save it now maybe increase the trolls trend we get this really nice distortion going on I mean look at this it's really cool all right so we have the distortion done now before we move on let's add the empty in our scene we set its transform tyrant the plane with the transform also reset it so we can then add a sphere right and for this fear we need a new shader a new unlit graph for the Fresno it's going to be super simple to shader we can add a Fresno and then a vector one for Fresnel power and then we can add a collar for the Fresnel collar with the mode set to HDR and then we can multiply the collar with the Fresnel effect and connect this to the caller input and that's it that's basically it now let's create a material out of this shader assign that material to the sphere and I'm gonna set the Fresnel power to three and then the Fresnel color to a purple similar to this one and increase the intensity so basically this is going to be the center of our black hole right something like this should be fine for now okay so for this world we actually need Photoshop or or Crete a file like this one with 2048 by 2048 select the brush tool with whiteford color and create a new layer with control-shift-n and then with the brush more or less of this size and while holding shift I'm going to create a line like this duplicate this layer rotated 90 degrees merge the two layers with ctrl e select background with shift and press V so we can have these aligned options up here right and then the idea now is to go to the filter in D start we want to use the twirl modifier and we can use an angle of around 250 and 300 that should be fine and here we go we have a nice spiral now what I'm going to do is erase a little bit these pointy ends and make them thinner towards the end as you can see so we have a nice-looking spiral right once this is done I'm going to save directly this Photoshop file to my unity project and then back to unity I'm going to create a material rename it swirl and in Shaler we can assign in the universal ran a pipeline in particles the unlit version right and the surface is going to be transparent the blending mode is going to be additive render face we want to see this from both sides and then we want to assign in our base map this world we just created and for this one I'm actually going to use the particle system because it's much quicker to work with and because it's just a few particles right so the start lifetime of this particle is going to be big like 15 and 20 and we don't want any start speed we don't want these to move so let's set that to zero and let's assign the material we just created by the way set these two local the Renault alignment of shape by the way start size in my case it's going to be around three and nine I'm gonna create these gradients by the way for the color lifetime and select two colors for the start color a violet and a purple something like these and I know this is really bright but all we gonna do is go to the mission and set this to around one or two that should be fine then we can set the start rotation to be random between these values we want these to shrink so let's use the size of a lifetime it goes from big to small just like this and the only thing we need to do is rotate - 90 degrees in the X and that's--it's looking nice let's just turn on rotation of a lifetime and insert these values minus 10 and minus 30 so it follows along with the heat distortion shader you know and by the way these are my values for the heat distortion in case you are wondering I'm using rotation amount minus one so it goes in the opposite direction and it gives this nice absorbing sensation you know that nice motion that is being absorbed but we can also do with the sphere is increase the intensity of the Fresnel color and maybe make it smaller just like these that should be enough and as you can see we have a really beautiful black hole very customized obviously probably black holes don't look like these who knows we just have a pixelated image for now but hey at least we can dream about it and make something as cool as these right now for the last part let's add some particles with VFX graph something simple and quick so let's create with right click a visual FX graph I can drop it to my black hole prefab just like these in the middle and then press edit to open this vido duck it here make some room and the first thing we want to do is increase the capacity can also increase a little bit the rate just like these now we can go down here and select the default particle or another particle that you have around set these two additive and let's control the size with a set size which is going to be random uniform by the way around 0.01 and 0.02 and nothing changes because the size of a lifetime is over writing any previous value so I'd set that to multiply and select this curve we want to go from big to small and the particles are really tiny so let's set the size to 0.1 and 0.2 actually now we want these particles to start in a sphere position so let's add the sphere with the radius of 2.2 now these particles we want them to go inwards to go to the center of our black hole like if they are being absorbent for that we can go to update particle and use the conform to sphere as you can see the radius of the sphere is all bit too big so let's decrease it to around 0.3 0.2 0.4 something around those values now the attraction speed and attraction force are too high as you can see it's pulling the particles in words really fast so it's decrease the traction speed to 1 and the traction force to 5 we actually want to use a random attraction speed so they don't all have the same attraction right so let's create a random number between zero one for now and connect it to the traction speed alright so as you may notice the particles are still in a sphere shape and we actually don't want that we want to flatten that sphere in the Y so we want to set position and the particles lose their previous position so let's make sure that we feed them their previous position we'd get attribute position the current location but since we want to change the Y we want to flatten sphere we can create a vector tree connect the X and z respectively and now if you connect this vector tree to the set position all of the particles have the same y value in the position which is zero right so if we feed a random number between something like minus 0 1 and 0 1 we are increasing that Y value maybe something like minus 0.2 and as you can see now the sphere is not flat it's not a circle but it has some volume now to add a spiral motion to these particles we need to once again set position but before all of this before to conform to sphere and before the set position we have used it right now we want to use their rotate 3d and the rotation axis is already set to Y which is what we want actually but the position of this rotate must be the previous position of the particle because we don't want to erase the previous position of the particle right so we want once again to get at reboot position for the angle we can use a random number and that's it we only need to connect the rotate Creedy and yet the rotation is really strong so I'm going to decrease it to something like between 0 and 0.01 maybe even less it adds a really nice motion and I think the particles I still a little bit too big so I'm going to decrease them to around 0.01 and 0.1 yeah that seems better and the traction speed is also big maybe zero that tree looks better definitely okay so that's looking really cute we have a nice black hole the distortion shader really adds a lot to the visible aspect of this black hole we made a few variations that are exclusive to my patreon page in case you ain't dressed to have access to them I left a link in description there's also a lot of visual effects that you can use in your projects in your games so yeah that's basically it make sure to check it out I wanna say thank you to all my patrons that have been supporting me you guys are awesome you know spark really means a lot and a special shout-out goes to the super mega patrons which are Alejandro Angel our dev show James a mantis goblin black hero syndrome the game Himura is PC Josh Mac karmic ramen yalla can leave marco rossi nicholas loves psycho tech studios robin boudreau silver who my Steven Melton TK zarf so that's it guys thanks for watching I hope you have enjoyed this video and I really hope to see you in the next one [Music]
Info
Channel: Gabriel Aguiar Prod.
Views: 101,278
Rating: undefined out of 5
Keywords: Unity tutorial, unity effects, game effect tutorial, unity magic effects, unity particle effects, unity particle tutorial, unity game effect, unity vfx, unity vfx graph, vfx graph, vfx, tutorial, unity gpu particles, unity gpu, unity vfx graph tutorial, unity particles, graph, unity, particles, unity graph, shader graph, unity black hole, black hole, unity heat distortion, unity shader, shader, black, hole, heat, unity shader graph, space, galaxy, supernova, cosmos, distortion, fresnel
Id: FlE8e1JwVzs
Channel Id: undefined
Length: 17min 25sec (1045 seconds)
Published: Tue Jun 16 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.