Version: 2022.3
Decals and projectors
Lens flares and halos

Projector component

Use a Projector component to create effects such as:

  • Decal effects, like bullet holes or paint splatters
  • Blob shadows
  • Stylized lighting effects
  • The effect of a real-world projector, using another Camera that renders to a Render Texture

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

A Projector creates a Blob Shadow for a robot
A Projector creates a Blob Shadow for a robot

Using the Projector component

A Projector works by projecting a material onto all objects that intersect its frustum. The material must use the Projector/Light or Projector/Multiply shaders, available in Unity’s Standard Assets.

Material configuration

When configuring a material to use with the Projector/Light and Projector/Multiply shaders, be aware of the following:

剪影纹理:

  • 确保纹理包裹模式设置为“Clamp”
  • Turn on “Replicate Border” option in mipmap related import settings
  • 使用未压缩的纹理格式
  • Projector/Shadow 还要求存在 Alpha 通道(通常可以使用 Alpha from Grayscale 选项)

衰减纹理(如果存在):

  • 数据需要在 Alpha 通道中,因此通常为 Alpha8 纹理格式
  • 确保纹理包裹模式设置为“Clamp”
  • 确保最左边的像素列为黑色;并且“Border mipmaps”导入设置处于启用状态。

示例

标准资源 (Standard Assets) 包含的示例预制件演示了 Projector 组件的使用。

要使用预制件,请执行以下操作:

  1. 下载 Standard Assets
  2. StandardAssets > Effects > Projectors 导入到项目中
  3. 在 Project 窗口中,导航到 StandardAssets > Effects > Projectors > Prefabs
  4. 将一个预制件拖入场景中

可以按原样使用预制件,对预制件进行修改,或检查预制件的配置。

Projector Inspector reference

属性: 功能:
Near Clip Plane 近裁剪面前面的对象不会接收到投射。
Far Clip Plane 超出此距离的对象将不会收到投影。
Field Of View 以度为单位的视野。仅在 Projector 不采用正交视图 (Orthographic) 时使用。
Aspect Ratio 此属性可用于调整 Projector 的高度和宽度。
Orthographic 如果启用此属性,则 Projector 将采用正交视图 (Orthographic) 而不是透视图。
Orthographic Size 正交投影大小。仅在启用 Orthographic 时才使用。
Material 投射的材质。
Ignore Layers 在此处指定的层中的对象不会接收到投射。默认值为 None。

Projector

Decals and projectors
Lens flares and halos