当前位置: 代码迷 >> 综合 >> Unity 之 Visual Effect
  详细解决方案

Unity 之 Visual Effect

热度:101   发布时间:2023-11-21 16:35:16.0

Halo:耀斑,光晕

Halos用于在空气中留下小尘埃颗粒的印象。

Properties

Property: Function:
Color 光晕颜色
Size 光晕大小

Details

Y您可以添加光晕组件到一个Light object,然后设置它的大小和颜色属性,以提供所需的发光效果. 一个Light 也可以单独的设置光晕,在不添加hole组件的前提下,打开灯光的 Draw Halo 属性.但是这样不怎么灵活

Hints

  • 通过设置 Graphics 下的 Light Halo 选择自己的shader,来表现自定义的halo

A Light with a separate Halo Component

 

 

 

Lens Flare:镜头光晕

Lens Flares 模拟光线在镜头内的折射效果 它们用来代表亮光 ,只是为了给你的场景增加一点气氛
.

 最简单添加一个镜头光晕的方法就是打开Light的 光晕属性. Unity在标准资源包里包含了很多内置的光晕效果4

也可以给空物体添加flare组件,自定义个镜头挂光晕

Enable the Fx button to view Lens Flares in the Scene View

  通过上述按钮查看光晕效果

Properties

Property: Function:
Flare The Flare to render. 光斑定义了镜头光斑外观的所有方面
Color 一些耀斑可以着色,以更好地适应你的场景的情绪。
Brightness 镜头光晕的大小和亮度。
Fade Speed 耀斑消退的快慢。
Ignore Layers 选择不隐藏耀斑的遮罩层,。
Directional 如果设置,照明弹将沿着游戏对象的正Z轴方向.它会看起来好像无限远,不会跟踪对象的位置,只有Z轴的方向。

Details

添加flare组件能更精准的控制镜头光晕的表现

Camera摄像机必须有Flare Layer 组件才能看见镜头光晕,这是默认自带的,你不需要设置 (this is true by default, so you don’t have to do any set-up).

Hints

  • 谨慎使用镜头光斑。.
  • 如果你使用一个非常明亮的镜头光晕,确保它的方向适合你的场景的主要光源。.
  • 创建自己的 Flares,需要创建一些 Flare Assets,先模仿我们自带的光晕,再创建自己的
  • Lens Flares 可以被 Colliders 挡住

 

Flare

Flare是 Lens Flare组件里面的选项. The Flare 它本身结合了纹理文件和一些信息来表现flare.

有一些 Standard Assets package. 自带的flare
.

The Flare Inspector

Properties

Property: Function:
Elements 耀斑中包含的图像的数量
        Image Index 使用的哪个图片 See the Flare Textures section below for more information.
        Position The Element’s offset along a line running from the containing GameObject’s position through the screen center. 0 = GameObject position, 1 = screen center.
        Size The size of the element.
        Color Color tint of the element.
        Use Light Color If the Flare is attached to a Light, enabling this will tint the Flare with the Light’s color.
        Rotate If enabled, bottom of the Element will always face the center of the screen, making the Element spin as the Lens Flare moves around on the screen.
        Zoom If enabled, the Element will scale up when it becomes visible and scale down again when it isn’t.
        Fade If enabled, the Element will fade in to full strength when it becomes visible and fade out when it isn’t.
