Unity Shader Graph completely explained!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

Thank you for this. If anyone knows, it would be nice to know how each node affects performance.

👍︎︎ 1 👤︎︎ u/GreaseMacaque 📅︎︎ Aug 14 2019 🗫︎ replies
Captions
welcome to all nodes explained in unity shadow graph in this video I will introduce you to all the nodes and will give some examples you can find all the time codes in the top comment I will go top-down from the create note menu and our explain everything let's start with artistic adjustments in the channel mixer you can mix color channels if you input is a color or a texture often connect that with the contrast node you can set the contrast of texture in the hue node you can set the hue make sure that your range is normalized then it will work better in the invert colors node you can invert some colors you just check them here in the replace color node you can input texture you say which color you want to replace for example Queen and which colour should be the result in this case wet you can set the range for example here a good range a little bit of fuzziness so that's the replacement is a little bit more subtle and this is how you go in the saturation node you just set the saturation of your image for example if you want a leg and white texture or material just type in 0 in the white balance note you can set just set white balance for example the temperature if you want to have a hot material say 1 otherwise 0 and tint you can really tint this next up is a artistic blend node here you can blend between two different inputs for example this image and this image Z was this image one is the other one and the blend mode is not that you have the other one and here you can really specify how you want to blend if you know Photoshop already you see that these are very similar options you have in the layers for example you can set hard light and then you can slowly blend in the other image so for example over white should really override the image completely artistic dither just adds dessert to your image with artistic masks you can create masks for example a mask for green just let the green check box only checkbox and then you have a green mask or you can have a color mask if you for example want to mask every green pixel in your image just choose screen I don't have the exact pixel color like this one so I can set to arrange a little bit higher and you see you have masks which you can use for your further workflow you can set the fuzziness to have some gradients from one color to the other artistic normal is all about normal Maps I have two more normal maps here a brick wall and this ya primitives normal map and you can blend them together with normal blend then both are applied at the same time you can create normal maps by using their node normal form height I put in this image valo night diagram it will generate a normal map for you form this black and white image you can create a normal map form a texture I use this texture this is an output now i have a normal map if you that value in your normal map is wrong somehow you can put in x and y values that one will be calculated I don't know in which cases this could be useful so just because I explain every node and I think this is the most useless note because I don't know where you can use it it's in here so let's go on normal strings can be used to strengthen up your normal map or reading it for example if you type in 0 is a string since 0 and you can go slowly up to 1 where your normal map is as it is in the input or use doing it even more normal unpack is pretty useless note and it's also written and unity documentary that this shouldn't be used anymore or it's not necessary to use them it's just if you have a texture and you have type the type II fault you can unpack it to make it a normal otherwise you could just say ok I imported it directly as a normal map then you do not need this if you do this twice weird things can happen so make sure that your setup is always correct in artistic utility you can do a color space conversion this is extremely helpful if you split you color for example all the black parts here are all the white parts here are red all the green parts are right here and all the blue parts are right here if you have for example a white ball this means you have forward full green for blue and this is in without a white color but sometimes you want to for example have the hue saturation and the value and then you for example get out here a black and white image this can be helpful in some rough flows so channel nodes are all about splitting values accessing values and merge them together for example the split and combined nodes iron here is the split just takes any vector for example here or vector for it does not need need to be a sample texture or texture in general it can also be a position it's bit obsessed texture and you see here everything that is thought in the texture and you can combine it back together so in this way you can access single attributes with the flip node you can flip some colors if you want and with a through the node you can change the order of the vector for example you get in RGB offer you can set okay red is wet now green is now green and blue is alpha and alpha is blue and then you switch those two if you use this little node just connect your texture in here say if your asset closed your asset and open it again because it's some kind of buggy let's continue and go to the input nodes the boolean is just a boolean you can use branch to just differentiate between two different inputs for example one and zero if the boolean is checked so without this too and otherwise it's fault and this is the output the color is self-explanatory it's just the color the constant is a constant here are five constants that you can use for example pi the integer is the integer it's there because you can input a vector one and then define it as a slider or integer let's the reason why the slider is also there an integer a slider and the vector one is basically it's the same the output is just a vector one the time now it just gives you some access to the time the time is the time since start the sine time is just the time and it's applied to sign the same goes for cosine Delta time is the Delta between a two different frames and this moves Delta is a time between do two different frames but if you do not have a very stable frame rate the smooth Delta is a little bit smoother vector 1 2 3 & 4 should be clear you can direct type the numbers in input geometry gives you some access to the geometry for example Zepeda chen director or the normal vector of your vertex or the position of your vertex these values directly come out of the file you were importing from the mesh the screen position is position of the vertex on the screen the tangent vector is the vector of the tank and the UV is a UV from the input mesh the vertex color is a default color defined in your mesh the view direction is the direction of the camera let's go to gradients so there are two different nodes and normally you connect them together you have a gradient out and there's only one node where the gradient can go in a sample gradient and this is act x value you can iterate through it for example here black blue and white zero is black zero point five it's blue and one is white and you can smoothly other way through it with input lighting you have access to all the lighting settings you have set up in your unity lighting tab for example a color of sky ecuador groans these are the ambient settings everything you have baked into the global illumination or the reflection probe in input matrix you can create matrices for example two point two three point four point four you can use them to create determinants or just multiply them with vectors and you get a vector out which you can use for colors or something like that the transformation matrix is a matrix generated from the Model View the projection or something like that dialectic specular are some materials that are predefined for example rusted metal water ice glass or custom or metal reflectance are metals that are predefined you can have a look at help just place a mouse cursor over the note white click open documentation it says how you can use it for example you need in the PBR master the workflow for metallic and then you can set the italic reflect reflect attends to the albedo input scene you have access to the camera position the camera Direction autographic and so on the width of the camera the height of the camera the values of the fork you have setup in the unity editor the object itself so this position differs from the position the main difference is that this is the origin position of the object and this position of the position of the vertex is just being processed by as a GPU right now the scene color is a color you set up in the unity editor egg is the same as the scene Def's you set it up and you can exit it here the screen width and height is also accessible the input texture nodes are always coming in a pair for example the cube map has a cube map asset and sampler cube map and you have to connect them the same goes for the texture to the asset and the sample texture 2d you always have to connect them because you can only plug in those RGB are outputs into the PVR master the texture to the array asset is basically the same as a texture to be a said the fact that you have another input node helps you just accessing one element of the array the same goes for the speedy acid it's just a speedy texture the sampler state helps you importing your texture these are also in the important settings but you can override them here so here I have an example texture a little bit tiled and offset and for example if I use a three linear filter I guess you won't see it because it's small here but it gets blurred out on the edges II I can choose the web mode as well for example if I say me well this whole texture will be mirrored OSI clamps and only one textures applied and the edges all stretched out the Texel size gives you both the possibility to access a resolution for example the width and the height of the input image and that's all we got for input let's go to master master gives you access to PVR and unlit this master node is always created from stock if you have a look at the asset folder and you create a shader graph you have to choose if you want to have an unlit shader or master shader it doesn't matter you can also use an unlit shader delete the master create a PBR master until you have a PBR shader the basic difference between those two is that the PBR stands for physically based rendering these are the input for the actual rendering and sundered master is an unlit material it means it's not affected by light and that's why it just has the color and the other one and the PBR just there to calculate the white color based on the lighting that will affect the material I don't want to erase your time next up math advanced absolute absolute value just removes the sign if there is any the absolute value of minus 2 is 2 the absolute value of 2 is 2 exponential you can choose a base for example base 2 if you have 2 to the exponential base of 2 you get 4 so this is the input and this is exponential value exponential you choose base and you get the exponent as an input here is the input X 2 to the x equals for example for if x equals 2 this is exponential the length the length of the length of a vector simply said you put in a vector you get out the length you can put any vector in if you put a vector one in you get it want to run out logarithmic values you can choose the base for example base to base two means the logarithmic function and use input and for example for for you get two that's it modular what you do is simple so for example it's the west of the division so four point five modulo five equals 2.5 and thing if if you have I modulo something and you iterate over the I everything repeats all over again as soon as I is increasing and you can use it for example for colors use a Voronoi diagram yes a modular and you get the same gradient all over again so you can create cool effects with it negate you just take the negative of the input and for example if I negate this 0 to 1 for annoy a diagram I got minus 1 to 0 and if I add 1 I get the negative of this picture here normalized normalizes for normalizing vectors after that the vector that comes out always have a length of 1 poster wise poster wise is nearly the same as a modular here you put in a vector or something like the picture and you have a step definition and the amount of steps if the amount used in the picture so you can have really steps and there's no gradient anymore just steps and you can define how many steps you want reciprocal reciprocal is just a short form for divide so the first one is 1 and this is the input it doesn't matter if I change it here or here it's just a shortcut forward and we've Supriya Kel square wood is the same as before so here is a 1 divided by the square root of the input this is a only difference you can use this node all those two it doesn't matter Vedic math so you can just add things and suspect things which is really 1 plus 1 equals 2 you can do this for colors as well if you add some things the color gets brighter if you substituent something it gets darker as the same goes for division if you divided it gets darker you can multiply multiply vectors you can multiply matrices with vectors you can multiply single numbers and of course colors for example the one is the white value here if you multiply this by a red you get this output here the power is easy as it is for example here I put it in a zero and two its zero to the two and result is zero the square root is really the square would I do not have to explain it I guess and derivate yes you can deviate something I don't know why you should do this but it's possible so you will get something like yeah the value or this deepness in is this point if you have a function you can derivate by x or x and y or just y and the input is always some kind of position in the word space or object space interpolate this is the most used function in is a complete shader graph most of the time you want to interpolate between two images or vectors on something like that I've used the slider as a T value if I use one I get checkerboard down here if I used three will I get the ball no diagram and I can interpolate between those values the inverse linear interpolation does the same thing but just reverse it so it will calculate this T value black is 0 and 1 is white so you can reverse it if you want the smooth step is like the step and you can define edges here so that you just get a part of it or you want to have a step at a positive specific position if the first edge and the second edge has the same value it's just the same as if you would use a step node math matrix we know the matrix already from the input so you can construct the matrix you can use input matrix node as well it's basically the same you type in all your values you need and you have some functions for example you can calculate a determinant you can split the motorway matrix in the component you want or you can transpose it ranges very simple concept so you put in a min and a max value if your about the max values the output is it makes value if you are below the mean value the output will be the min value if you are in between the output is just the input the fraction note just calculates a fraction for example for this number one point two six our point will be output will be zero point two six just everything after the dot will be output it minimum and maximum just outputs minimum or the maximum of the input one minus one minus can also be created by just a substituent one minus an input this is just an abbreviation node because it's used so off random arrange creates a random number between men the minimum and the maximum value based on the see we map we map just normalizes your input so you have an int min Max and an outlet max for example my in min Max is minus 1 to 1 I expect the input in this range for example 0 lies exactly between minus 1 and 1 and then it's mapped between the middle of 0 and 10 so here it will be I guess somewhere around 5 if I type in 1 it will be mapped to 10 if I type in minus 1 it will be mapped to 0 so and if I type and 0.5 this means that it's mapped to 7.5 so it just normalizes the input and multiplies is with the range of the output the separate node is again an abbreviation for more complex input structure so it's basically a clamp node with min well u 0 and Max value 1 so they are cut out here and you have just input so these two nodes to basically exactly the same math bound math want does already the rounding for you so you can wound up with feeling round down with floor wound at 0.5 this is an old wound or you can get a sign the sign will output 1 or - not 1 if the input is bigger than 0 the output is 1 if the input is smaller than 0 the output is minus 1 the step node is just like a smooth step it's an abbreviation where both inputs are the same so you just defines a number where the throat is where as a cut between 1 and 0 should be made you see the Voronoi diagram on the left if I choose a very small value only the dot here is selected if I select a very large value only the very wide spots our white here every calculate your houses and unity has as to the try geometry functions the sine cosine tangent and of course the sister function as well as the arc and the hyperbolic and you can also convert for example degrees to radians and radians to degrees math vector you can calculate the distance of the vectors dot product and the cross product normally the distance of dot product does not make sense with vector one but these are the defaults here you can also plug in vector two vector four vectors we just to calculate these values the fernell effect is a little bit more complicated in the computation but for the usage it's very easy you just have a power and edges of your object will have different colors in the center because this is what happens and we all nature the edges are a little bit lighter if you look at a very flat angle on objects you will see that they're a little bit lighter so you can use a final node to create the final effect so the sphere mask is used in 3d space therefore I can't give you in an example but imagine the following situation you have the cube a basic cube in 3d space and then you can define a center where you want so the center is input you can for example takes origin of an object I will for example use here as a bottom of this box and then there will be fears around the center and if it's above a radius it will be highlighted for example here and if it's below a whale radius it's not highlighted and highlighted means output 1 and not highlighted is an output of 0 and you can use this to mask something our and the Hartness just creates a gradient around the sphere so that in this hardness range there is not a zero and one there was a slightly gradient if you set the hardness to zero you will have a heart gradient or no gradient at all rotate about axis is just the same as the C sharp function angle axis you have an input vector and an axis and you want to rotate around it so either in radians or degrees the unit can be set up here reflection and projection helps you with vector threes so you define a normal maybe as normal as just going up this means the surface is flat on the ground and then you have an input vector for the reflection which directly points to the ground and the output is this vector which is just mirrored around this effect or the projection works a little bit different so you have one vector and you project it to another vector and then 90 degrees angle is taken here and here this dotted line will just project this point to this plane or vector and this is here as an output you will get it's like the Sun which is casting race this is nice for calculating shadows or other things transform do not mess up with the feet sharp transform class it's a little bit different here you really transform positions for example the position of an object to the position in the world so for example if you have a point it's exactly at your origin of the object it will have the value 0 0 0 if you want to know where as this point in the world is you can convert this with this note the left things in the math category are waves normally the input our time nodes or just coordinates so you can specify a sine wave which is just a wave between the maximum number and minimum number if you have the saw tooth wave if you have structural axes and it's between one and maximum and zero at the bottom the square wave looks something like this is ah these are just steps between zero and one and the triangle wave is just a triangle it goes up slowly and then falls down immediately you see here how slowly it goes into a white value and then directly drops to black next section procedural these are very good procedural things I hope they will add more in the future because they help with prototyping you have a checker board at the first position you can set the colors how you want them and you can set the frequency as high as you want you have some nice options the Voronoi noise I used it a lot in this video your already seen it you can also have a gradient noise with a scale and a simple noise with a scale shapes you have some basic mathematical shapes you can specify width height and so on radiuses sides and many more things or rounded rectangle you can use them for example for masking out things here I have two different textures and I want to merge them in my material so I take a linear interpolation and then I can specify the radius or the height and the width and this is very fast to set up and very useful utility is so there was the preview node you can just plug anything in it and it will shows us preview and it only shows colors unfortunately it does not show any vector3 values or you have to guess them by the color but it's pretty hard logic logic is just a boolean logic you have all the operators you need and or not and oh and you can create them by input vectors for example asking is it infinity infinite yes or no is it not a number is it's a font face if you want to use this you have to go to the PPR master and say okay I want to have a two-sided render and if you just went as a back face you can for example use a different color or do something like that and you can also ask for if any of these numbers or inputs is one or all of the inputs is one and you have a comparison node you can compare two vectors or two simple numbers if they're equal not equal less greater or something like that and the result of all the logic here is nearly in every case branch where you put in a predicate and then you say okay it takes the input from the first one if the predicate is two otherwise take it from the other one as a pretty okay just not true and you see I'm switching between those two noises here the last section is UV so and the first thing you can choose is a flipbook if you have a texture like this you can specify I have four different rows and eight different columns in my texture and then you can choose the tile for example try 0 1 2 3 4 you can do animations with it or anything like that make sure to use this pattern and type in the right numbers otherwise you will get some nasty results polar coordinates you can choose a scale and lengths I don't know what know where is it useful for but maybe in the future I will see someone using this in a brilliant way and I can directly report it to you the radical sphere is just a little bit different and you can use half bangs of twangs is and the offset and it will create some kind of invisible sphere over your texture and just would manipulate as a UV values you can also rotate your input picture for example if it's upside-down or something like that you can rotate it if you want you can set the sender where you want it to be and then rotate around it three rights just creating a sphere and you can set everything you want to create a sphere effect and in the middle of the UV coordinates a stretched out and at the corners and Neely's the same tiling and offset most of used I guess the tiling just says okay how many times do I want to see and how many times do I want to see in the other direction and offset just sets off set off the image twirl is another interesting effect I use to twirl effect in my shader graph fish tutorial you can adjust 12 the complete thing around and you can set the strings offset and the center the try planner is a little bit different it's a little bit more complex to explain therefore I aggrieved the main preview here you see a sphere and no matter how I rotate the sphere the texture is always oriented on the view if I look close to it or directly on it I see my texture because it's projected from the view from the font from above you can't see it so yeah you see a little bit of it and from the left or the white so the sides and if I rotate it then it's merged together here in a way that half of the upper projection is visible and the other projection from the front that's it these are all the nodes in shadow graph the most of the nodes are pretty simple and easy to understand the real magic is in the usage and therefore you have to look up a lot of example every example that you get in your hands take a deep look at it because everything in shada graph is about the connection between those nodes the node itself are very simple this video should help you to just motivate you to try out new nodes if you liked the video please leave a like and comment something something is something that I did wrong I don't know if I get everything right here but I still did my best so see you next time subscribe to my channel to get more straight to-the-point tutorials [Music] [Music]
Info
Channel: DitzelGames
Views: 104,893
Rating: undefined out of 5
Keywords: unity shader graph, unity, shader graph, nodes, unity shader graph explained, unity shader graph tutorial, all nodes explained, unity shader graph node tutorial, unity tutorial, how to write a unity shader, shader graph development, unity shader development, unity custom material, unity how to shader, unity shader animation, unity shader complete, unity shader graph overview, overview
Id: 9aOtie1DKCc
Channel Id: undefined
Length: 35min 37sec (2137 seconds)
Published: Sat Jun 15 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.