本篇把 VFX 功能点映射到工程里现成的示例资源,给出「在哪个场景打开、应该看到什么」,供社区工程师照表逐项验收:打开示例运行,对照「预期效果」核对是否一致。
路径均相对工程根 LayaVFXSample/。示例 .vfx 大多在 assets/resources/ 下;*_Converted 后缀为 Unity 转换版。
- 打开对应场景(
assets/scenes/*.ls)或直接双击 .vfx 在 VFX Graph 面板预览。
- 运行,观察粒子表现。
- 对照「预期效果」一栏核对:形态、颜色、运动、数量级是否一致。
- 不一致 → 记录现象,结合 Context/Block/Operator 的参数说明排查。
主要演示场景:
assets/scenes/LearningTemplates.ls —— 学习模板集合(LearningTemplates/vfx/ 下示例)
assets/scenes/Scene.ls —— VfxSample 系列功能示例
assets/scenes/SDFScene.ls —— SDF 碰撞/吸附
assets/scenes/CollisionDepthBufferScene.ls —— 深度缓冲碰撞
| 功能点 | 示例 | 预期效果 | 文档 |
|---|
| Constant Rate | VfxGraph.vfx | 每秒稳定冒出固定数量粒子 | Spawn |
| Single Burst | VfxSample_Burst.vfx | 一次性爆发一团粒子后停止 | Spawn |
| Loop Burst | VfxSample_LoopBurst.vfx | 周期性反复爆发 | 同上 |
| Fountain(连续喷射) | VfxSample_Fountain.vfx | 持续喷泉状粒子流 | 同上 |
| PreWarm(预热) | VfxSample_PreWarm.vfx | 场景一加载粒子就已是「演过一段」的状态 | 图级属性 |
| Spawn Over Distance | VfxSample_SpawnOverDistance.vfx | 发射器移动才生成粒子(足迹/拖尾) | Spawn |
| Custom Spawner(脚本驱动) | LearningTemplates/vfx/CustomSpawnerTest.vfx + src/CustomSpawnerDemo.ts | 点击屏幕喷一团 30 颗,无点击 0 颗 | CustomSpawn |
| Capacity(容量上限) | LearningTemplates/vfx/CapacityCount.vfx | 活粒子数被 Capacity 限制不再增长 | Initialize |
| 功能点 | 示例 | 预期效果 | 文档 |
|---|
| Set Position (Plane) | LearningTemplates/vfx/SetPositionPlaneTest.vfx | 粒子在平面区域内随机分布 | Position |
| Position Sequential | VfxSample_PositionSequential.vfx | 粒子按序列排成线/圆/阵列 | Position |
| Set Position (Mesh) Surface | LearningTemplates/vfx/SetPositionMeshSurfaceTest.vfx | 粒子贴附网格表面 | Position |
| Set Position (Mesh) Volume | LearningTemplates/vfx/SetPositionMeshVolumeTest.vfx | 粒子填满网格体内 | 同上 |
| Position SDF | LearningTemplates/vfx/PositionSDF.vfx | 粒子分布在 SDF 表面/体内 | Position |
| 功能点 | 示例 | 预期效果 | 文档 |
|---|
| Orient Face Camera | LearningTemplates/vfx/OrientFaceCamera.vfx | 面片始终朝向相机 | Orient |
| Orient Fixed Axis | LearningTemplates/vfx/OrientFixedAxis.vfx | 面片绕固定轴朝向 | 同上 |
| Pivot Attribute | LearningTemplates/vfx/PivotAttribute.vfx | 粒子绕自定义轴心旋转/缩放 | getAttribute |
| Rotation Angle | LearningTemplates/vfx/RotationAngle.vfx | 粒子按角度自转 | Attribute |
| Box Rotation | VfxSample_BoxRotation.vfx | mesh 粒子持续旋转 | 同上 |
| Connect Target | VfxSample_ConnectTarget.vfx | 粒子拉伸连接到目标点(链状) | Output |
| 功能点 | 示例 | 预期效果 | 文档 |
|---|
| Attractor(引力) | VfxSample_Attractor.vfx / LearningTemplates/vfx/AttractorAABoxTest.vfx | 粒子被吸向中心/区域 | Force |
| Turbulence(湍流) | VfxSample_Turbulence.vfx | 粒子受噪声扰动飘动 | Force |
| Vector Field(矢量场) | VfxSample_VectorField.vfx | 粒子沿 3D 矢量场流动 | Force |
| Conform To Sphere | VfxSample_ConformToSphere.vfx | 粒子吸附到球面 | Force |
| Conform To AABox/OrientedBox/Cone | LearningTemplates/vfx/ConformTo{AABox,OrientedBox,Cone}Test.vfx | 粒子吸附到对应形状 | 同上 |
| Conform To SDF | LearningTemplates/vfx/ConformToSDF.vfx(SDFScene.ls) | 粒子吸附到 SDF 形状表面 | 同上 |
| Calculate Mass From Volume | LearningTemplates/vfx/CalculateMassFromVolumeTest.vfx | 按体积算质量影响受力 | Attribute |
| 功能点 | 示例 | 预期效果 | 文档 |
|---|
| Collision Simple | VfxSample_Collision.vfx / LearningTemplates/vfx/CollisionSimple.vfx | 粒子撞平面/球反弹 | Collision |
| Collision OrientedBox / Torus | LearningTemplates/vfx/Collision{OrientedBox,Torus}Test.vfx | 粒子与对应形状碰撞 | 同上 |
| Collision SDF | LearningTemplates/vfx/CollisionSDF.vfx(SDFScene.ls) | 粒子与 SDF 形状碰撞 | 同上 |
| Collision Depth Buffer | VfxSample_CollisionDepthBuffer.vfx(CollisionDepthBufferScene.ls) | 粒子与屏幕深度(场景几何)碰撞 | 同上 |
| Kill Plane/Cone/Torus/OrientedBox/Baseline | LearningTemplates/vfx/Kill{Plane,Cone,Torus,OrientedBox,Baseline}Test.vfx | 进入对应区域的粒子立即消失 | Kill |
| 功能点 | 示例 | 预期效果 | 文档 |
|---|
| Billboard | VfxSample_Billboard.vfx / LearningTemplates/vfx/BillboardPrimitive.vfx | 朝相机面片贴图 | Billboard |
| Output Mesh / Cube | VfxSample_OutputMesh.vfx / LearningTemplates/vfx/CubeOutput.vfx | 粒子显示为网格/立方体 | Mesh |
| Output Point | VfxSample_OutputPoint.vfx | 粒子显示为点(点云) | Point |
| Output Line / LineStrip | VfxSample_OutputLine.vfx / LearningTemplates/vfx/LineStripOutput.vfx | 线段 / 连续折线 | Line |
| Output Distortion | LearningTemplates/vfx/DistortionTest.vfx | 屏幕热浪/扭曲(需相机 opaqueTexture) | Distortion |
| Output ShaderGraph (Quad/Strip) | VfxSample_ShaderGraphQuad.vfx / VfxSample_StripSGQuad.vfx | 自定义 shader 着色的粒子/拖尾 | ShaderGraph |
| Output Static Mesh | LearningTemplates/vfx/StaticMeshOutputTest.vfx / StaticMeshBindingTest.vfx + src/StaticMeshBindingDemo.ts | 静态网格由 graph/代码驱动 transform/color | StaticMesh |
| Multiple Outputs | VfxSample_MultiOutput.vfx / LearningTemplates/vfx/ComposedOutputTest.vfx | 一个系统多种渲染叠加 | Output 总览 |
| Soft Particle | VfxSample_SoftParticleShowcase.vfx | 与场景相交处柔化淡出 | 公共参数 |
| Screen Space Size | VfxSample_ScreenSpaceSize.vfx | 粒子保持固定屏幕像素大小 | Output |
| Subpixel AA | VfxSample_SubpixelAA.vfx | 极小粒子抗锯齿更平滑 | 同上 |
| Camera Fade | VfxSample_CameraFade.vfx | 靠近/远离相机时淡出 | 同上 |
| 功能点 | 示例 | 预期效果 | 文档 |
|---|
| Color over Life | LearningTemplates/vfx/ColorizeTest.vfx | 粒子颜色随寿命渐变 | Output |
| Gradient Property | VfxSample_GradientProperty.vfx / LearningTemplates/vfx/InlineGradientTest.vfx | 用渐变控制颜色 | sampleGradient |
| Flipbook Mode | LearningTemplates/vfx/FlipbookMode.vfx | 序列帧动画硬切播放 | 公共参数 UV Mode |
| Flipbook Blend | VfxSample_FlipbookBlend.vfx | 序列帧帧间平滑混合 | 同上 |
| Tile/Warp | VfxSample_TileWarp.vfx | 粒子超出范围环绕回另一侧 | Position |
| 功能点 | 示例 | 预期效果 | 文档 |
|---|
| Sample Texture2D | LearningTemplates/vfx/SampleTexture2D.vfx | 用纹理采样驱动粒子属性 | 纹理采样 |
| Sample Mesh(位置/法线/UV/色/切线) | LearningTemplates/vfx/SampleMesh{Position,Normal,UV,Color,Tangent}Test.vfx | 粒子按网格对应属性采样 | 网格采样 |
| Sample Skinned Mesh | LearningTemplates/vfx/SampleSkinnedMeshTest.vfx + src/SampleSkinnedMeshDemo.ts | 粒子贴在骨骼动画角色表面随动 | SkinnedMesh |
| Sample Point Cache | LearningTemplates/vfx/SamplePointCacheTest.vfx / VfxSample_MeshPointCache.vfx | 粒子按点云数据分布 | 点云 |
| Worley Noise | LearningTemplates/vfx/WorleyNoiseTest.vfx | cellular 噪声驱动 | 噪声 |
| Custom GLSL | LearningTemplates/vfx/CustomGlslTest.vfx / CustomGlslBlockTest.vfx | 用户 GLSL 代码控制粒子 | Custom / Custom |
| Graphics Buffer | VfxSample_GraphicsBuffer.vfx + src/GraphicsBufferDemo.ts | 外部 GPU buffer 数据驱动粒子 | setBuffer |
| Change Space / Gamma-Linear | LearningTemplates/vfx/ChangeSpaceTest.vfx / GammaLinearTest.vfx | 坐标空间/色彩空间转换 | Math/Vector / Color |
| 功能点 | 示例 | 预期效果 | 文档 |
|---|
| Trail(简单拖尾) | VfxSample_Trail.vfx | 粒子拖出连续尾迹 | Trail |
| Head And Trail | VfxSample_HeadAndTrail.vfx | 头部粒子 + 跟随拖尾 | 同上 |
| Fountain Trail / Multi Trail | VfxSample_FountainTrail.vfx / VfxSample_MultiTrail.vfx | 喷泉拖尾 / 多条拖尾 | 同上 |
| Strip Spawn Rate | LearningTemplates/vfx/StripSpawnRate.vfx | 按速率生成的 strip 流动 | 同上 |
| Multi Strip(SingleBurst/SpawnRate/PeriodicBurst) | LearningTemplates/vfx/MultiStrip*_Converted.vfx | 多条 strip 不同生成模式 | 同上 |
| Ratio Over Strip | LearningTemplates/vfx/RatioOverStripTest.vfx | 属性沿 strip 位置渐变 | ratioOverStrip |
| 功能点 | 示例 | 预期效果 | 文档 |
|---|
| Trigger Event(OnDie 链式) | VfxSample_Firework.vfx | 主弹粒子死亡时炸开二级粒子(烟花) | GPUEvent |
| Trigger Event on Shape Enter | VfxSample_TriggerEventShape.vfx | 粒子进入形状时触发新粒子 | 同上 |
| Trigger Event Collide | LearningTemplates/vfx/TriggerEventCollide_Converted.vfx | 碰撞时触发事件 | 同上 |
| GPU Event 多 strip 链 | LearningTemplates/subvfx/MultiStripGPUEvents/T*.vfx | GPU 事件驱动多 strip 链式生成 | 同上 |
| Output Event(CPU 回调) | LearningTemplates/vfx/OutputEventTest.vfx + src/OutputEventDemo.ts | 粒子事件回调到 CPU(控制台打印) | OutputEvent |
assets/resources/univfx/ 下有大量成品游戏特效,适合作为「综合效果」参考验收(不逐参数,看整体观感是否与 Unity 一致):
| 系列 | 路径 | 内容 |
|---|
| Essentials Visual Effects | univfx/Essentials/... | 光环 / 屏障 / Buff / 爆炸 / 治疗 / 跳跃 / 近战 / 导弹 / 拾取 / 传送 |
| Dissolve & Teleport | univfx/Dissolve & Teleport/... | 溶解(突发/能量/烟雾/线条/图案)/ 传送门 / 虫洞(含 SkinnedMesh 版) |
| AuraDebug (VFX1~14) | univfx/Essentials/Prefabs/AuraDebug/ | 光环类逐步调试版本 |
VFX Graph 教学文档集到此完整(00~07)。