光照貼圖快速入門 Lightmapping Quickstart

 

This an introductory description of lightmapping in Unity. For more advanced topics see in-depth description of lightmapping in Unityhtml

這是一個Unity 光照貼圖的引導手冊。若是想查看更多的高級功能請查看in-depth description of lightmapping in Unityapp

Unity has a built-in lightmapper: it's Beast by Illuminate Labs. Lightmapping is fully integrated in Unity. This means that Beast will bake lightmaps for your scene based on how your scene is set up within Unity, taking into account meshes, materials, textures and lights. It also means that lightmapping is now an integral part of the rendering engine - once your lightmaps are created you don't need to do anything else, they will be automatically picked up by the objects.編輯器

Unity內置的光照貼圖烘培工具是Illuminate Labs 的Beast。烘培光照貼圖流程被完美的整合到Unity中。這就意味着使用Beast能夠根據你的網格物體,材質貼圖和燈光屬性的設置來烘培你的場景,從而獲得完美的光照貼圖。同時也意味着光照圖將做爲渲染引擎的一部分。只要你烘培一次光照貼圖你就不須要其餘任何操做。光照圖將自動指定到物體上。ide

光照貼圖

Preparing the scene and baking the lightmaps
準備須要烘培的光照貼圖的場景

Selecting Window – Lightmapping from the menu will open the Lightmapping window:工具

從菜單欄選擇Window – Lightmapping打開光照圖工具窗口。ui

  1. Make sure any mesh you want to be lightmapped has proper UVs for lightmapping. The easiest way is to choose the Generate Lightmap UVs option in mesh import settings
    檢查你將要烘培的模型上是否存在一個合適的用來定位光照貼圖的UVs。你也能夠從mesh import settings面板中的勾選Generate Lightmap UVs選項來生成一個用於定位光照圖UV的集。
  2. In the Object pane mark any Mesh Renderer or Terrain as static – this will tell Unity, that those objects won't move nor change and they can be lightmapped.
    在物體面板中將要烘培光照貼圖的物體設置爲Static(靜態),這樣Unity就會知道哪些物體是須要被烘培的。 
  3. To control the resolution of the lightmaps, go to the Bake pane and adjust the Resolution value. (To have a better understanding on how you spend your lightmap texels, look at the small Lightmap Display window within the Scene View and select Show Resolution).
    在Bake面板下調整Resolution的值控制光照貼圖的分辨率。(在Scene View面板裏勾選上小窗口Lightmap Display中的Show Resolution選項能夠幫助你更直觀的查看貼圖分辨率設置)。 
  4. Press Bake 
    點擊Bake(烘培)
  5. A progress bar appears in Unity Editor's status bar, in the bottom right corner. 
    在Unity編輯器底部的狀態欄的右邊會出現一個進度條。
  6. When baking is done, you can see all the baked lightmaps at the bottom of the Lightmap Editor window. 
    當烘培結束時,你能夠從光照圖編輯器的底部預覽窗口中查看全部烘培好的貼圖。

Scene and game views will update - your scene is now lightmapped!this

場景和遊戲窗口將會更新。如今在你的場景中已經能夠看到光照貼圖效果了!spa

Tweaking Bake Settings 調節烘焙設置

Final look of your scene depends a lot on your lighting setup and bake settings. Let's take a look at an example of some basic settings that can improve lighting quality.orm

最終場景的渲染效果取決與你對燈光和烘培選項的更多設置。讓咱們來看一個經過基礎設置改進光照的質量的小例子。htm

This is a basic scene with a couple of cubes and one point light in the centre. The light is casting hard shadows and the effect is quite dull and artificial.

這是一個簡單的場景,包含一組立方體和一個位於場景中心的點光源。燈光產生硬陰影,看起來效果至關平淡而不天然。

Selecting the light and opening the Object pane of the Lightmapping window exposes Shadow Radius and Shadow Samples properties. Setting Shadow Radius to 1.2, Shadow Samples to 100 and re-baking produces soft shadows with wide penumbra - our image already looks much better.

選擇燈光打開物體面板,展開陰影範圍和陰影採樣屬性。設置陰影範圍爲1.2,陰影採樣爲100從新烘培,會產生一個半影範圍很寬的軟陰影。咱們畫面看起來真的好多了。
 

With Unity Pro we can take the scene one step further by enabling Global Illumination and adding a Sky Light. In the Bake pane we set the number of Bounces to 1 and the Sky Light Intensity to 0.5. The result is much softer lighting with subtle diffuse interreflection effects (color bleeding from the green and blue cubes) - much nicer and it's still only 3 cubes and a light!

使用專業版Unity可以開啓全局光照和天光進行烘培畫面效果能獲得更大的改進。在Bake(烘培)面板設置Bounces(反彈)爲1,Sky Light Intensity天光強度爲0.5。可以烘培出帶有微妙變化的反射效果的軟光源。(會從綠色和藍色的盒子上產生色彩溢出)。

 

Lightmapping In-Depth 光照貼圖深刻了解

For more information about the various lightmapping-related settings, please refer to the in-depth description of lightmapping in Unity.

更多的和光照貼圖設置有關的信息請查閱in-depth description of lightmapping in Unity

相關文章
相關標籤/搜索