-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDepthTest.cs
More file actions
30 lines (25 loc) · 844 Bytes
/
DepthTest.cs
File metadata and controls
30 lines (25 loc) · 844 Bytes
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;
[ExecuteInEditMode]
public class DepthTest : MonoBehaviour {
#region [Variables]
public Shader depthTestShader;
[Range(0,1)]
public float depthAmount = 2.0f;
public Texture2D fogColor;
public Material curMaterial;
#endregion
private void Start()
{
Camera.main.depthTextureMode = DepthTextureMode.Depth;
}
// Use this for initialization
void OnRenderImage (RenderTexture sourceTexture, RenderTexture destTexture) {
if (depthTestShader != null)
{
curMaterial.SetTexture("_FogTex", fogColor);
curMaterial.SetFloat("_DepthPower", depthAmount);
Graphics.Blit(sourceTexture, destTexture, curMaterial);
}
else Graphics.Blit(sourceTexture, destTexture);
}
}