-
Notifications
You must be signed in to change notification settings - Fork 115
/
PQSProjectionFallback.cs
executable file
·209 lines (176 loc) · 8.12 KB
/
PQSProjectionFallback.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
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
// Material wrapper generated by shader translator tool
using System;
using UnityEngine;
namespace Kopernicus
{
namespace MaterialWrapper
{
public class PQSProjectionFallback : Material
{
// Internal property ID tracking object
protected class Properties
{
// Return the shader for this wrapper
private const String shaderName = "Terrain/PQS/Sphere Projection SURFACE QUAD (Fallback) ";
public static Shader shader
{
get { return Shader.Find (shaderName); }
}
// Saturation, default = 1
public const String saturationKey = "_saturation";
public Int32 saturationID { get; private set; }
// Contrast, default = 1
public const String contrastKey = "_contrast";
public Int32 contrastID { get; private set; }
// Colour Unsaturation (A = Factor), default = (1,1,1,0)
public const String tintColorKey = "_tintColor";
public Int32 tintColorID { get; private set; }
// Near Tiling, default = 1000
public const String texTilingKey = "_texTiling";
public Int32 texTilingID { get; private set; }
// Near Blend, default = 0.5
public const String texPowerKey = "_texPower";
public Int32 texPowerID { get; private set; }
// Far Blend, default = 0.5
public const String multiPowerKey = "_multiPower";
public Int32 multiPowerID { get; private set; }
// NearFar Start, default = 2000
public const String groundTexStartKey = "_groundTexStart";
public Int32 groundTexStartID { get; private set; }
// NearFar Start, default = 10000
public const String groundTexEndKey = "_groundTexEnd";
public Int32 groundTexEndID { get; private set; }
// Multifactor, default = 0.5
public const String multiFactorKey = "_multiFactor";
public Int32 multiFactorID { get; private set; }
// Main Texture, default = "white" { }
public const String mainTexKey = "_mainTex";
public Int32 mainTexID { get; private set; }
// PlanetOpacity, default = 1
public const String planetOpacityKey = "_PlanetOpacity";
public Int32 planetOpacityID { get; private set; }
// Singleton instance
private static Properties singleton = null;
public static Properties Instance
{
get
{
// Construct the singleton if it does not exist
if(singleton == null)
singleton = new Properties();
return singleton;
}
}
private Properties()
{
saturationID = Shader.PropertyToID(saturationKey);
contrastID = Shader.PropertyToID(contrastKey);
tintColorID = Shader.PropertyToID(tintColorKey);
texTilingID = Shader.PropertyToID(texTilingKey);
texPowerID = Shader.PropertyToID(texPowerKey);
multiPowerID = Shader.PropertyToID(multiPowerKey);
groundTexStartID = Shader.PropertyToID(groundTexStartKey);
groundTexEndID = Shader.PropertyToID(groundTexEndKey);
multiFactorID = Shader.PropertyToID(multiFactorKey);
mainTexID = Shader.PropertyToID(mainTexKey);
planetOpacityID = Shader.PropertyToID(planetOpacityKey);
}
}
// Is some random material this material
public static Boolean UsesSameShader(Material m)
{
return m.shader.name == Properties.shader.name;
}
// Saturation, default = 1
public Single saturation
{
get { return GetFloat (Properties.Instance.saturationID); }
set { SetFloat (Properties.Instance.saturationID, value); }
}
// Contrast, default = 1
public Single contrast
{
get { return GetFloat (Properties.Instance.contrastID); }
set { SetFloat (Properties.Instance.contrastID, value); }
}
// Colour Unsaturation (A = Factor), default = (1,1,1,0)
public Color tintColor
{
get { return GetColor (Properties.Instance.tintColorID); }
set { SetColor (Properties.Instance.tintColorID, value); }
}
// Near Tiling, default = 1000
public Single texTiling
{
get { return GetFloat (Properties.Instance.texTilingID); }
set { SetFloat (Properties.Instance.texTilingID, value); }
}
// Near Blend, default = 0.5
public Single texPower
{
get { return GetFloat (Properties.Instance.texPowerID); }
set { SetFloat (Properties.Instance.texPowerID, value); }
}
// Far Blend, default = 0.5
public Single multiPower
{
get { return GetFloat (Properties.Instance.multiPowerID); }
set { SetFloat (Properties.Instance.multiPowerID, value); }
}
// NearFar Start, default = 2000
public Single groundTexStart
{
get { return GetFloat (Properties.Instance.groundTexStartID); }
set { SetFloat (Properties.Instance.groundTexStartID, value); }
}
// NearFar Start, default = 10000
public Single groundTexEnd
{
get { return GetFloat (Properties.Instance.groundTexEndID); }
set { SetFloat (Properties.Instance.groundTexEndID, value); }
}
// Multifactor, default = 0.5
public Single multiFactor
{
get { return GetFloat (Properties.Instance.multiFactorID); }
set { SetFloat (Properties.Instance.multiFactorID, value); }
}
// Main Texture, default = "white" { }
public Texture2D mainTex
{
get { return GetTexture (Properties.Instance.mainTexID) as Texture2D; }
set { SetTexture (Properties.Instance.mainTexID, value); }
}
public Vector2 mainTexScale
{
get { return GetTextureScale (Properties.mainTexKey); }
set { SetTextureScale (Properties.mainTexKey, value); }
}
public Vector2 mainTexOffset
{
get { return GetTextureOffset (Properties.mainTexKey); }
set { SetTextureOffset (Properties.mainTexKey, value); }
}
// PlanetOpacity, default = 1
public Single planetOpacity
{
get { return GetFloat (Properties.Instance.planetOpacityID); }
set { SetFloat (Properties.Instance.planetOpacityID, value); }
}
public PQSProjectionFallback() : base(Properties.shader)
{
}
[Obsolete("Creating materials from shader source String is no longer supported. Use Shader assets instead.")]
public PQSProjectionFallback(String contents) : base(contents)
{
base.shader = Properties.shader;
}
public PQSProjectionFallback(Material material) : base(material)
{
// Throw exception if this material was not the proper material
if (material.shader.name != Properties.shader.name)
throw new InvalidOperationException("Type Mismatch: Terrain/PQS/Sphere Projection SURFACE QUAD (Fallback) shader required");
}
}
}
}