Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize Lightmap Technology with Unity3D

2025-02-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to achieve Unity3D light mapping technology, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Concept

Lightmapping Lightmap technology is a technology to enhance the lighting effect of static scenes. Its advantage is that it can make static scenes look more real, rich and three-dimensional with less performance consumption; the disadvantage is that it can not be used to deal with dynamic lighting in real time. When the game scene contains a large number of polygons, real-time light sources and shadows have a great impact on the performance of the game. At this time, the Lightmapping technology is used to pre-dye the light effect into a map and apply it to the polygon to simulate the light and shadow effect.

Baking parameters parameters in the "All" group of the Object tab

Lightmap Static: selected indicates that the object will participate in baking.

Scale In Lightmap: resolution scaling, so that different objects have different lighting accuracy. In this way, according to the actual scene, the objects in the prospect can use a lower resolution and save the storage space of the light map. On the other hand, the closer objects use higher resolution to make the map more realistic.

Lightmap Index: the Lightmap index used when rendering. A value of 0 means that the first baked light map is used when rendering, and a value of 255 means that no light map is used when rendering.

The location and area of the lighting information of a game object in the whole lighting image is determined by Tiling XUnip Y and Offset Xamp Y together.

Parameters in "Lights"

Lightmapping: there are 3 types available

1) RelatimeOnly: the light source does not participate in baking and only acts on real-time lighting.

2) Auto: indicates that the light source responds differently in different situations. When baking, the light source acts on all objects that participate in baking; in actual game operation, the light source acts as a real-time light source on objects that are dynamic or not involved in baking, rather than on static objects that have been baked. In the case of Dual Lightmaps, for objects that are less than the shadow distance (the range used to generate shadows in real time in shadow Distance,Unity, no real-time shadows will be generated outside the range), the light source will act as a real-time light source on these objects, whether static or dynamic.

3) indicates that the light source is only used during baking and will not act on any object at other times.

Color: light source color.

Intensity: light intensity.

Bounce Intensity: the intensity of light reflection.

Baked Shadows: bakes shadows. There are three types to choose from

1) Off: light objects do not produce shadows.

2) On (Realtime:Hard Shadows): produces shadows with stiff contours.

3) On (Realtime:Soft Shadows): produces smooth shadows.

Shadow Samples: the number of shadow samples. The more samples, the better the quality of shadows generated.

Shadow Angle: the angle of the ray diffraction range.

Bake Tab

Mode: mapping method.

1) Single Lightmaps: the simplest and most straightforward method, which consumes relatively little performance and space. It can well represent the light and shadow effects of most static scenes.

2) Dual Lightmaps: real-time lighting and partial Lightmap lighting are used near, and Lightmap lighting is used in the distance. At the same time, there is a smooth transition between real-time light and static light and shadow, so that dynamic light and static light can be well integrated.

3) Directional Lightmaps: on the one hand, the light and shadow information is saved on the light map, and at the same time, the collected light source direction information is saved in another map, so that the Bump/Spec mapping can be completed without a real-time light source, and at the same time, the light and shadow effect of the ordinary light map can be restored.

Quality: generates the quality of the Lightmap.

Bounces: the number of light reflections, the more times, the more uniform the reflection.

Sky Light Color: Sky light color.

Sky Light Intensity: Sky light intensity. When the value is 0, the sky color is invalid.

Bounces Boost: enhance indirect light, which is used to increase the amount of light indirectly reflected, thus extending the range of reflected light.

Bounces Intensity: the multiplication of reflected light intensity.

Final Gather Rays: the number of rays emitted by each unit of the lighting map used to collect light. The more the number, the better the lighting quality.

Interpolation: controls the interpolation mode of daylighting point color. 0 is linear interpolation and 1 is gradient interpolation.

Interpolation Points: the number of daylighting points used for interpolation. The more the number, the smoother the result, but too much may blur some of the details. Therefore, the more daylighting points do not come, which can easily lead to excessive smoothing.

Ambient Occlusion: ambient masking effect.

LOD Surface Distance: used to calculate the maximum world space distance of a light map from high mode to low mode. Similar to the process of generating a discovery map from high mode to low mode.

Lock Atlas: if selected, all areas of the Lightmap will be locked, that is, the object will be locked using the Tiling XUnip Y and Offset XUnip Y attributes associated with the Lightmap, and it will no longer be possible to adjust the resolution attribute of the Lightmap and add new baked objects to the Lightmap.

Resolution: Lightmap resolution. Check the ShowResolution option of the Lightmap Display panel in the lower right corner of the view window to display the cell size. Assuming that Resolution is 50, 500 pixels of space on the Lightmap will be occupied on a flat grid of 10 to 10 unit area.

Padding: the distance between baking diagrams of different objects.

Maps Tab

Light Probes: used to set a reference to the currently used Light Probes Group.

Array Size: sets the number of Lightmaps.

Compressed: enables the use of compressed texture formats.

Baking

Bake Scene has three options:

1) Bake Scene: bake the entire scene. If there is an edited Light Probes in the scene, then bake the Light Probes at the same time.

2) Bake Selecte: bake only the selected parts. Use the Bake Selected function to add or update on the original basis, while the system will retain the previous lighting map. In this way, you don't need to re-bake the whole scene because of some changes, only the changed parts, which greatly improves the baking efficiency.

3) Bake Probes: only bake Light Probes.

Example

1 create a project and draw the following in the scene:

Check Cube and check Static in the Inspector panel, which allows Cube to participate in the baking.

2 Open the Window- > Lightmapping option in the menu bar, and the Lightmapping view pops up. The Directional Light in the scene is selected, and the settings for the light source appear in the Object tab in the Lightmapping view. The parameters are set as follows:

3 Parameter settings under the Bake tab:

4 check the Show Resolution check box in the Lightmap Display dialog box in the lower right corner of the Scene view, and you can see the resolution of the illumination on the model.

5 Click Bake Scene in the lower right corner of the Lightmapping view, select the Bake Scene mapping mode, and start generating Lightmaps.

The comparison results are as follows:

1) after baking:

2) before baking:

Note: the property of plane must be set to Static, otherwise Cube will not be shaded.

The property of plane is not set to Static, and the effect is as follows:

These are all the contents of the article "how to achieve Lightmapping Technology in Unity3D". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report