Unity3D Game Development 5: basic game creation scenario 2

Source: Internet
Author: User

The light source is an important part of each scenario. The Grid Model and texture determine the shape and texture of the scenario, and the light source determines the brightness, color, and atmosphere of the scene environment. More than one light source can be used in each scenario, and reasonable use of the light source can create a perfect visual effect.

Uniity provides four types of light sources

1. Directional light: A direction light source, similar to the lighting effect of sunlight in nature

2. Point light: a light source, similar to the lighting effect of a light bulb.

3. Spotlight: the Spotlight, similar to the lighting effect of the Spotlight

4. Area Light: Area Light/Area Light Source

The creation process is as follows:


Parameter information of the light source:


Type: Type, Type of the light source

Range: Range. This parameter is used to control the distance from the center of a light source object. this parameter is set only for a spot light source and a spotlight.

Color: Color, which is used to adjust the Color of the light source.

Intensity: Specifies the Intensity of the light source. The default value of the spot light source and the point light source is 1, and the default value of the direction light is 0.5.

Cookie: specifies the texture with the alpha channel for the light source, so that the light brightness varies in different places.

Cookie Size: this parameter is used to control the zoom Cookie projection. this parameter is available only for the direction light.

Shadow Type: Shadow Type. You can select No Shadows (disable Shadow), Hard Shadows (Hard Shadow), and Soft Shadows (Soft Shadow). Only the Directional light source can enable the Shadow.

Draw Halo: draws a Halo.

Flare: Flare/glare, which is used to specify the Flare/lens halo effect for the light source.

Render Mode: rendering Mode. This option is used to specify the rendering Mode of the light source. Three options are available: Auto, determine the light source rendering mode based on the brightness and runtime quality settings; Important: Important, light source rendering by Pixel; No Important: not Important, the light source is always rendered at the fastest speed

Culling Mask: Remove masking graphs. The game objects associated with the middle layer will be affected by the illumination of the light source.

Lightmapping: lightmap

OK. Let's take a look at the specific case column.

Pilot the scenario that has been created, such:


Choose GameObject & gt; Create Other & gt; Directional light from the menu bar, and add a direction light for the scenario. In this case, you will find that the scenario is much brighter, such:


We want to simulate the midday sun effect, so in the retrieval view, we modify the color of the light source, set the intensity to 0.8, and add a shadow. In Shadows Type, we select Hard Shadows (Hard Shadows ), for example:


Next we will introduce the camera

Just as the scenes in a movie are used to present the story to the audience, the Unity camera is used to present the game world to the players. There can be at least one camera or multiple cameras in the game scene, multiple Cameras can create two-person split screen effects or advanced custom effects.

Unity supports two types of cameras: perspective (perspective) and Orthographic (orthogonal) cameras. We can understand that they are used in 3D and 2D. Let's look at the camera attributes, for example:


Let's take a look at the parameters of the Camera component.

Clear Flags: Clear the flag to determine which part of the screen will be cleared. This option is generally used to describe different game objects using multiple cameras. There are three modes.

Skybox: The sky box. This mode is set by default. The blank part of the screen shows the sky box of the current camera. If the current camera does not set the sky box, it uses the Background color by default.

Solid Color: Solid Color. If you select this mode, the background Color of the current camera is displayed.

Depth only: Depth only

Don't Clear: do not Clear

Background: Background. This parameter is used to set the Background color.

Culling Mask: removes masks and controls the game object rendered by the Camera Based on the layer specified by the game object.

Projection: Projection Method

Perspective: the camera will render the game object in Perspective mode.

Orthographic: Orthogonal. The camera will render the game object evenly in a perspective-free manner.

Field of view: the Field of view, which is only applicable to the perspective mode. This option is used to control the camera's angle width and longitudinal angle size.

Clipping Planes: Specifies the distance between the cropping plane and the camera starts rendering and stops rendering.

View Port Rect: Standard View rectangle. Four values are used to control the position and size of the camera View. This parameter uses the screen coordinate system and the value is between 0 and 1.

Depth: Depth, which is used to control the Rendering sequence of the camera. A larger camera will be rendered on a smaller camera.

Rendering Path: Rendering Path

Target Texture: Target Texture

HDR: highly dynamic Rendering

Next let's take a look at how to implement picture-in-picture in the scene

Import existing scenes. In this scenario, a Camera named Camera has been created, and the Deth depth is 0. The Camera's view includes the bridges in the scene, for example:


Next we create a new Camera named Camera01, then adjust the Camera's field of view, which is different from the first Camera, and set Deth to 1. Then we click Play, the second camera image is found, for example:


To make the camera occupy part of the screen to achieve the effect of painting in the picture, edit the ViewPortRect attribute to 0.6, 0.58, and click the Play button, for example:



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








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.