blob: 0c1a6b1217a1baad8ce78bd326b3f4abb68af479 (
plain)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
using System;
using UnityEngine;
namespace XMainClient
{
public class ShadowMapInfo
{
private const int m_shadowMapWidth = 512;
private const int m_shadowMapHeight = 512;
public RenderTexture shadowMap = null;
public const int RChannel = 1;
public const int GChannel = 2;
public const int BChannel = 4;
public const int AChannel = 8;
public const int EmpytChannel = 0;
private int m_shadowChannelState = 0;
private static bool hasShadowMap = false;
public void CreateShadowMap()
{
this.shadowMap = new RenderTexture(512, 512, 0,(RenderTextureFormat)16, 0);
this.shadowMap.name = "ShadowMap";
this.shadowMap.autoGenerateMips = false;
this.shadowMap.Create();
Shader.SetGlobalTexture("_CustomShadowMapTexture", this.shadowMap);
Shader.SetGlobalFloat("shadowScale", XCustomShadow.scale);
ShadowMapInfo.hasShadowMap = true;
ShadowMapInfo.EnableShadow(true);
}
public void DestroyShadowMap()
{
bool flag = this.shadowMap != null;
if (flag)
{
this.shadowMap.Release();
this.shadowMap = null;
ShadowMapInfo.hasShadowMap = false;
}
}
public static void ClearShadowRes()
{
Shader.SetGlobalTexture("_CustomShadowMapTexture", null);
ShadowMapInfo.EnableShadow(false);
}
public static void EnableShadow(bool enable)
{
bool flag = enable && ShadowMapInfo.hasShadowMap;
if (flag)
{
Shader.EnableKeyword("CUSTOM_SHADOW_ON");
}
else
{
Shader.DisableKeyword("CUSTOM_SHADOW_ON");
}
}
public int AllocChannel()
{
bool flag = (this.m_shadowChannelState & 1) == 0;
int result;
if (flag)
{
this.m_shadowChannelState |= 1;
result = 1;
}
else
{
bool flag2 = (this.m_shadowChannelState & 2) == 0;
if (flag2)
{
this.m_shadowChannelState |= 2;
result = 2;
}
else
{
bool flag3 = (this.m_shadowChannelState & 4) == 0;
if (flag3)
{
this.m_shadowChannelState |= 4;
result = 4;
}
else
{
bool flag4 = (this.m_shadowChannelState & 8) == 0;
if (flag4)
{
this.m_shadowChannelState |= 8;
result = 8;
}
else
{
result = 0;
}
}
}
}
return result;
}
public void FreeChannel(int channle)
{
this.m_shadowChannelState &= ~channle;
}
public void Clear()
{
this.m_shadowChannelState = 0;
this.DestroyShadowMap();
}
}
}
|