一个粒子系统可以模拟并渲染许多称为粒子的小图像或网格以产生视觉效果。系统中的每个粒子代表效果中的单个图形元素。系统共同模拟每个粒子以产生完整效果的印象。
Particle systems are useful when you want to create dynamic objects like fire, smoke, or liquids, because it is difficult to depict this kind of object with a Mesh (3D) or Sprite (2D). Meshes and Sprites are better at depicting solid objects such as a house or a car.
为了在创作粒子系统时提供灵活性,Unity 提供两种解决方案来供您选择。如果项目的目标平台支持计算着色器,Unity 允许同时使用这两种解决方案。这两种粒子系统解决方案为:
The following table shows a high-level comparison of the two particle system solutions. For more information about either solution, see Built-in Particle System or Visual Effect Graph.
功能 | 内置粒子系统 | Visual Effect Graph |
---|---|---|
渲染管线兼容性 | 内置渲染管线、通用渲染管线、高清渲染管线 | 通用渲染管线、高清渲染管线 |
可实现的粒子数 | 数千 | 数百万 |
粒子系统创作 | 简单模块创作过程,使用 Inspector 中的粒子系统 (Particle System) 组件。每个模块代表粒子的一种预定义行为。 | 可高度定制的创作过程,使用图形视图。 |
物理 | 粒子可与 Unity 的基础物理系统进行交互。 | 粒子可与 Visual Effect Graph 中定义的特定元素进行交互。例如,粒子可与深度缓冲区进行交互。 |
脚本交互 | 可以使用 C# 脚本在运行时对粒子系统进行全面自定义。可以对系统中的每个粒子进行读取和写入操作,还可以响应碰撞事件。粒子系统组件还提供播放控制 API。这意味着可以使用脚本来播放和暂停粒子效果,并使用自定义步长来模拟粒子效果。 | 可以公开图形属性,并通过 C# 脚本访问这些属性,从而对效果实例进行自定义。还可以使用事件接口来发送自定义事件以及可由图形处理的附加数据。视觉效果 (Visual Effect) 组件还提供播放控制 API。这意味着可以使用脚本来播放和暂停粒子效果,并使用自定义步长来模拟粒子效果。 |
帧缓冲区 | 无 | 在高清渲染管线中,提供对颜色和深度缓冲区的访问权。例如,可以对颜色缓冲区进行采样并使用结果来设置粒子颜色,也可以使用深度缓冲区来模拟碰撞。 |
Unity 的内置粒子系统可用于为 Unity 支持的每个平台创建粒子效果。内置粒子系统在 CPU 上模拟粒子行为,这种技术具有以下主要优点:
有关如何使用内置粒子系统的更多信息,请参阅粒子系统组件。
Visual Effect Graph 是一个可用于为 Unity 项目创建大规模视觉效果的包。Visual Effect Graph 利用 GPU 模拟粒子行为,可模拟的粒子数量远远超过内置粒子系统。如果要创建包含大量粒子的视觉效果并且需要高度可自定义的行为,请使用 Visual Effect Graph 而不是内置粒子系统。有关安装和使用 Visual Effect Graph 的信息,请参阅入门指南。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.