朱峰社區(qū)首頁 朱峰社區(qū)

搜索資源 注冊|登陸

等待

返回 展開菜單
按功能 按軟件

Unity3D游戲制作教程

Unity3D游戲制作教程

包含5節(jié)視頻教程

本系列包含Unity3D介紹、Unity3D導(dǎo)出人物、Unity3D導(dǎo)出場景、Unity3D導(dǎo)出動作、游戲測試最終完成一個簡單的游戲。是一套非常完整的Unity3D游戲制作教程。

關(guān)閉

Unity組件:Light 燈光

關(guān)注:1456 留言:0 樓主:森林酷魚 發(fā)帖時間:15年11月16日

森林酷魚

普通會員

森林酷魚

社區(qū)新人:1級

關(guān)注2824人

  • 性別

  • 年齡

    18

  • 積分

    1

  • 登陸

    1

  • 發(fā)帖

    2

間隔線

Lights will bring personality and flavor to your game. You use lights to illuminate the scenes and objects to create the perfect visual mood. Lights can be used to simulate the sun, burning match light, flashlights, gun-fire, or explosions, just to name a few.

燈光將給你游戲帶來個性和味道。你用燈光來照亮場景和對象 以至創(chuàng)造了完美視覺的氣氛。燈光可以用來模擬太陽,燃燒的火柴,手電筒,槍火光,或爆炸,等等等等,在此就不一一列舉。

Light 燈光
The Light Inspector 燈光檢視面板

There are three types of lights in Unity 在Unity中有三種類型的燈:

  • Point lights shine from a location equally in all directions, like a light bulb.
    點光源從一個位置向四面八方發(fā)出光線,就像一盞燈。
  • Directional lights are placed infinitely far away and affect everything in the scene, like the sun.
    方向光源(平行光) 被放置在無窮遠(yuǎn)的地方,影響場景的所有物體,就像太陽
  • Spot lights shine from a point in a direction and only illuminate objects within a cone - like the headlights of a car.
    聚光燈 燈光從一點發(fā)出,只在一個方向按照一個錐形物體的范圍照射,就像一輛汽車的車頭燈。

Lights can also cast Shadows. Shadows are a Pro-only feature. Shadow properties can be adjusted on a per-light basis.

燈光也可以投射陰影。陰影是專業(yè)版的功能。陰影屬性可以在每一個燈光的基礎(chǔ)上進(jìn)行調(diào)整。