Flare Texture  Flare’s Elements使用的材质. It must be arranged according to one of the TextureLayout options.
Texture Layout How the individual Flare Element images are laid out inside the Flare Texture (see Texture Layouts below for furth

 

Line Renderer

Line Renderer组件在三维空间中获取一个由两个或多个点组成的数组,并在每个点之间绘制一条直线. Line Renderer 因此,一个单一的线渲染器组件可以用来绘制任何东西,从简单的直线到复杂的螺旋. 这条线总是连续的;如果你需要画两条或更多完全独立的线,你应该使用多个GameObjects,每个都有自己的线渲染器。

T线渲染器不会渲染一个像素宽的线,它渲染的线总是面向摄像机.

 

Properties

属性当中有很多一看就懂的,就不说了,重要的都用黑体加粗了

Property Function
Cast Shadows 是否投射阴影 See Renderer.shadowCastingMode in the Scripting API reference documentation to learn more.
Receive Shadows If enabled, the line receives shadows.
Motion Vectors Select the Motion Vector type to use for this Line Renderer. See Renderer.motionVectorGenerationMode in the Scripting API reference documentation to learn more.
Materials These properties describe an array of Materials used for rendering the line. The line will be drawn once for each material in the array.
Light Parameters 添加一个Lightmap Parameters 能够和 global illumination system.交互
Positions linerender中各个点的位置
Use World Space 如果启用,这些点将被视为世界空间坐标,而不受附加该组件的GameObject转换的约束。
Loop 使其能够连接该行的第一个和最后一个位置。这就形成了一个闭环
Width 宽度
Color 颜色.
Corner Vertices 此属性指示在绘制线条中的角时使用多少额外的顶点。增加这个值使线条角看起来更圆
End Cap Vertices 线结尾处应该用多少顶点来结束,点越多,越圆滑
Alignment  View :面向Camera
Local :面向自己Transform component
.
Texture Mode 控制纹理如何应用到线条上.  Stretch拉伸纹理覆盖整条线, Wrap 重复纹理覆盖整条线.  Tiling重叠的次数
Shadow Bias 隐形偏移,沿着光的方向移动阴影
Generate Lighting Data If enabled (the box is checked), the Line geometry is built with Normals and Tangents included. This allows it to use Materials that use the scene
lighting, for example via the Standard Shader
, or by using a custom shader
.
Sorting Layer Name of the Renderer’s sorting layer.
Order in Layer This Renderer’s order within a sorting layer.
Light Probes Probe-based lighting interpolation
mode.
Reflection Probes If enabled and reflection probes are present in the Scene, a reflection Texture is picked for this Line Renderer and set as a built-in Shader uniform variable.
  1. 对line render使用Particle Shader的Material.最好

Hints.

  • View:当你移动相机时,线条可能会出现旋转  Local :取消这个.
  • 线渲染器应该是游戏对象上唯一的渲染器。..

Line Renderer example setup

 

Trail Renderer:拖尾

Properties

Property: Function:
Cast Shadows Determines whether the trail casts shadows, whether they should be cast from one or both sides of the trail, or whether the trail should only cast shadows and not otherwise be drawn. See Renderer.shadowCastingMode in the Scripting API reference documentation to learn more.
Receive Shadows If enabled, the trail receives shadows.
Motion Vectors Select the Motion Vector type to use for this Trail Renderer. See Renderer.motionVectorGenerationMode in the Scripting API reference documentation to learn more.
Materials These properties describe an array of Materials used for rendering
the trail. Particle Shaders
work best for trails.
Lightmap Parameters Reference a Lightmap Parameters Asset here to enable the trail to interact with the global illumination system.
Time 拖尾的生命周期
Min Vertex Distance 拖尾的最小距离 (see Minimum vertex separation below).
AutoDestruct 过了生命周期是否自动销毁
Width Define a width value and a curve to control the width of your trail at various points between its start and end. The curve is applied from the beginning to the end of the trail, and sampled at each vertex. The overall width of the curve is controlled by the width value.
Color Define a gradient to control the color of the trail along its length.
Corner Vertices 此属性指示在路径中绘制角时使用多少额外的顶点。增加这个值使轨迹角看起来更圆
End Cap Vertices 线结尾处应该用多少顶点来结束,点越多,越圆滑
Alignment Set to View to make the Trail face the camera
, or Local to align it based on the orientation of its Transform component
.
Texture Mode Control how the Texture is applied to the Trail. Use Stretch to apply the Texture map along the entire length of the trail, or use Wrap to repeat the Texture along the length of the Trail. Use the Tiling parameters in the Material to control the repeat rate.
Generate Lighting Data When enabled, the trail geometry includes Normals and Tangents. This allows the trail to use Materials that use the scene lighting, for example via the Standard Shader
, or by using a custom shader.
Light Probes Probe-based lighting interpolation
mode.
Shadow Bias Move shadows along the direction of the light to remove shadowing artifacts caused by approximating a volume with billboarded geometry.
Sorting Layer Name of the Renderer’s sorting layer.
Order in Layer This Renderer’s order within a sorting layer.
Reflection Probes If enabled and reflection probes are present in the Scene, a reflection Texture is picked for this Trail Renderer and set as a built-in Shader uniform variable.

 

Billboard Renderer

 Billboard Renderer 渲染BillboardAssets, 要么是来自预先准备好的资产(比如 SpeedTree) or 来自自定义创建的文件 (例如,在运行时使用脚本或自定义编辑器创建).

Billboards are a level-of-detail (LOD) 用于在场景中较远的地方以更简单的方式绘制复杂的三维网格

Property: Function:
Cast Shadows If enabled, the billboard creates shadows when a shadow-casting Light shines on it.
     On Enable shadows.
     Off Disable shadows.
     Two Sided Allow shadows to be cast from either side of the billboard (that is, backface culling is not taken into account).
     Shadows Only Show shadows, but not the billboard itself.
Receive Shadows Check the box to enable shadows to be cast on the billboard.
Motion Vectors Check the box to enable rendering
of the billboard’s motion vectors into the Camera Motion Vector Texture. See Renderer.motionVectors in the Scripting API for more information.
Billboard 如果你有一个预先制作的Billboard Asset,把它放在这里分配给这个Billboard Renderer.。
Light Probes If enabled, and if baked Light Probes are present in the Scene, the Billboard Renderer uses an interpolated Light Probe for lighting.
     Off Disable Light Probes.
     Blend Probes The lighting applied to the billboard is interpreted from one interpolated Light Probe.
     Use Proxy Volume The lighting applied to the Billboard Renderer is interpreted from a 3D grid of interpolated Light Probes.
Reflection Probes If enabled, and if Reflection Probes are present in the Scene, a reflection Texture is picked for this GameObject
and set as a built-in Shader
uniform variable.
     Off Disable Reflection Probes.
     Blend Probes The reflections applied to the billboard are interpreted from adjacent Reflection Probes, and do not take the the skybox
into account. This is generally used for GameObjects that are “indoors” or in covered parts of the Scene (such as caves and tunnels), because the sky is not visible and therefore wouldn’t be reflected by the billboard.
     Blend Probes and Skybox This works like Blend Probes, but also allows the skybox to be used in the blending. This is generally used for GameObjects in the open air, where the sky would always be visible and reflected.
     Simple Reflection Probes are enabled, but no blending occurs between probes when there are two overlapping volumes.

 

Billboard Asset

 Billboard Asset 一个更复杂的网格的预渲染图像集合 Billboard Renderer,为了在和Camera一定距离 的时候渲染它,通过LOD技术

最常见的方式产生一个Billboard Asset是在SpeedTree Modeler中创建文件,然后将它们导入Unity。也可以创建自己的Billboard Asset从脚本. See the API reference for BillboardAsset for further details.

 

Projector

Switch to Scripting

 Projector 允许你把一个 Material 投射到它的截面体内,材质球的 shader必须是特殊声明的,能够为projecting正确工作的, standard assets有提供的shader/Light and Projector/Multiply shaders.

Properties

Property: Function:
Near Clip Plane 投影的近平面
Far Clip Plane 投影的原平面
Field Of View T视场的角度。这只在投影仪不是Ortho Graphic的情况下使用。.
Aspect Ratio The Aspect Ratio of the Projector. This allows you to tune the height vs width of the Projector.
Is Ortho Graphic If enabled, the Projector will be Ortho Graphic instead of perspective.
Ortho Graphic Size The Ortho Graphic size of the Projection. this is only used if Is Ortho Graphic is turned on.
Material The Material that will be Projected onto Objects.
Ignore Layers Objects that are in one of the Ignore Layers will not be affected. By default, Ignore Layers is none so all geometry that intersects the Projector frustum will be affected.

Details

通过 projector 你可以:

  1. 生成一个 shadows.
  2. Make a real world projector on a tripod with another Camera
    that films some other part of the world using a Render Texture
  3. Create bullet marks.
  4. Funky lighting effects.

Note: 创建一个projector时,确保使用的材质球的贴图的 wrap模式 为 clamp.否则投影仪的纹理会被重复看到,你将不会得到想要的阴影效果。

Hints

  • Projector Blob shadows可以创造非常令人印象深刻的分裂细胞般的灯光效果.
  • 当没有 Falloff Texture 时,可以创造非常令人印象深刻的分裂细胞般的灯光效果. 解决方法是使用一个只有透明通道的Falloff 贴图具有最左边黑色像素列的纹理。

 

 

 

  相关解决方案