[MUSIC]
In this video,
we'll enhance the look of our solar system thorough the use of materials.
A GameObject is often made up of 3D geometry, sometimes called a 3D model.
It is represented here, as a wire frame.
You could think of the material as the wrapping paper around the game objects.
All game objects that are visible have a material.
All game objects have a shader.
A shader is basically a formula that defines how the material is rendered,
that is how the material looks.
The material of the shader is what make the game object visible on the screen.
There are different types of shaders, each with its own properties.
One of the common properties of shaders is a texture.
In this example, the texture is what makes the sphere look like the planet Earth.
Our objectives will be to create materials for the Sun, the Earth, and the Moon,
as well as create a skybox material.
A skybox is a special type of material that is a wrap around your entire scene,
that displays the vast beyond of the world.
In our case, it's outer space.
Okay, so we're going to add materials to our various game objects here,
starting with the Sun.
And once again, there's many different ways to do things,
there's a lot of short cuts.
We'll show a couple techniques here, right now.
So under the Textures,
we can see we've got all these lovely textures acquired from NASA.
So for example, if I click on one I can get a preview over here in Inspector.
So here is a sunmap image,
picture of the Sun surface.
And one kind of shortcut is, you can actually take a texture like this, and
actually drag and drop it right on a game object, either in the scene, or
in the hierarchy.
So let me go ahead and do that, and you can see that essentially
applied that sunmap texture to the game object, if I actually click on the Sun.
What actually happened is it added what's called a material component,
and once again materials have shaders, and if you actually open up the details
of the shader, it's got a variety of maps for the standard shader type.
The Albedo map is the top level one, and
it actually applied that sunmap texture as that Albedo map.
If I actually click on this,
you can see it shows that that's what's actually selected there.
The other thing it did is, it actually created this material.
So a material is actually a separate game asset, just like the textures themselves.
So you can see it actually created a Materials folder for me up in the project,
and if I open it up, it created a material called sunmap.
Of course, I could rename this if I wanted to, just like any other game asset.
I can call this Sun Material, as an example, and
you can see the Sun Material is what is attached to the Sun.
We'll go back and play with some of these settings in a moment, but for now,
let's go ahead and create one of these for the Earth.
So I'll do the same technique.
I'll grab the earthmap texture, drag and drop it onto the Earth.
You can see it created a new material called earthmap1k,
corresponding to the same file name.
So I'm gonna go ahead and rename that just for clarity, call it the Earth Material.
And once again, I can see the component attached to the Earth.
I can open it up, and see that textures is attached
there as the Albedo map, for the standard shader.
So let's do the Moon.
I'm gonna do this in a slightly different way, as sake of example, if I go to
the Moon, let's say I want to use a material that's already been created.
So I'm gonna go ahead, and grab one of these.
I'll grab the Earth map, and drag and drop that onto the Moon,
or I can drag and drop it right into the inspector.
That'll apply that Earth Material to that game object.
If I go ahead and tap F, you can zoom in and you can see, yep, I've got the Earth,
and then I've got my baby Earth here, and now I wanna modify the material.
I wanna make it the Moon, so I'm gonna go ahead and
grab the moonmap map texture, and drag and drop it right onto this spot.
Or, once again, it's got that little dot, so you can also click here, and
it will bring up all the possible things in my project, that would work with that.
So you can see these are all the textures, and of course, the moonmap is selected.
Now what this did is, it actually modified the material.
So you can see that since the same material is attached to both the Moon and
the Earth, now I've got two Moons, I've got a big Moon, and a baby Moon.
So this isn't really what I wanted to do.
So I'm gonna go ahead and undo that last modification,
to bring it back to the Earth.
So really, of course I need to make a new material for the Moon.
You can share materials across game objects.
Maybe you've got a bunch of cars in your game, and
you want them all to have the same material.
But just realize, if you modify a material that's attached to multiple game objects,
it's gonna modify it to all the game objects that use that material.
So I'm gonna create a new material, I'm gonna do this in a slightly different way.
Over here in the Projects tab, I can go to the Materials folder, and
I'm gonna go ahead and select Create, and Material is actually one of the options.
So let me go ahead and select Material.
Now, the reason I selected the folder first, is, when you create things,
it'll put it in the folder that's selected.
If I wouldn't have done that, it would have put it at the top level,
which really isn't a problem, I would just have to then drag
it into the Materials folder to keep my project organized.
And I'm gonna go ahead and rename this Moon Material.
You can see I've got the material selected, so
the inspector is all about the material, the shader, and then its settings.
I'll go ahead and click the little selection on that top map, and
select the Moon.
And then, now I can basically drag and
drop that material onto the Moon, and it will change.
So now we've got the Earth and the Moon, and if I pan over we've got the Sun.
So they've all got their respective materials.
Of course, if I hit Play, you can see that my Solar System model or
simulation, is starting to look a lot better.
One of the problems, of course,
is the Sun really doesn't look like it's emitting light.
One thing I actually have here is, I actually have a directional light in this
scene, that I got when the scene first started.
Let me go ahead and delete that.
Eventually, we'll change the lighting here.
But the directional light really doesn't really make sense,
cuz it's shiny and down at the Sun.
So I'm gonna go ahead and delete that.
On the Mac, it's Cmd+Delete, in your hierarchy on Windows,
I believe it's Ctrl+Delete.
So let me delete that.
You can see the lighting changed dramatically,
in our world, and we'll fix that in the next lesson.
But for now, let's make the Sun look like it's emitting some lights.
So let me go back to the Sun, go down to the Material component,
and one of the settings is actually the Emission setting here.
And right now, it's set to zero.
So, let me just go ahead and play with this, I can move just off of that, and
click and drag.
And you can see as I move it up, it starts to kind of emit light.
So we can do that by dragging or we can, of course, set it numerically so
I'll set it just to 0.5 for purposes of example.
The other thing that we can do is we can actually set a map for admission.
So I don't really have a separate map here.
So, for purpose of example, I'm gonna go ahead and take the Uranus map,
and attach it as my emission, or maybe the Venus map.
And you can see that, it essentially,
is kind of layering, lemme hit F to move back to it.
It's sort of layering that texture, on top of the other texture,
and is sort of emitting the content of that texture out.
So it looks kind of like a fiery surface now.
I could actually even change the color of the emission,
and see how that plays out, so maybe if I select a yellow color,
it's gonna really look like a burning Sun surface.
So the last thing that I wanna do is,
I want my Solar System to look like it's in space.
So we've got this kind of generic horizon effect here,
that's sort of the default in Unity.
So I wanna change that, and
I do that through another type of material called a skybox.
So let me go to the Material folder again, and go ahead and
create a new Material, and I'm gonna call this my Space Skybox Material.
So I'm gonna actually change the shader here.
So right now it's the standard shader, let me go down,
you can see there's many different shader types.
One of the types is skybox, let me go ahead and pick the six sided skybox,
and we see the various properties of the shader change down below.
For the six sided, we've got six textures, that we can drag in here, essentially.
If you're in a room, and you look around, you've got basically a wall in front of
you, a wall behind you, to the left, to the right, up and down.
So you basically, can create a texture, for
the entire sort of box that you're sitting in.
Since we're in space, I've got a space texture here.
Let me go ahead and just hit select and pick space.
And you can see down here in the preview, that's one side of the box.
Ultimately, I could have different pictures for different boxes of space,
but I'm gonna use the same one, since it's essentially black with some stars,
and go ahead and drag it into all six of those positions.
So I've got my Space Skybox Material set,
so now I need to actually apply it to my world.
And they actually changed this a little bit with Unity 5, the way you do it now
is, you go under window, and go down to the lighting option under window.
And this will bring up the lighting panel, and you wanna be in the same view.
You can see right here, is where we can select the skybox.
So right now, it's the default skybox, this is just built into Unity.
I wanna change this to my Space Material Skybox.
Let me go ahead and bring that window back, and
I'll go ahead and use the little selection thing to do that.
And go ahead and pick the space skybox, and
you'll see immediately now we are in outer space.
Let me go ahead and hit Play.
And our scene is looking a lot better, our Sun is actually sort of emitting light.
You can see the Earth and the Moon, are very, very dark, since we got rid of
that default light, but we'll fix that, once again, in the next section.
In the next video,
we'll further enhance the look of our Solar System through the use of lighting.
[MUSIC]