Properties 屬性
  • Type 類型
    The current type of light object: 燈光對象的當(dāng)前類型
  •     Directional 方向光
    A light placed infinitely far away. It affects everything in the scene.
    燈光放在無窮遠(yuǎn)處。它影響著在場景里所有物體。
  •     Point 點光
    A light that shines equally in all directions from its location, affecting all objects within its Range.
    燈光從它的位置各個方向發(fā)出光線,影響其范圍內(nèi)的所有對象。
  •     Spot 聚光
    A light that shines everywhere within a cone defined by Spot Angle and Range. Only objects within this region are affected by the light.
    光線在 按照聚光燈的角度和范圍所定義的一個圓錐區(qū)域 照射所有物體。只有在這個區(qū)域內(nèi)的對象才會受到光線照射。
  • Range 范圍
    How far light is emitted from the center of the object. Point/Spot light only.
    光從物體的中心發(fā)射能到達(dá)多遠(yuǎn)?。只對點光源和聚光燈
  • Spot Angle 聚光燈角度
    Determines the angle of the cone in degrees. Spot light only.
    燈光的聚光角度。只用于聚光燈
  • Color 顏色
    The color of the light emitted. 光線的顏色.
  • Intensity 強(qiáng)度
    Brightness of the light. Default value for a Point/Spot light is 1. Default value for a Directional light is 0.5
    光線的明亮程度,點光源/聚光燈 默認(rèn)值是1。方向光源 默認(rèn)值是0.5
  • Cookie
    The alpha channel of this texture is used as a mask that determines how bright the light is at different places. If the light is a Spot or a Directional light, this must be a 2D texture. If the light is a Point light, it must be a Cubemap.
    這個紋理的阿爾法(alpha)通道作為一個遮罩,使光線在不同的地方有不同的亮度。如果燈光是聚光燈或方向光,這必須是一個2D紋理。如果燈光是一個點光源,它必須是一個立方圖(Cubemap)。
  • Cookie Size
    Scales the projection of a Cookie. Directional light only.
    縮放Cookie投影。只用于方向光。
  • Shadow Type 陰影類型
    (Pro only)
    No, Hard or Soft shadows that will be cast by this light. Only applicable to desktop build targets. Soft shadows are more expensive.
    硬或軟的陰影,將是由燈光所投射的。只適用于編譯桌面目標(biāo)程序(PC)。軟陰影更為昂貴。(耗資源)
  •     Strength 硬度
    The darkness of the shadows. Values are between 0 and 1. 陰影的黑暗程度。取值范圍是在0和1之間。
  •     Resolution 分辨率
    Detail level of the shadows. 陰影的細(xì)節(jié)水平。
  •     Bias 偏移
    Offset used when comparing the pixel position in light space with the value from the shadow map. When the value is too small the surfaces start to self-shadow themselves ("shadow acne"), when too big - casters are disconnected from receivers ("peter panning").
    用于比較燈光空間的像素位置與陰影貼圖的值比較的偏移量。當(dāng)值太小,表面會產(chǎn)生self-shadow("影子痤瘡"),-----就是物體的表面會有來自于自身的陰影,物體就像長了痘痘一樣。當(dāng)值太大,光源就會脫離了接收器("彼得平移")。
  •     Softness 柔化
    Scales the penumbra region (the offset of blur samples). Directional light only.
    縮放半陰影區(qū)(模糊樣本的偏移量)。只用于方向光
  •     Softness Fade 柔化淡出
    Shadow softness fade based on the distance from the camera. Directional light only.
    陰影柔化是根據(jù)到相機(jī)距離進(jìn)行淡出的。只用于方向光。
  • Draw Halo 繪制光暈
    If checked, a spherical halo of light will be drawn with a radius equal to Range.
    如果勾選此項, 光線帶有一定半徑范圍的球形光暈被繪制。
  • Flare 耀斑
    Optional reference to the Flare that will be rendered at the light's position.
    可選的。參考耀斑(Flare) , 在光的位置渲染出來。
  • Render Mode 渲染模式
    Importance of this light. This can affect lighting fidelity and performance, see Performance Considerations below. Options include:
    這燈光的重要性。這可能會影響照明的保真度和性能,請參閱下面的性能注意事項。包括:
  •     Auto 自動
    The rendering method is determined at runtime depending on the brightness of nearby lights and current Quality Settings for desktop build target.
    為桌面構(gòu)建目標(biāo)渲染的方法是根據(jù)附近的燈光的亮度和當(dāng)前的質(zhì)量設(shè)置( Quality Settings)在運(yùn)行時確定。
  •     Important 重要
    This light is always rendered at per-pixel quality. Use this for very important effects only (e.g. headlights of a player's car).
    燈光是逐個像素渲染。只用在一些非常重要的效果(比如玩家的車的車頭燈)。
  •     Not Important 不重要
    This light is always rendered in a faster, vertex/object light mode.
    燈光總是以最快的速度渲染。頂點/對象光模式
  • Culling Mask 消隱遮罩
    Use to selectively exclude groups of objects from being affected by the light; see Layers.
    有選擇地使組對象不受光的效果影響;請看層(Layers.)。
  • Lightmapping 光照貼圖
    The Lightmapping mode: RealtimeOnly, Auto or BakedOnly; see the Dual Lightmaps description.
    光照貼圖的模式:僅燈光實時計算(RealtimeOnly), 自動(Auto) or 僅烘焙( BakedOnly) 請看雙光照貼圖(Dual Lightmaps )
Details 細(xì)節(jié)

There are three basic light types in Unity. Each type can be customized to fit your needs.

在Unity中光有三種基本類型。各類型可以定制,以滿足您的需要。

You can create a texture that contains an alpha channel and assign it to the Cookie variable of the light. The Cookie will be projected from the light. The Cookie's alpha mask modulates the light amount, creating light and dark spots on surfaces. They are a great way af adding lots of complexity or atmosphere to a scene.

你可以創(chuàng)建一個包含alpha通道的紋理,并將其賦予光線的Cookie變量。Cookie會被光線投影。cookie的Alpha遮罩調(diào)節(jié)光量,可以在表面產(chǎn)生亮點和黑點。他們是往場景加入大量復(fù)雜的東西或氣氛的一種很好的方法。

All built-in shaders in Unity seamlessly work with any type of light. VertexLit shaders cannot display Cookies or Shadows, however.

Unity里所有的內(nèi)置的著色器(built-in shaders)全都可用于任何類型的燈光。然而,VertexLit 著色器不能顯示Cookies或者陰影。

In Unity Pro with a build target of webplayer or standalone, all Lights can optionally cast Shadows. This is done by selecting either Hard Shadows or Soft Shadows for the Shadow Type property of each individual Light. For more information about shadows, please read the Shadows page.

在Unity專業(yè)版,編譯目標(biāo)為網(wǎng)頁版或單機(jī)版,所有的燈光可以選擇性地投射陰影(Shadows)。這是通過選擇每個燈光陰影類型( Shadow Type)屬性為"硬陰影或軟陰影來完成的。更多關(guān)于陰影的信息,請閱讀陰影(Shadows )頁。

Point Lights 點光源

Point Lights 點光源

Point lights shine out from a point in all directions. They are the most common lights in computer games - typically used for explosions, light bulbs, etc. They have an average cost on the graphics processor (though point light shadows are the most expensive).

點光源光線在某一點從各個方向發(fā)射。它們是電腦游戲中最常用的燈光——通常用于爆炸、燈泡、等。他們有一個圖形處理器的平均成本(雖然點光源陰影是最昂貴的---最耗費(fèi)資源的)。

Point Lights 點光源
Point Light 點光源

Point lights can have cookies - Cubemap texture with alpha channel. This Cubemap gets projected out in all directions.

點光源可以有cookies – 帶有 alpha通道的立方圖(Cubemap )紋理。立方圖 (Cubemap)可在各個方向得出投影。

Point Light with a Cookie 帶有Cookie的點光源
Point Light with a Cookie 帶有Cookie的點光源

Spot Lights 聚光燈

Spot Lights 聚光燈

Spot lights only shine in one direction, in a cone. They are perfect for flashlights, car headlights or lamp posts. They are the most expensive on the graphics processor.

聚光燈只在一個方向上,在一個圓錐體范圍發(fā)射光線。它們用作手電筒真是完美,汽車的車頭燈或者燈柱。它們在圖形處理器上是最耗費(fèi)資源的。

Spot Lights 聚光燈
Spot Light 聚光燈

Spot lights can also have cookies - a texture projected down the cone of the light. This is good for creating an effect of light shining through the window. It is very important that the texture is black at the edges, has Border Mipmaps option on and its wrapping mode is set to Clamp. For more info on this, see Textures.

聚光燈同樣也可以帶有cookies - 這可以很好地創(chuàng)建光芒透過窗戶的效果。紋理的邊緣是黑色的,打開邊框多層紋理(Border Mipmaps )選項和它的循環(huán)模式(wrapping mode)設(shè)置為強(qiáng)制拉伸(Clamp),這是非常重要的。想要得到更多關(guān)于這方面的信息,參見紋理(Textures.)

Spot Light with a Cookie 帶有Cookie的聚光燈
Spot Light with a Cookie 帶有Cookie的聚光燈

Directional Lights 方向光源

Directional Lights 方向光源

Directional lights are used mainly in outdoor scenes for sun & moonlight. The light affect all surfaces of objects in your scene. They are the least expensive on the graphics processor. Shadows from directional lights (for platforms that support shadows) are explained in depth on this page.

方向光主要用于模擬在室外場景的陽光與月光。方向光影響你的場景中的對象的所有表面。 他們在圖形處理器中是最不耗費(fèi)資源的。方向光產(chǎn)生的陰影(因為平臺支持陰影)標(biāo)識著在此頁(this page)上的深度。

Directional Lights 方向光源
Directional Light 方向光源

When directional light has a cookie, it is projected down the center of the light's Z axis. The size of the cookie is controlled with Cookie Size property. Set the cookie texture's wrapping mode to Repeat in the Inspector.

當(dāng)平行光有一個cookie,它是預(yù)測光的Z軸的中心。cookie大小由cookie的大小(Cookie Size)屬性控制。在檢視面板設(shè)置cookie貼圖的循環(huán)模式(wrapping mode)為重復(fù)(Repeat)

方向光投影一個云狀的cookie紋理
Directional Light projecting a cloud-like cookie texture
方向光投影一個云狀的cookie紋理

A cookie is a great way to add some quick detail to large outdoor scenes. You can even slide the light slowly over the scene to give the impression of moving clouds.

Cookie是在大型戶外場景中快速添加細(xì)節(jié)的好方法。你甚至可以將的燈光在場景中慢慢移動,給人的感覺就像云在動。

Performance considerations 性能考慮

Lights can be rendered in one of two methods: vertex lighting and pixel lighting. Vertex lighting only calculates the lighting at the vertices of the game models and interpolates the lighting over the surfaces of the models. Pixel lights are calculated at every screen pixel, and hence are much more expensive. Some older graphics cards only support vertex lighting.

燈光有兩種渲染方式:頂點(vertex )光照和像素(pixel )光照。頂點光照只計算游戲模型的頂點照明和通過插值計算得出模型表面所有光線。燈光在屏幕每一個像素計算,因此很奢侈(耗費(fèi)資源)。一些舊的顯卡只支持頂點光照。

While pixel lighting is slower to render, it does allow some effects that are not possible with vertex lighting. Normal-mapping, light cookies and realtime shadows are only rendered for pixel lights. Spotlight shapes and Point light highlights are much better when rendered in pixel mode as well. The three light types above would look like this when rendered in vertex light mode:

像素光照渲染得慢,但它能夠?qū)崿F(xiàn)一些頂點光照不能實現(xiàn)的效果。正規(guī)映射(Normal-mapping),燈光cookies(light cookies) 和實時陰影(realtime shadows)只能由像素光照渲染。在像素光照模式下,聚光燈的形狀和點光源亮點效果更好。當(dāng)在頂點光照模式下渲染,以上三種光照類型的效果就像這樣:

Performance considerations 性能考慮
Point light in Vertex lighting mode. 在頂點光照模式下的點光源

Performance considerations 性能考慮
Spot light in Vertex lighting mode. 在頂點光照模式下的聚光燈

Performance considerations 性能考慮
Directional light in Vertex lighting mode. 在頂點光照模式下的方向光

Lights have a big impact on rendering speed - therefore a tradeoff has to be made betwen lighting quality and game speed. Since pixel lights are much more expensive than vertex lights, Unity will only render the brightest lights at per-pixel quality. The actual number of pixel lights can be set in the Quality Settings for webplayer and standalone build targets.

燈光有對渲染速度有非常大的影響——因此必須權(quán)衡前后照明質(zhì)量和游戲速度。由于像素光照比頂點光照奢侈得多(更耗費(fèi)資源),Unity將只在最亮的光逐個像素渲染。網(wǎng)頁版(webplayer)和單機(jī)版(standalone)編譯目標(biāo)中,像素?zé)舻膶嶋H數(shù)量可以質(zhì)量設(shè)置( Quality Settings )進(jìn)行設(shè)置。

You can explicitly control if a light should be rendered as a vertex or pixel light using the Render Mode property. By default Unity will classify the light automatically based on how much the object is affected by the light.

光線以頂點光照或像素光照模式渲染。你可以通過渲染模式屬性(Render Mode property)顯式控制。默認(rèn)情況下,Unity根據(jù)對象受到光影響的多少自動對光進(jìn)行歸類。

