Version: 2020.3
Lens flares and halos
Lens Flare component

Flare asset

A Flare asset allows you to create and configure the appearance of lens flares. Lens flares simulate the effect of lights refracting inside a camera lens. Use them to represent bright lights or to add a bit more atmosphere to your Scene.

Note: This workflow is compatible only with the Built-in Render Pipelne. For similar functionality in other render pipelines, see Lens flares and halos.

Using Flare assets

  1. Assign the Flare asset to a Light component or a Lens flare component.
    • If you assign it to the Flare property of a Light component, Unity automatically tracks the position and direction of the Light and uses those values to configure the appearance of the lens flare.
    • If you assign it to the Flare property of a Lens flare component, you can use the Lens Flare component to configure additional values for more precise control.
  2. If you want a Camera to see lens flares, attach a Flare Layer component to the Camera’s GameObject.
  3. To see the lens flare effect in the Scene View, enable the Effect toggle in the Scene View toolbar and, in the drop-down, enable Flares.

示例

There are some sample Flare assets in Unity’s Standard Assets.

Flare Inspector reference

光晕需要包含单个__纹理__上的多个光晕__元素。在光晕中,可从任何纹理选取要包含的__元素

光晕检视面板 (Flare Inspector)
光晕检视面板 (Flare Inspector)
属性: 功能:
Elements 光晕中包含的光晕图像数量。
        Image Index Flare Texture 为此元素使用哪个光晕图像。请参阅下面的_光晕纹理_部分以了解更多信息。
        Position 元素沿着从所属游戏对象的位置到屏幕中心的线路上的偏移量。0 = 游戏对象位置,1 = 屏幕中心。
        Size 元素的大小。
        Color 元素的颜色色调。
        Use Light Color 如果光晕附加在光源上,启用此功能会使用光源的颜色为光晕着色。
        Rotate 如果启用此属性,元素的底部将始终面向屏幕的中心,使元素随着镜头光晕在屏幕上移动而旋转。
        Zoom 如果启用此属性,元素将在可见时扩大,而在不可见时再次缩小。
        Fade 如果启用此属性,元素将在可见时淡入至最高强度,而在不可见时淡出。
Flare Texture 此纹理包含该光晕的__元素__使用的图像。必须根据 TextureLayout 选项之一进行排列。
Texture Layout 如何在__光晕纹理 (Flare Texture)__ 中布置各个光晕元素图像(有关详细信息,请参阅下面的_纹理布局_)。
Use Fog 如果启用此属性,光晕将伴随着距离雾效消失。此属性通常用于小光晕。

Configuring Flare assets

光晕由多个__元素__组成,沿着一条线排列。这条线是通过比较包含镜头光晕的游戏对象的位置与屏幕的中心来计算得出的。这条线会延伸到所属游戏对象和屏幕中心之外。所有光晕__元素__都在这条线上排成一行。

For performance reasons, all Elements of one Flare must share the same Texture. This Texture contains a collection of the different images that are available as Elements in a single Flare. The Texture Layout defines how the Elements are laid out in the Flare Texture. If you use many different Flare assets, using a shared single Flare Texture that contains all the Elements will give you best rendering performance.

Lens Flares are blocked by Colliders. A Collider in-between the Flare GameObject and the Camera will hide the Flare, even if the Collider does not have a Mesh Renderer. If the in-between Collider is marked as Trigger it will block the flare if and only if Physics.queriesHitTriggers is true.

To override the shader used for Flares, open the Graphics window and set Lens Flares to the shader that you would like to use as the override.

Texture Layouts

下面提供了不同光晕__纹理布局__的选项。图像中的数字对应于每个__元素__的 Image Index 属性。

1 大 4 小

专为类似于太阳的大型光晕而设计,这种情况下需要其中一个__元素__比其他元素具有更高的保真度。此布局适用于高度是宽度两倍的纹理。

1 大 2 中 8 小

专为需要 1 个高清图像、2 个中等大小图像和 8 个小图像的复杂光晕而设计。此布局用于标准资源“50mm Zoom Flare”(50mm 缩放光晕),其中有两个中等大小的元素表示彩虹色圆圈。此布局适用于高度是宽度两倍的纹理。

1 个纹理

单个图像。

2x2 网格

一个简单的 2x2 网格。

3x3 网格

一个简单的 3x3 网格。

4x4 网格

一个简单的 4x4 网格。

Lens flares and halos
Lens Flare component