-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathBokehBlur.cs
30 lines (25 loc) · 897 Bytes
/
BokehBlur.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using UnityEngine;
namespace Blur
{
public class BokehBlur:MonoBehaviour
{
private Material mat;
public float rotateDistance=1;
public int sampleCount=20;
public float radius=1;
private static readonly int RotateDistance = Shader.PropertyToID("_RotateDistance");
private static readonly int SampleCount = Shader.PropertyToID("_SampleCount");
private static readonly int Radius = Shader.PropertyToID("_Radius");
private void OnEnable()
{
mat = new Material(Shader.Find("LX/BokehBlur"));
}
private void OnRenderImage(RenderTexture src, RenderTexture dest)
{
mat.SetFloat(RotateDistance,rotateDistance);
mat.SetInt(SampleCount,sampleCount);
mat.SetFloat(Radius,radius);
Graphics.Blit(src,dest,mat);
}
}
}