The actual lights that are rendered as pixel lights are determined on an object-by-object case. This means:

實際燈光被渲染在object-by-object的情況下確定作為像素光渲染。這句話的意思是:

  • Huge objects with bright lights could use all the pixel lights (depending on the quality settings). If the player is far from these, nearby lights will be rendered as vertex lights. Therefore, it is better to split huge objects up in a couple of small ones.
    帶有明亮燈光的巨大物體,可以全用像素光照(根據(jù)質(zhì)量設(shè)置)。如果玩家非常遠(yuǎn),附近的燈光可以用頂點光照模式渲染。因此,巨大的物體應(yīng)分割成幾個小的物體這樣更好。

See Optimizing Graphics performance on Desktop, iOS or Android page for more information.

在 臺式機(jī)(Desktop),iOS 或Android 頁面參見優(yōu)化圖形性能(Optimizing Graphics performance),獲取更多信息。

Creating Cookies

For more information on creating cookies, please see the tutorial on how to create a Spot light cookie.

創(chuàng)建的Cookie的更多信息,請參閱關(guān)于如何創(chuàng)建一個射燈cookie的教程( tutorial on how to create a Spot light cookie)

Hints 提示
  • Spot lights with cookies can be extremely effective for making light coming in from windows.
    帶cookies的聚光燈可以很有效的制作出光線從窗戶射進(jìn)來的效果。
  • Low-intensity point lights are good for providing depth to a scene.
    低強(qiáng)度點光源帶來場景深度。
  • For maximum performance, use a VertexLit shader. This shader only does per-vertex lighting, giving a much higher throughput on low-end cards.
    為了獲得最佳性能,使用VertexLit 著色。這個著色器(shader)只進(jìn)行頂點光照,在低端卡提供高得多的吞吐量。

贊0 踩0

未知用戶

2005-2025 朱峰社區(qū) 版權(quán)所有 遼ICP備2021001865號-1
2005-2025 ZhuFeng Community All Rights Reserved

VIP

朱峰社區(qū)微信公眾號

回頂部

1.復(fù)制文本發(fā)給您的QQ好友或群、微信等;好友點擊鏈接以后,轉(zhuǎn)發(fā)就成功了。 2.如朋友點擊您的鏈接,您需要需刷新一下才行;同一個好友僅能點擊一次。
購買VIP,觀看所有收費(fèi)教程!!