Unity Shader Graph Tutorial: Creating a Horror Glitch Effect

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
foreign on creating a horror screen glitch effect using the full screen Shader graph new feature in unity 2022.2 in this tutorial we will be showing you how to use the full screen Shader graph to create a screen glitch effect that will add a creepy and unsettling element to your horror game or video so let's get started [Music] merry Christmas and happy new year for everyone on Unity as a store there is a great deal for the new year sales where you can get up to 50 percent discount for most of the assets additionally if you buy assets for more than 300 dollars you get additional discount at 20 for entering the coupon code hello 2023 I place the link for this sale down in the description in addition to many other free assets for you make sure that you create a new project using Unity 2022.2 because this is a new feature presented by unity in that version so we can start by creating a 3D sample scene urp so you will use that template and let's name the project screen glitch effect to be able to add full screen effects to the urp we need to go first to the project settings then go to Graphics double click on the current scriptable render pipeline settings then select the current renderer data and down we need to add a new renderer feature which is the full screen pass renderer feature we keep all the settings the same except the pass index we change it from procedural to blit because that will allow us to gain access to the full screen in Shadow graph so immediately after you added the full screen pass renderer you'll notice that something changed on your scene and it become something white or maybe negative colors and you can see there is a pass material and this material we will change it to animate other materials to control the full screen effect so let's create a new Shader graph and which is full screen Shader graph let's name it screen glitch Shader then let's create a new material and name it screen matte to hold our Shader graph now all the things that left is to replace the material we created with the pass material and immediately you'll you will see a gray screen so let's go to the Shader graph and do some tests to make sure that we have control of the screen effects the magical trick here is only one node we will use the urp screen node to get what the screen holds currently so create a new urp sample buffer node and set the source buffer to delete source then simply now we can do any Shader we want to apply it to the screen and so for testing purposes let's create a test color then multiply it with the current frame in the scene and see how we can change the color of whatever is showing on the screen multiply both the color and urp sample buffer save and go back to the scene on white we have the normal colors we can change all the colors of the objects on the screen to any other color and as you can see now we have full control of what's appearing on screen and we are applying a full screen effects so let's start by creating the glitch horror effect okay let's go back to Shader graph and delete all the current nodes the screen glitch effect consists of three parts first part is the noise second part is the flickering and the third is the scan lines so we will start by creating the noise on the screen we can start by adding a UV node then we split it to gain access to the y-axis to do a noise on the y-axis only that's how usually the glitch is chose in horror movies or video games then we create a gradient noise node and we link the UV to it to distribute the noise on the y-axis only we can add a float here to control the noise amount and we can set it as a default value for 50 and we can see now a nice lines representing the noise on the y-axis next we want to move this noise so of course we will need a Time node and to control the speed or the threads of the glitch we can create a new float and name it glitch strains multiply the time with glitch strands then add it to the splitted value of the y-axis then connected to the UV to to get this nice movement of the noise lines currently the noise is not strong enough and as you can see there is no black lines they are mostly a dark gray but we want a stronger level of the noise so we can use the remap node to strengthen the noise as following so create a remap node then connect the output of the gradient noise to the input of it change the in min max to 0 on X one on Y and out min max to x minus 1 and y 1. and now you can see there is a great contrast between the black and white lines and this is what we need exactly let's group everything in one group and let's name it noise to keep things arranged and organized now let's create the flickering effect by starting from the gradient noise node then we need of course again time to control the glitch strands so we multiply the time node with the glitch strands again and we connect it to the UV on the gradient noise node and to strengthen the flickering effect we multiply the gradient noise with itself twice so we use a multiply node one time and a second time then thirdly to make the black areas more Vivid we multiply again with deer 0.1 let's group all the new nodes in a flickering group then we need to add the flickering to the noise so we use a multiply node to multiply the results of the noise with the result of the flickering to get this nice glitchy effect now we need to apply this glitch effect to the screen by offsetting the white lines and keeping the black lines so we create a vector 2 to only affect the x-axis and we link it to a tiling and offset node on the offset of the tiling and offset node and finally we create a urp sample buffer node to get the current frame from the screen and we change the source buffer to blit and we connect the results to the color save and go back to the scene and now you can see this awesome glitch effect started working perfectly and of course we can adjust the noise amount and the glitch strands from the material and see the results immediately on the scene let's go back to the shadow graph and group the last nodes into applying the glitch to the screen group and as an extra step we can add scan lines to make this effect looks more creepy and also more eye-catchy to create the scan lines without texture we can start by assign node then we use a tiling and offset node and we split it to the to gain access to the y-axis to create a sine or lines on the y-axis by increasing the tiling only on the y-axis to 600 value then to move the scan lines we can borrow the multiply of the time by the Glitch strands by using an add node so we connect the results of the multiply using an add note then we connect it to the sign and we can now see the scan Lines Moving upward to gain control over the visibility of the scan lines we use a clamp node and we create also a vector 1 scan lines strands then we connect the skyline strands to the minimum value in the clamp that will makes all the points or vertices in that node to be white which eliminates the scale lines so we can control the visibility or the trends of the scan lines using this float see the results of the scan line you can use a multiply node to multiply the skull lines with the urp screen buffer and connect it to the color and now you can see the scale lines but they are very sharp that uh annoying or covering the screen in a bad way so to medicate the black lines we can use the following we can mitigate the effect of the black lines by using a remap node and to changing the out min max which control the black lines and setting the minimum value to 0.2 that will create a nice scan lines without damaging the scene behind it and now as you can see we can get soft skull lines and not sharp ones while keeping the scene very viewable and Vivid behind now we can group all the nodes responsible for the scan lines in a group then we connect the results of the glitch back to the urp buffer and we can have now the final effect visible and of course we can control everything instantly from the material properties that we created so we can change the noise and the glitch strands we can also change the scan line visibility and we can make all those parameters as sliders to ease controlling them so for example we can set the noise amount to be a slider between 1 and 100 also for the glitch strands that will make all the parameters can be changed easily using sliders and that will help us later to control them by code or even when we create an animation for them now let's create a controller for those values by creating a new script and let's name it glitch controller of course we need a reference to our material so we create a public material and name it matte then we need three floats to control the floats on the material the first float is for the noise amount the second for glitch strands and the third one for scan lines strands then in the update function we set those floats to the floats in the material in the Shader graph and for of course to do that we need the accurate reference names from the shadow graph so for example for setting the noise amount we write material both set float and we type the reference name exactly as we set it from the Shader graph then we assign it assigned to it the noise amount from the inspector and we do the same for all other floats so we sit the value for the glitch strands and also for the scan line strengths save the script and go back to the scene and now we need to assign the material into the inspector now you can create an animation to control those values so we go to window and open the animation tab then we create a new animation and let's name it glitch effect now we can hit record and adjust the values over time so we can move the timeline into 20 milliseconds then adjust the values for the noise amount to 100 the glitch trans to 100 while for the skull line strands we should start by the value 1 which make them invisible then change it to 0 to make them visible at the middle of the timeline then finally we copy the first frames maybe to one second to repeat the loop of the animation I use the same technique for creating the scene that I showed at the beginning of the video but instead of using the animator I use cinemachine and the timeline there to create the cutscene of course I use some free assets from Unity asset store and I used some free audio effects sound effects I'll provide the links for all of those down in the description and if you want to learn how to create a cutscene I already created a video about that I'll provide the link for the tutorial down in the description and that's it for today's video if you are enjoying watching this video please be sure to give it a like and consider subscribing to my channel for more content like this I also wanted to take a moment to thank all of my patreon supporters who keep this channel going on if you are a pattern supporter be sure to check out the project files that you can download as a part of your support till next video see you soon thank you foreign
Info
Channel: Binary Lunar
Views: 14,134
Rating: undefined out of 5
Keywords: BinaryLunar, Shader Graph Unity Tutorial, Glitch Effect, Full Screen Glitch Effect, Noise Effect, Flickering Effect, Scanlines Effect, Horror Game Effect, Horror Game Shader Graph, Unity 2022.2 Tutorial, Unity URP 2022.2, Unity Shader Graph Tutorial, Creating a Horror Glitch Effect, Creepy Effect, Full Screen Shader Graph, Full Screen Render Feature, Step by step tutorial, easy unity tutorial 2022, new year sales, unity assets store, Screen Glitch Shader Graph
Id: VgBv6OrYY7E
Channel Id: undefined
Length: 16min 0sec (960 seconds)
Published: Tue Dec 27 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.