-
Notifications
You must be signed in to change notification settings - Fork 8
/
WaterBase.cs
62 lines (56 loc) · 1.14 KB
/
WaterBase.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System;
using UnityEngine;
[ExecuteInEditMode]
public class WaterBase : MonoBehaviour
{
public void UpdateShader()
{
if (this.waterQuality > WaterQuality.Medium)
{
this.sharedMaterial.shader.maximumLOD = 501;
}
else if (this.waterQuality > WaterQuality.Low)
{
this.sharedMaterial.shader.maximumLOD = 301;
}
else
{
this.sharedMaterial.shader.maximumLOD = 201;
}
if (!SystemInfo.SupportsRenderTextureFormat(1))
{
this.edgeBlend = false;
}
if (this.edgeBlend)
{
Shader.EnableKeyword("WATER_EDGEBLEND_ON");
Shader.DisableKeyword("WATER_EDGEBLEND_OFF");
if (Camera.main)
{
Camera.main.depthTextureMode |= 1;
}
}
else
{
Shader.EnableKeyword("WATER_EDGEBLEND_OFF");
Shader.DisableKeyword("WATER_EDGEBLEND_ON");
}
}
public void WaterTileBeingRendered(Transform tr, Camera currentCam)
{
if (currentCam && this.edgeBlend)
{
currentCam.depthTextureMode |= 1;
}
}
public void Update()
{
if (this.sharedMaterial)
{
this.UpdateShader();
}
}
public Material sharedMaterial;
public WaterQuality waterQuality = WaterQuality.High;
public bool edgeBlend = true;
}