Glass in Unity
Following some of the work we have done in the Galaxy Shooter that we just completed, we are going to look at some concepts of Unity 3D work space.
Today, we are going to look at creating glass in a 3D environment. As you can see from the Gif to the left, it is quite possible and easy using the tools, that Unity gives use.
For the simple set up, we will be using a Sphere GameObject inside a Cube Gameobject and using two different Materials.
To create a new Material, right click in the Project tab, select Create>Material from the menu. Make two materials, One we will call blue and change the Albedo Color to a dark before placing it on our Sphere so that we can see it clearly against the clouds of the sky box.
The second Material, We will call Glass. Placing it on the Cube will let us see the changes that we make as we make them.
The First and most important step for a Glass like material is to make it Transparent. You will find this option under Rendering Mode at the top of the Material’s Inspector Tab.
You can also access these same settings in the GameObject’s Inspector tab, but it is important to know that any changes made to the Material in the Inspector will change that Material for all uses of it. So, if you want different types of a similar Material, Duplicate the Material with Ctrl+D (Cmd+D on Mac).
Let’s give this Glass Material a pale Yellow color to contrast it against the Blue sphere it contains. At this point, you are probably wondering why you are looking at a Yellow cube instead of a Blue sphere in a Glass cube. That is were the Alpha comes in.
When you pick a Color when the Albedo, this Color Wheel picker window pops up. For the most part, we will simply use the the top half of the window and be down with it. But let’s take a look at the bottom half.
We see Four slide bars with colors in them and labeled R,G,B,A. They stand for Red, Green, Blue and Alpha. And let us set each color in the mix to a value of 0 (Black) to 255(Full Color). The Alpha channel controls how see through a color is and when the Material is transparent, how transparent it is.
Looking back at the Material Inspector, we can adjust the Metallic and Smoothness to get different looks to the Glass. We can go from completely clear to completely reflective (0 to 1 Metallic). Or Soft (matte) Reflections to Sharp and Crisp (Softness).
With this, We can now make everything from Windows to Display Cases to Monitors and Vending Machine fronts. Show me what you can come up with.