以下均为来自中国大学mooc 游戏引擎原理及应用时的学习笔记,不含商用,仅供学习交流使用,如果侵权请联系作者删除。
文章目录
- 4.1 视频播放
- 4.2 粒子系统
- 4.3 后处理效果
4.1 视频播放
首先将摄像机调整成如图所示
然后调整为平行投影然后给plane添加一个组件 video player
然后接下来把视频文件拖拽到video player的video clip下 就可以播放了
如果我们想通过空格键来控制是否播放 我们可以这样:
插入以下代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
public class VideoControl : MonoBehaviour
{
VideoPlayer vp;
// Start is called before the first frame update
void Start()
{
vp = GetComponent<VideoPlayer>();
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
if (vp.isPlaying)//注意 isplaying是个成员变量
{
vp.Pause();
}
else
{
vp.Play();
}
}
}
}
这个选项是一开始的时候就进行播放的选项
4.2 粒子系统
新建一个粒子
然后新建一个材质,并将着色器选为Particles的v
选择这个
然后设置这个
由于火焰是8行4列 所以进行如图所示的设置
cycles指的是粒子的生命周期 动画序列的重复次数我们设置为3
每秒发散出多少粒子
这个火焰不需要特定的形状 因此把shape取消选中
lifetime是指生存时间 将生存时间随机可以更好的模拟火焰
这个火焰从无到有再到无:在color over lifetime里面实现
这个billboard也会影响火焰的形状火焰模拟完了之后 接下来为他创建一个子物体粒子系统
名为smoke
然后创造一个材质
选中摄像机然后按ctrl+shift+f便可以使摄像头对齐然后我们调整这个参数 可以调整产生的烟雾的多少
还可以调整烟雾的形状
上面调整透明的变化
下面调整颜色的变化多个粒子出现在一起时候的出现顺序
sorting fudge指的是如果这个粒子系统跟其他带有透明通道的物体有重叠关系的话,绘制的前后顺序,越低的值代表粒子系统越有可能低于其他物体的前面我们希望这个烟雾随着时间的增长 烟雾的大小会越来越大:
duration是粒子系统一个循环的时长,lifetime是单个粒子持续时长
4.3 后处理效果
右边的这个图渲染出了一个懒洋洋的效果