Amazing skybox using visual shader in Godot 4 #Godot #godottutorial #howto #shader

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone and welcome back to your favorite internet show of this channel the Skybox Series in today's video we will going to create a skybo Shader in gdau using visual Shader this video will be the basic one similar to the one I have done for Unity and I know that I have said that I won't recreate existing videos in gdo but I need to show the basic so we can possibly continue the series in the future using G do all right for the tutorial I will be using G do 4.2 and I have also installed the add-on called Shader lip add-on is not necessary for this tutorial but I mean it's good to have for more complex videos like if you want to recreate the unity tutorials then you pretty much need the add-on lastly I've hit 1,000 subscribers thank you so much apparently I also need watch hours to apply for partner program so I request you to watch entire video without skipping it will really help okay enough of that let's get to the topic right after the intro all right I have a blank scene with no 3D as main parent Here and Now first let's create a visual Shader right click create new resource search for visual Shader then select the mode Sky I will call it Sky Box Shader let's also create a material for our Shader right click create new resource search for Shader material I will call it Skybox with the extension do material assign our Shader to the material pretty cool now the question is where do we apply the material you need to click these three little dots here here you can adjust the sky color the sun size and all the good stuff we don't care about all this because we will create our own so just go ahead and click this add environment to scene button then we will have this world environment node it is necessary because without this our Skybox will not render when we on our game in the inspector click the environment resource and in it expand the sky section click on the sky resource here you can see the sky material slot just drag and drop our material here now in the Shader first we need exess information of our world in the unity video we have grabbed that by normalizing the position node value in World space and G we have nice variable called I Direction although it is called I Direction all it does is it gives the excess information in World space and we cannot see the preview here because sko does not currently support 3D previews I guess now we need the up AIS and for that let's click this tiny Arrow here it will give us red green and blue values or we can also say x y and Zed respectively now we cannot see the preview of Y axis either but for the educational purpose I will feed it into the color so in y axis we will have value of one at the top then it will slowly fade to zero at the Horizon and then it will phad to minus one at the bottom first we will only need the values between 1 and zero now if you have watched the unity video there we have used clamp node to clamp the values between 1 and zero for this one let's use max node just to show the Alternatives Max node as the name suggest Returns the maximum value between these two inputs so for the value bigger than zero we will get that value itself and between 0 and negative values 0 is bigger so we will get zero so now we have one to Z in the sky and the rest is all zero okay now we need values between 0o and minus one and for that we will use you guessed it Min node Min node Returns the minimum values between the two inputs feed our y AIS into a and for B set zero now we have zero at the top and from Horizon to bottom we have negative values we can't use negative values we need to change them to positive values in unity tutorial I have used the negate node to do that for this one let's use absolute node again this is to show that there are million ways to get the desired result you don't need to blindly follow me just try to understand why we are using each node do that and you will never find yourself stuck in tutorial hell anyway I just realized I haven't explained what absolute node does absolute node will simply return positive value or absolute value or unsigned value so we have all zero at top from Horizon to bottom the value will slowly fade from 0 to one let's add these two together now we have one at top zero at Horizon and again one at bottom but we won't opposite of that we want zero instead of one and vice versa in simple words I want to invert the colors for that let's use one minus node one minus will subtract whatever values we feed in from one so in this case it will invert the color pretty cool now the max node will be our Sky part our absolute node will be our ground part and one minus node will be our Horizon now we need to control the size of the Horizon so let's create a power node power node will darken the values which are less than one as we increase the power and now I think we can go full screen with our Shader all right we will do the same for our Sky part and our ground part so let's create two power nodes and to control the power from the inspector let's create three float parameters I will call them zeni Horizon and nador blend respectively and fit them in power nodes now let's create three color parameters for our Sky Horizon and ground color then let's multiply our Sky color with our Sky Power node then we will do the same for our Horizon and ground finally let's add everything together then take our final add noes output and feed it into the color and our basic skybook Shader is done it will look like this and we have our nice Sky boox now just to give you guys ideas and justify the thumbnail let's add some clouds for that we will use Simple noise node this is the node from the add-on but you can also use texture 2D let noise texture no big deal we will multiply our noise with our Sky part then add it to our Sky finally add this one here and you will see everything turns black because we have a compilation error the reason is the simple noise uses default UVS and in our Sky processor we don't have access to UV variable if I hit the show code button you can see it says unnown identifier in expression UV it's all right default UV won't help us here anyway so we will say that we want to apply the simple noise parallel to our our x z plane to do that we will simply use x and z axis of our world or I Direction and combine them using Vector 2 compose node then take its output and feed it into simple noise nodes UVS now we have the weird stretching going on at the Horizon the reason is because our Skybox is basically a sphere and the noise is trying to wrap around the top to fix this we will simply divide our new Vector with our Y axis then take its output and feed it into the UV now our noise is applied perfectly parallel to our x z plane finally let's move the clouds for that let's create a Time node then create multiply node for vector two take our time and feed it into multiply node Now to control the speed and direction you can of course use Vector 2 parameter node I will just pass the values in multiply node itself then to offset the values we will use UV function node with mode panning it will simply Pan the UVS using the offset take our multiply nodes output and feed it into off set take our divide nodes output and feed it into UV finally take our UV function nodes output and feed it into simple nice nodes UV and we have our moving clouds of course this needs the Improvement but I will leave that to you and if you're creating a game like DCS then you will need a different approach maybe volumetric clouds with Ray marging but for this tutorial I think you guys will get the idea now you can hopefully recreate the effects from the previous episode in gdau as well take it as a challenge and give it a shot and that's pretty much the video If you find the video helpful consider like share and subscribe wish list Cosmic roads on Steam if you have any questions post them in the comments that's it from me and I will see you guys in the next one [Music]
Info
Channel: Digvijaysinh Gohil
Views: 365
Rating: undefined out of 5
Keywords: Godot, Shaders, How to, Tutorial, Visual shader, Shader graph, Skybox, Procedural sky, Sky, Clouds, Godot Shader, Godot shader tutorial
Id: y3ENkHJ3heI
Channel Id: undefined
Length: 11min 36sec (696 seconds)
Published: Sat Jan 06 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.