Procedural Skybox Shader with Clouds in Unity With URP Shader Graph! ✔️ 2020.3 | Game Dev Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi i'm ned and i make games today i want to show you how to set up some simple unity shader graphs for good looking sky boxes sky boxes render behind everything else in your scene don't discount them a nice skybox can add a lot of polish to your game i'm using unity 2020.1.4 f1 and universal render pipeline 8.2.0 make sure that you've enabled the universal render pipeline by creating a settings asset and enabling it in your project settings let's see how to set a custom skybox material first the skybox material can use any unlit graph shader here i've created a material that uses such a shader to have the current scene use this material as its skybox open the lighting dialog and switch to the environment tab and select your skybox material [Music] let's get started by creating an unlit shader graph we would like to have the shader draw a gradient across the sky where the altitude decides the color we can find the altitude by normalizing world position which transforms it into a coordinate on a sphere then we can take the y coordinate we can do this with a position node set to world space a normalized node and a split node the second component is the value we need finally this remap node converts the altitude from a value ranging from negative one to one to a value ranging from zero to one plug this into the color field of the master node to visualize what we've accomplished so far okay we want to use the altitude to create a color gradient shader graphs do accept gradients as a property so we can create one here go ahead and set up some colors the sample gradient node will output the color at the specific altitude value where zero is the left and one is the right on the gradient go ahead and save the asset and check it out in the scene you might notice that the material for this gradient the property does not show up in the inspector this makes the shader a bit of a pain to use so let's try a different approach this time i'll define three color properties one for the horizon where the altitude equals zero straight ahead one for the zenith where the altitude equals one directly up and one for the nadir which is where the altitude equals negative one are directly down define these blend power properties as well which control how quickly the colors blend also note that i went ahead and created this as a sub graph because i know i'm going to be using it in future shaders here you can see i've calculated the altitude again but i left the range between negative one and one because this is easier to work with with this algorithm next i need to blend the three colors together which happens in these nodes it looks pretty complicated but these previews thankfully give a good visual representation of what's happening generally i want to create three gradients one for each color multiply each gradient by its corresponding color and then add all three together i like to play around with the different value properties to get a better idea of how they affect the final gradient so i am liking this but we can do better really you can get lost in adding features to procedural sky boxes but let's start by adding some animated clouds for this you'll need a cloud texture i created one using a cloud filter in an image editor but you can find one online or create one yourself just make sure that yours has an alpha channel create another sub graph called cloud texture our goal with this sub graph is to draw the cloud texture on the top of the skybox we want it to animate and fade into the horizon which we can control with these properties the color and scale properties here give more control over how the clouds will look in the graph we again get the altitude value with the position normalize and split nodes we can also use the first and third components as the uvs into the cloud texture but we want the texture to shrink closer to the horizon so divide the uvs by the altitude notice that if the altitude is negative the uvs don't make much sense which we can see on the bottom half of this preview don't worry about it though the shader will mask out these values multiply the uvs by the scale property next add an offset for animation the time node returns various timer related values take the time value and multiply it by the animation speed property then add that to the uvs finally feed the uvs into a sample texture 2d node multiply the output color by the cloud color property and route that into the output node as i said earlier we need to remove clouds below the horizon we can do this by outputting an alpha value everything below the horizon should be zero which is how the altitude works so we can start with that throw out negative values with this maximum node this power node changes the gradient shape based on the distance fade power finally multiply the alpha gradient by the texture's alpha component and we'll have the final value this shader combines the sky gradient with the cloud texture you can see both sub graphs here with their corresponding properties this blend node combines two colors together in a variety of ways we want to use the overwrite mode which behaves like a normal alpha blend would route that output into the master node and that's it save your asset let's check it out and that's it play around with the material properties until you have something you like as i said before you could get really fancy with your skybox shader sun stars weather day night cycles the possibilities are endless i hope this shader will help you get started thanks so much for watching if you like this video please leave a like it lets youtube know to recommend this video to others how do you plan to use the skybox shaders any topic you'd like to see a video about thanks again and make games [Music] you
Info
Channel: Ned Makes Games
Views: 36,529
Rating: undefined out of 5
Keywords: gamedev, game development, development, unity, unity3d, madewithunity, programming, game design, csharp, lua, uml, nedmakesgames, nedmakesgames dev log, twitch, twitchcreative, twitch creative, indiedev, indie game, dev log, shaders, 3d modeling, blender, tutorial, walkthrough
Id: sXevaQ8cM2c
Channel Id: undefined
Length: 7min 29sec (449 seconds)
Published: Thu Sep 03 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.