REFLECTIONS in Unity

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video we'll have a look at adding reflections in unity will be using reflection probes and screen spaced reflection to achieve the effect the environment that I'm using is called corridor and you can download it for free off the asset store also special thanks to dine guy in Diego Judah men are Minoru see you're right Omer passio infinity PPR and hence have tuned for their support on patreon alright let's get started so here's our scene and as you can see it's a pretty cool corridor sci-fi level we have a bunch of lights and materials but everything looks very dark the reason why is that this scene is very reliant on reflections and since we don't have any reflections in here all those parts simply stay black we can see this if we right-click in the hierarchy and create a 3d object and go and select sphere now we want to reset the position of a sphere so that's right click and hit reset and it should reset to the origin here let's hold down ctrl and drag it to the center of our level that's it F to focus on it and I'm just gonna place it somewhere around here and maybe also size it up a bit so now we have this large sphere in the middle of our level and currently it just uses the default material if we wanted to put a reflective material on here let's right-click in the project go create select material and it's called it shiny let's then select our sphere and drag shiny on to it so now you can see we have a standard material with standard settings the first thing that we want to do is increase the metallic to one this will make it completely reflective in general the more metallic and material is the more it will reflect its surroundings we also have another parameter here that controls our reflection that's the material smoothness which is of course how smooth the surface is we can imagine that the smoother a surfaces the sharper the reflections will look in other words if we decrease the smoothness we have blurring out our reflection so in our case we'll set that to 1 so we can see our reflections as clearly as possible and as you can see a sphere is completely black we don't have any reflections so to set up reflections for a scene let's start by creating reflection probes a reflection probe is like a camera that captures a spherical view of its surroundings unity then takes this image and store I said in a cube map this means that it splits up the environment into six textures one for each direction then unity can simply overlay the cube map on top of nearby objects in order to create reflection the credit reflection probe will go to the hierarchy right click go light reflection probe and right away you can see our scene lights up it's currently lighting up in a very blue color and it's not even certain that something is going to happen in your case so let's make sure to go through all the settings to set them up correctly the first thing that I want to do is position our reflection probe to be kind of in the center of this main corridor in fact I just want to go ahead and place it right inside of our sphere so let's select a sphere right click on the transform and hit copy component then let's click on the reflection probe right click on the transform and hit paste component values so now it snaps right inside of a sphere the next thing that we want to set up is the bounding volume that's this big box right here this determines what objects are included in the reflection so all objects that are within this box are both going to be reflected upon as well as reflect onto other objects so what we want to do here is make sure to include all the objects that we would like to do this will edit the volume that's the button up here and now we can simply click and drag on the sides here I'm holding down Auto scale on both axes and I'm just gonna extend it out a tiny bit as well as extended out in the depth you'll notice as you resize your bounding volume you can actually see different parts of your level get affected once you're satisfied we're just gonna go out of volume edit mode and now everything looks good in here however of course we want to have actual reflections we don't just want to color things blue the reason why is if we click on our reflection probe you can see it's currently completely blue down here so it's not really gathering any reflections that's because by default reflection probes are baked you can see that up here the type is currently set to baked this means that the cube map for this probe is calculated even before we start the game this is much much better for performance since when we're running the game we don't actually have to generate any textures but it also means that we can only include objects in our reflection that are static so that we're sure they want move so if I go in the environment here and select all of the objects in my environment this doesn't include stuff like collision particles and lighting but it does include every single object I have in here so we want to mark this entire environment as static and of course we could go to the right here and just select static but then we would also start calculating static lighting and all that stuff instead we can use the drop down here to be more specific and only mark them static for reflections will hit yes change children and if we now go window lighting and then settings at the bottom here where it says auto-generate will disable that and instead we want to use the drop down arrow to select Bakke reflection probes and voila we now have reflections inside of a level and you will notice immediately that this looks way better than before all of the blue parts are now reflecting parts of the environment and our sphere is now completely shiny we can also now select the material for sphere go under the inspector and you can now clearly see how the metallic Ness is how much we want to reflect and the smoothness is the blurriness of the reflection also notice how our sphere is actually reflecting the environment but we didn't mark it as static the reason why is that we can still see reflection on non static objects but they won't be part of it and if we go into our reflection propia you can see that we can't actually see the sphere anywhere you can also see that we have a bunch of settings that we can configure most notably we can configure capture settings for our cube map this is stuff like resolution if we go in here and change it to something like 32 and then hit the back button we can clearly see that the quality of the cube map gets reduced so let's bump that right back up to 128 we can also choose whether we want to have high dynamic range the shadow distance and we can even select a custom background color because you actually don't have to use the same one that your camera uses one of the options that I use the most is the culling mask this allows you to disable different layers that you don't want to include in your reflection so say we wanted to make sure that our sphere was never included in the reflection we could simply go and create a new layer for it we could call it ignore reflection select the sphere and make sure to add it to that layer then when we select the reflection probe on the culling mask we can simply disable that layer and now it will completely ignored even if we mark it as static so that's really cool but all these reflections are baked what if we wanted to show reflections in real time say we had moving objects well let's try and create a test case for this let's go to a hierarchy right-click go 3d object and select cube let's move over this cube as you can see it's not currently showing inside of our sphere let's make it easier to see by right clicking in the project go create material let's create a red material will change the albedo to a solid red and let's drag the material on to our cube still we're not able to see it the reason why is that the cube is not included in our cube map to include it we would have to mark it as static as was going to the reflection probe and hit bake and now it's clearly there but as soon as I go ahead and move the cube while the reflection stays where it is so instead we want to select the reflection cube and change the type from baked to real-time if your reflection suddenly look really weird that's because you need to go to lighting and re-enable Auto generate because we have to get rid of the old reflections that were calculated there we go so now that our reflection probe is set to real-time we should be able to select our cube and disable it from static and it will still show up in the reflection probe we can also go ahead and move it down but it won't actually update the reason why is that the Refresh mode on our reflection probe is currently set to on awake and so it will actually only update once you start the game so if we go out and hit play we can see that the reflection updates but only in the beginning to change this will just change the refresh mode from on awake to every frame and you can see now the reflection nicely follows our cube around we can also change the smoothness of this reflection you might not be able to see it but it is a tiny bit laggy to get rid of this we can change the time slicing from all phases at once which runs over nine frames to no time slicing and there we go the reflection is now completely smooth remember these settings definitely also have a impact on performance so most of the time I'd recommend simply selecting the default option here so I'm gonna exit out of play mode select the reflection probe and change it back to baked I'll select the cube again and change it back to static and I'm also going to move it over here closer to the center of our probe and what you notice is that suddenly our entire environment turns kind of red that's because a huge part of the reflection in our probe is currently a cue because the cube is very very close by now one of the ways to make this better is by using multiple reflection probes to do that we'll simply go into our scene we'll select our reflection probe we'll go and modify the volume and we'll make this way smaller we then go out of any mode hit control D which will duplicate the reflection probe hold down control and move it over we'll duplicate it again and move it over again and you can see this gets rid of the red over in the side corridors because they are now using separate reflection probes that aren't affected by the cube but of course inside of our main corridor things are still very red and this is just one of those things that you'll have to live with when approximating reflections using probes right for one like to get rid of this cube right here it doesn't really add anything to the scene but one effect that can really help add realistic reflections to your game is screen space reflection unlike reflection probes screen space reflection is always calculated on the fly as an image effect it's commonly used to create more subtle reflections such as on a shiny floor or in puddles the good thing about SSR is that objects will line up with their reflections which often doesn't happen with probes now screen space reflection is of course a post-processing effect and that means that we need to download the post-processing stack from the asset store in order to use it now I have an entire video on using the post-processing stack including this effect that I definitely suggest you check out but I just wanted to show you how nice this effect can be so I've downloaded the post-processing stack and I've gone to the main camera and added a post-processing behavior and I've created a post-processing profile as well if I select this we can see all the nine affect that I'm currently applying to my camera and here at the top we have screen space reflection if I go ahead and enable this you can see right away it makes a huge difference we can see lights reflecting on to the floor surface we can see the sphere reflecting on to the floor we can see lights reflecting on to the walls and walls reflecting on to the walls it really adds a lot of depth and realism to the scene if we open it up you can also see we have a bunch of different settings that we can tweak here right away it's going to say that this effect only works with the deferred rendering path so if you're not seeing any reflections you'll probably want to go to your main camera go on the rendering path and change this to deferred the main setting here is probably the reflection quality you will get much much nicer reflections if you change this to high but do know that this effect can be pretty computationally expensive so you'll have to experiment with this for your own game then we have a bunch of different settings for the reflection if you want to know what all these properties do I would recommend looking at the unity manual and of course checking out my video on post-processing but I think it's safe to say that our environment now looks much much better awesome that's pretty much it for this video if you enjoyed it make sure to subscribe so dome is the future one also make sure to follow us on twitter at breakage suite for more updates and cool behind-the-scenes stuff on that thanks for watching and I will see you in the next video thanks to have the awesome patreon supporters who donated in January and especially thanks to Dan guy in da kogai kudamon Amanda Russi Ouray Omer vo infinity PPR hence of tune Sybok mommy pay me double tap 45 mer Peter died Cobra John pure God Superman the great games P Thomas wall-e Jason Tito Derek Eames Kirk Faisal Murphy beyond Farooq knob suniye Hobson Erasmus Rob pan James Rogers Alex wickets key and Robin pony you guys Rock
Info
Channel: Brackeys
Views: 199,338
Rating: undefined out of 5
Keywords: brackeys, unity, unity3d, model, material, materials, beginner, easy, how, to, howto, learn, course, tutorial, tutorials, fix, tip, game, development, develop, games, reflection, reflections, screen space, screen space reflection, ssr, probes, probe, mirror, water, wet, surface, reflective
Id: lhELeLnynI8
Channel Id: undefined
Length: 13min 1sec (781 seconds)
Published: Sun Feb 04 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.