Unity3D Game Development 8 sky box

Source: Internet
Author: User

The sky box in Unity is actually a kind of material that uses a special type of Shader. This type of material can be shrouded in the entire game scenario, and similar prospects can be simulated based on the texture specified in the material, the effects of the sky make the game scene more complete.

Choose Assets> Import Package> Skyboxes from the menu bar, for example:


Import Skyboxes. UnityPackage for the project. The Importing package dialog box is displayed. All content in the resource package is listed in the dialog box, for example:


After a resource is imported, the resource package contains nine sky boxes, for example:


In Unity, there are two ways to use the sky box, one is to specify in the Render Settings (rendering Settings) in Unity, this method is for game scenarios, simply put, in the same game scenario, no matter which camera object is used, the sky box remains unchanged, and the specified sky box can be directly displayed in the Scene view.

Choose Edit> Render Settings from the menu bar. The Render Settings parameter panel is displayed in the Inspector view. Click the circle button on the right of the Skybox Material item, in the displayed Select Material dialog box, specify the sky box Material for the game scenario, for example:


Another way is to add the sky box component to the camera object and specify it in the sky box component. This method is only for the camera itself. Simply put, it is in the same game scene, if you switch the camera, the sky box will change accordingly. The priority of the sky box specified for the camera will be higher than that specified in the rendering settings.

Select the camera object, and click Component-> Rendering-> Skybox in the menu bar to add the sky box Component to the camera object, for example:


Then add the materials of the sky box as shown in the above method, which is invisible in Scene. Therefore, we click the Game view, for example:


In addition to the sky boxes provided in the skybox resource package, Unity also supports custom sky box materials. Before making the sky box materials, you must prepare 6 Image Textures, it is used to paste the materials on the front, back, left, right, top, and bottom of the sky box. Images can be generated by using software or taking photos, and must be seamlessly connected.

First, we prepare six texture maps, and then open the menu bar Assets-> Create-> Material, Create a Material, and click RenderFX-> Skybox In the shader drop-down list on the right, for example:


Click the Select button in the Texture preview window on the right of the Front (+ Z) item, and Select the corresponding Texture in the Select Texture dialog box that appears, for example:


Choose Edit> Render Settings from the menu bar. The Render Settings parameter panel is displayed in the Inspector view. Click the circle button on the right of the Skybox Material item, in the pop-up Select Material dialog box, specify the created sky box Material for the game scenario, for example:


Observe the effect of the sky box, and you can find obvious seams at the turning point of the sky box, which is caused by the texture Warp Mode setting, set the Warp Mode of the texture to the Clamp Mode, for example:


After the operation is complete, you can find that the seams at the turning point of the sky box are completely lost.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.