Custom Skyboxes in Unity3D

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi guys nick here with physical access bringing you a new video on unity 3d development and today i'm going to cover a few different ways that you can create your own skybox now the three methods that i'm going to cover are just generating a skybox from images generating a procedural skybox using unity's built-in procedural skybox generator and then also baking a cube map in unity using a reflection probe so the very first method we're going to cover is a six sided cube map and the way you do this is you simply go in and you find throw you make six images in my case i'm only going to use three but you'll make six images and you're gonna apply those two cube in the c the scene editor here i have set up just a default scene and i've put in three images that i've imported as sprites um i've just basically dragged three images in um i made this pretty simple like cloud for the side there's gonna be blue on top and brown on the bottom for the ground so one of the things that you want to make sure you do for each of these is you're going to want to change the wrap mode to clamp because it's going to be on repeat if you put it on repeat it's going to have white edges on the cube when you're done so how we're going to do this is we're going to right click and we're going to create a material and this material will call skybox to give it a name and with this skybox we're going to change this to from standard shader to skybox six sided what you'll then notice is that you now have these six options to select for putting in these images on each side so i'm going to go ahead and put in on the bottom for down the top for up and then the other four i'm going to put right left back and front now you'll see here if you rotate around it's it looks like a cube now i'm going to go ahead and apply this to our scene so in order to do that we just need to go into our window rendering lighting settings and we're going to change our default skybox to our new material skybox and then in your scene you can move around look around and see what that looks like so you'll notice that there is a bit of a problem and that is that it looks like a cube it doesn't look smooth it doesn't look like it's an infinite you know expansion you can actually tell that you're in a cube and that's not necessarily ideal so if you want to manually create one just remember that's the limitation that you're going to face there are ways to generate them so that they look like they're not in a cube and you'll just you know you'll see um some space and one option i was going to show you before moving on to the others is there was this cool generator that lets you build a space based skybox and it'll actually generate the images for you and i've brought it up right here you can see that there is this pre-generated six images here now when you bring this into unity the only thing you have to remember is that left and right are opposites so it's going to generate the left side and the right side you're going to want to put its right on the left and it's left on the right in unity but this will generate a six-sided cube map for you and you can randomize a seed you can change um whether it has small stars or not or bright stars you can take the bright stars out or sun and you can even take out the nebula and just have a giant star field so this is pretty cool i'm going to put the link in the description so you can check that out if you want to generate your own cube map using this especially for like a space game really handy to use so um then the next method that we're going to cover is how to use a procedural cue of procedural skybox and so i'm going to open up a scene we'll save this one and in this scene you can see that we have the default skybox applied and the way that you created procedural skybox is you just go create then you're going to go to material we're going to call this skybox again and on this shader we're going to go to skybox oops let me go back skybox and procedural now you can do a lot of things with this what you can do is set a sun size if you can find it change the sun's size oh i'm forgetting that we're still using the uh default you can change the sun size um and then you can change the sun size convergent which will make it look kind like it's brighter and then you can change the color of the atmosphere so whatever you want uh make it kind of like a maybe like a gold or something and then you can change the color of the ground so we'll change that maybe make it more of a blue and the way you apply that again is you just go to window rendering lighting settings and then you change it to this new skybox here and now you have your new skybox so that's procedural now the last option i've done some setup so let's go into that and look at the scene we have here for our last skybox we're going to use a baked cube map using a reflection probe and the way we're going to do this requires a little bit of setup and you can see here in this scene i've actually set up quite a few things i've already applied a procedural skybox to the background of this scene and i have set up the sprites this night skyline with these sprites that are out there and the easy way to do this is just to have a little bit of like an image with some boxes and some yellow lights and all i've done is put that in there as a 2d object sprite applied that and then moved those sprites around in a circle if you want to know how i got a circle so well using that what i really did was i put in this cylinder and on that cylinder i just move these sprites around and resize them and then i move them using vector if you hold v when you're moving something you'll see that it snaps to the edge of the sprite or the corner of the sprite and if you move that it'll lock in place along the uh to another to another vector of another object so i'm going to undo my move there and we will hide that cylinder again and then all i did there is once i got one quarter of those i made four blocks and i rotated each of them by 90 degrees so that i have a circle and so that's my skyline i also did the same thing with some stars uh the stars i just put a sphere out and all i did was just put these little white stars all over the sphere and when you have a giant sphere there it's just going to lay on the surface of the sphere so we're in the middle there we can see the stars we have that procedural background we have these uh the skyline here and so you can kind of look around and that's what i want to use for my sky box so if i were like manually create this remember the problem that i had is it looks like a box and i want it to look more like this so we're going to use a reflection probe now a reflection probe will work because really what a reflection probe is is just a six sided like a camera that looks six directions and so that's a great way of getting a cube map because we're basically just taking those images and putting them onto a cube map so the first thing that you have to do or the most important step you have to do is to make sure that all of the objects that you want to capture on that reflection probe are set to static and so the easy way to do that since i put all of my objects in a parent object i have the skyline and i set it static here i just checked the box so if you uncheck it says you want to change children and you're going to say yes so we're going to set it to static say yes change children i did the same thing with the star as you can see it's set to static and this other set of stars as well is set to static so now what we're going to do is in our hierarchy we're going to create a light object reflection probe i'm going to set this i'm going to set its transform to 0 0 0 because every it's going to be centered between everything and we're now going to go ahead and bake this so you're going to see right here it says baked and we want to make sure i think everything looks okay here um you can leave all this stuff to default oh that's right we do want to change one thing we want to make sure that our resolution is something that's halfway decent so 128 is not going to look good 1024 512 is maybe okay for your needs but you might want to do 1024 or 2048 for a higher resolution cube map for your skybox so i'm going to say 1024. you'll want to use 2048 if you have like a higher you know higher resolution game you want to look nicer use that higher resolution so once that's in place you can come down here and click bank and it's going to take a little bit to pick and i will probably pause the video while it's doing that and then come back once it's done and we're going gonna see what our result is okay so now that it's baked we can kind of preview what we saw here and it's hard to see the stars because they're so small but you can kind of tell uh let's see if we can maybe increase the size of this to give us a little bit more visibility into that and you can see we've got some white stars there now i put the skyline up a little bit too high and the reason why is because i couldn't see um before so one of the things i probably want to do is put that skylight down a little bit or bring the reflection probe up so that the dark purple kind of hits right at the skyline but for the purposes of the demonstration we've shown that it works so if you change this reflection probe and move it up you're going to get that skyline touching right there or if you move the skyline down you'll get the same effect so let's see what happens when we actually apply it as a background so what i'm going to do is just create a new scene and we're going to call it skybox test and one thing you'll notice is when the skybox was created in that same scene that we had our reflection probe so this scene here the skybox bake scene in that same folder it's going to create the skybox bake folder and it's going to give you this lighting data this reflection probe that's 1024x1024 and a reflection probe that's 10 128 by 128 you will want the 1024 by 1024. there's also one other setting that we need to check before we actually apply this to a skybox and that on this reflection probe is to change the convolution type here to none because what you'll see is it starts to kind of blend the corners of the cube so you'll see like this kind of like white area it kind of looks blurrier and you don't want that you want it to be you want it to look like it's not blended in any way it'll look cleaner and crisper so make sure you turn this off if you want to see what it looks like test it out but now what we're going to do is go back into this and we're going to oh i need to apply this first and we're going to create a new material as soon as this saves there it goes and so um we're going to create material we're going to call it night sky box knight sky box and we're going to call this or make this a sky box material and we're going to select cube map on this cube map we're going to select our reflection probe i think this is yeah we want the higher res one so this is the low res one you can't even see the skyline this is the high res one and that's what we want to use so now that we have that we can actually go to our skybox test scene we'll save everything here we will go to window rendering lighting settings and we're going to change that to our new skybox material night sky box and there you go and now you'll see the combined effects so this is no longer in the scene with the skyline this is what the cube map has rendered and you can tell because now if i go down or up my skyline is no longer going down or up with me it's all just baked into that so for demonstration we've proven it works really simple to go i'll probably go ahead and fix this and show you the final image once it's done i'll be back in just a minute and there we go after fixing it um and re-baking with the uh i made the reflection probe a little bit higher in the other scene and after re-breaking it this is the end result uh you see that the light now this the skyline is actually touching the ground so there you can see that we can bake that image and you can make any scene you want to you can put 3d objects in here you can throw that in there as long as you set everything that you want to be captured to static you will get that i would also recommend that if you're going to create or bake a new skybox that you make a whole new scene to do it um i don't know why i had complications doing this myself but there were some i i tried to do this with an existing scene that i had already created and i tried to set everything to static and unfortunately i could not get some things to capture even though they were just 3d objects there shouldn't have been any reason it looked like it should have worked but once i recreated the scene entirely and baked it with the brand new scene it worked even though it was the same exact objects and everything like that so that's my only extra tip for this so there we have it guys now you know how to make three different types of sky boxes in each case you're going to want to have a material and you're going to set that material to a skybox type and one of the types is going to be the six sided where you're going to grab six images and you're gonna throw one image onto each side top bottom left right forward and back one of those is going to be the procedural where you can use unity's built-in procedural method for making this planet with an atmosphere in the sun and you can make all sorts of colors with that the default skybox that you get with unity is also a procedurally generated one so you're just changing that to something that you want and then the last option is using a cube map and you can generate that cube map using a reflection probe you use the reflection plug you bake the refresh reflection probe then you take that cube map be sure to check your resolution and then the convolution settings um and then you take that cube map and you apply it as the material for the cube map on your skybox and that's everything i got for you today i hope you guys enjoyed watching this video if you did please like and i hope to see you next time you
Info
Channel: Bit Galaxis
Views: 48,938
Rating: undefined out of 5
Keywords: 2D Game, 3D Game, 3D Model, Game Dev, Game Development, Game Input, Gamedev, Space, Space Ship, Sprite, Stars, Starship, Unity, Unity 3D, Unity 3D Tutorial, Unity Tutorial, Unity3D, Unity3D Tutorial, Video Games, gamedev, game dev, unity, unity3d, unity 3d, scripting, C#, Unity Standard Assets, Character Models, Characters, Lighting, Spot Light, Directional Light, Fog, Point Light, Cubemap, Skybox, Skyline, Tiling, Background
Id: g38f-xxvEQ8
Channel Id: undefined
Length: 16min 59sec (1019 seconds)
Published: Thu Jul 16 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.