Unity game Development Tips a collection of materials applied to the creation of reflective materials for materials in unity
In the game, most material applications are inseparable from the texture, and the texture itself is a picture. So, when you're learning this chapter, it's a good idea to install powerful software like Photoshop and gimp that can edit pictures on your computer. The former is used in this chapter. In addition, some textures need to contain transparents channels, so the picture is best saved as a format that can store the appropriate information, such as PSD and TGA.
Create a reflective material in unity
In life, there are many examples of reflective materials (reflective material). For example, objects such as water surfaces, smooth metals, mirrors, etc. can reflect other objects, such as reflections in the waters, figures in mirrors, 3-1.
Figure 3-1 The metal ball in the figure, and the surrounding environment reflected
In unity, you can mimic this reflection. Just use a shader with reflective properties, and then configure it a little bit. The following procedures are described:
(1) Prepare two textures, one of which needs to contain transparent information, that is, an alpha channel, and then import into the project. The two textures used in this section are shown in 3-2.
Figure 3-2 Importing two texture graphs
(2) Select the texture that does not contain transparent information, and then in the Inspector view, make the following changes:
- Q Set the Texture Type property to reflection;
- Q Set mapping property to cylindrical;
Then click the Apply button. This setting indicates that the texture will be used as a reflection of the cylinder. The texture is set and the texture is set to 3-3 as shown.
Figure 3-3 Setting the texture in the Inspector view and the texture after it is set
(3) In Project view, create a material and name it mat_reflect, select it and then make the following settings in the Inspector View:
- Q Set Shader (shader) property to Reflective/specular;
- Q Set Base (RGB) Gloss (A) to a texture that contains transparent information;
- Q Set reflection cubemap as normal texture;
As shown in 3-4.
Figure 3-4 the cylinder object in the Inspector view 3-5 scene view
(4) In the hierarchy view, add the cylinder object. See the cylinder3-5 shown in the scene view. It does not reflect any of the surrounding objects at this time.
(5) Drag the mat_reflect material to the cylinder object, 3-6, the effect is very different, it shows its own color, but also reflects the surrounding objects.
Hint: The texture contains transparent information, the more transparent the object reflected by the more clear the image. Figure 3-7, after lowering the transparency, the reflected image is dark and the sharpness is reduced.
Figure 3-6 the cylinder object that is reflecting the surrounding object figure 3-7 after the opacity is reduced, the effect of reflection imaging
This article is selected from: Unity Game Development Tips Collection University bully internal information, reproduced please indicate the source, respect the technology respect the IT person!
Create reflective materials for the application of the materials in the Unity game development Tips Collection