Categories: Unity, C #, VS2015
Date Created: 2016-04-11 I. INTRODUCTION
Light, also known as light source, is an important part of every scene that illuminates scenes and objects, allowing the game to have its own personality and style, such as using lights to simulate the sun, burning matches, flashlights, gunfire, or explosions.
Mesh models and textures determine the shape and texture of the scene. The lighting determines the light, color and atmosphere of the scene environment. Each scene can use more than one light, reasonable use of light can create a perfect visual effect.
In the Unity Professional Edition, all lights can selectively project cube-mapped textures. The cube map (Cubemap) is projected to shadow in all directions. Second, the type of light
There are 4 types of lights in Unity 5.3.4. The way you create lights is similar to how you create other game objects:
Because different types of light source properties are similar, they are presented here together.
1. Type
The type of light source.
(1) Directional
Direction light. This type of light can be placed at infinity and can affect all game objects in the scene, similar to the lighting effects of sunlight in nature.
Directional light is the type of light source that consumes the least graphics processor resources.
Directional lights are mainly used to simulate the sun light and moonlight in outdoor scenes. It affects the surface of all objects in the scene. Their graphics processors cost the least. The shadow cast by the directional light (for a platform that supports shading) is explained in depth.
When the directional luminaire has a cookie, the cookie is projected to the center of the lamp's Z-axis. The size of the cookie is controlled by the Coikie size (cookie size) attribute. Sets the cycle mode of the Cookie texture to repeat (Repeat) in the viewer (Inspector).
Is the directional light that shadows the cloud-like Cookie texture:
Cookies are a great way to quickly add details to a large outdoor scene. You can even move the lights slowly in the scene to create the effect of the Izumo movement.
Note that when using forward rendering, shadows are disabled for directional lights with cookies. However, you can enable shadowing by writing a custom shader (shader) using Fullforwardshadows.
(2) Point
The point light emits light from one position to the other, affecting all objects within its range (range), similar to the lighting effect of the bulb. The shadow of a point light source is the type of light that consumes the image processor resource more.
(3) Spot
Spotlight. This light is emitted from a point and is irradiated in one direction according to a conical range, which is defined by the spotlight angle (spot Angle) and range.
Spotlight is the type of light that consumes graphics processor resources more.
This type of lamp affects only the objects in the area where it is exposed, and is suitable for simulating the headlights, flashlights, and spotlights in the stage scene 、...... and other lighting effects. Is the spotlight effect:
The spotlight can also have a Cookie-a texture that the cone light casts down. This is ideal for making light through the window. The edge of the texture is black very important, which is to enable the Border multilayer map (Border Mipmaps) option, and its loop mode (wrapping mode) is set to Extrude (Clamp).
is a spotlight with a Cookie:
(4) Area
Area light/polygon light source. This type of light source cannot be applied to real-time lighting, only for light map baking (Lightmap baking), which illuminates one side of a plane's rectangular section from all sides.
Area lights. A light that is able to illuminate one side of a plane's rectangular section from all sides. Rectangles are defined by the width (width) and Height properties. Area lights can only be used during light map baking (Lightmap baking) and have no effect on objects at run time.
The area light casts light from one side of a flat rectangular section.
The light is projected on all objects within the light range. The size of the rectangle is determined by the width and Height properties, and the plane's normals, such as the one on which the light is projected, are the same as the positive Z direction of the light. The light is emitted from the entire surface of the rectangle, so that the shadow of the object affected is softer than the shadow of the object affected by the illumination or directional light.
Because light calculations require intensive processor use, the area lights are not available at run time and can only be baked into the light map (lightmap).
2. Range
Range. Used to control how far the light is emitted from the center of the light object. This property applies only to point lights or spotlights (spot light).
3. Spot Angle
Spotlight Angle. Determines the angle of the cone. Applies only to Spotlight (spot).
4. Color
Color. The color of the emitted light.
5, Intensity
Strength. Brightness of the light. The default value for the lighting (point)/Spotlight (SPOT)/area lamp (zone) is 1. The default value for the directional light (directional) is 0.5.
6. Cookies
This is used to specify a texture with an alpha channel for the light source, so that the light has different brightness in different places. If the fruit light is a spotlight or directional light, you can specify only-a 2D texture. If the light source is a point light, the item must be specified-a cubemap (cubic thoughtfulness).
You can create a texture that contains an alpha channel and assign it to the light's cookie variable. The Cookie will be projected by the light. The alpha shading of the Cookie adjusts the amount of light, generating highlights and black dots on the surface. This approach is ideal for greatly increasing the complexity and ambience of the scene.
All built-in shaders in Unity can work seamlessly with each type of light. However, Vertex light (vertexlit) shaders cannot display cookies or shadows (Shadows).
7. Cookie Size
Scales the projection of the Cookie. Only directional lights (directional) have this parameter.
8. Shadow Type
Shadow Type (Professional Edition only). Select a shadow type for the light source. You can choose No Shadows (Turn shadows off), hard Shadows (solid shadows), and soft Shadows (soft shadows).
Note that soft shading consumes more system resources.
By default, only directional lights can turn on shadows.
If you want to turn on the point light or the shadow of the spotlight (only if it is published as a Web or standalone version), you can use the Edit → Project Settings → p!ayer option in the menu bar, and then in the viewer view, through the rendering Path (render path) further sets the deferred light type.
The options for Rendering path are:
(1) Vertexlit
Vertex illumination. This light effect is the worst and does not support shading. Typically used to configure a crossover machine or a restricted mobile platform.
(2) Forward
Forward coloring. It is very good to support the light irradiation effect, but does not support the point light source, the spotlight.
(3) Deferred Lighting
Delayed lighting (supported only for Pro editions). Supports the best lighting effects and shadows cast by all types of light sources, but requires some degree of hardware support.
9, strength
Shadow intensity. The dark degree of the shadow. Its value is between 0 and 1.
10, Resolution
Resolution. Controls the quality of the shadow resolution. There are 5 options: the use of quality is not set, low quality, medium quality, high quality, higher quality.
11, Bias
Offset. The offset used to set the pixel position of the light space compared to the value of the shadow map. The value range is 0~0.5. If the value is too small, the surface of the object will produce Sele-shadow, that is, the surface of the object will have an error display from its own shadow, and if the value is too large, the shadow will deviate to a large extent from the projected game object.
12, softness
Soften. Controls the offset of the shadow Blur sample area. Applies only to directional lights (directional).
13, softness Fade
Soften fade out. Controls the extent to which shadows fade away from the camera. Applies only to directional lights (directional).
14. Draw Halo
Draws a glow. If checked, the light's spherical glow is drawn, and the halo's radius is equal to the range. See the Halo documentation and render setup documentation for more details.
15. Flare
Flare/glare. You can choose to refer to the spot that will be rendered in the position of the light.
16. Render Mode
Rendering mode. The importance of this kind of light. This affects lighting fidelity and performance, see Performance considerations below. Options include:
Auto: Automatic. Determines the rendering method at run time based on the brightness of nearby lights and the current quality settings.
Important: Important. The light is always rendered individually and by pixel. Use this feature only for very important effects (for example, the front light of a player's car).
Not Important: unimportant. The light is always rendered in a faster vertex/object light mode.
17. Culling Mask
Remove the shading map. Used to selectively make certain groups of objects unaffected by light; see Dual light maps.
18, Lightmapping
Light map. This item controls the mode in which the light source shadows the light map.
Realtimeonly: Real-time light calculation only, do not participate in the baking calculation of the illumination map.
Auto: Automatic.
Bakedonly: Bake only for light maps, no real-time light calculations.
19, Width, Height
Width (wide) (for area lights only) the width of the rectangular lighting area.
Height (height) (for area lights only) the height of the rectangular illumination area. Third, performance considerations
Lights are rendered in two ways: vertex illumination and pixel illumination.
Vertex Lighting calculates only the light at the vertex of the game model and inserts the light onto the surface of the model.
Pixel lighting is calculated at each pixel of the screen, and therefore consumes more resources.
Some older graphics cards only support vertex lighting
Although pixel illumination renders more slowly, it can achieve some of the effects that vertex lighting does not achieve. Normal maps (normal mapping), light cookies, and real-time Shadows (Realtime Shadow) are only rendered in pixel mode. In pixel mode, the shape of the spotlight and the lighting effect are better.
When rendering in vertex light mode, the light effects of the above three lights are as follows.
Is the effect of the point light in vertex illumination mode:
Is the effect of spotlight (spot) in vertex lighting mode:
is the illumination effect of the directional light (directional) in vertex illumination mode:
Lighting has a very big impact on rendering speed-so you have to weigh the light quality against the game speed. Because pixel lights are much more resource-intensive than vertex lights, unity renders the effect of "brightest light" only on a per-pixel basis. The actual number of pixel lights can be set in the quality settings for both the network player and the stand-alone compilation target.
You can use the Render Mode property to explicitly control whether the light should be rendered as a vertex or pixel light. By default, Unity automatically classifies light based on the extent to which the object is affected by light. Which lights are actually rendered as pixel lights are determined by the specific object.
"Unity" 4.6 lights