-
Notifications
You must be signed in to change notification settings - Fork 115
/
PQSProjectionSurfaceQuad.cs
executable file
·629 lines (526 loc) · 25.5 KB
/
PQSProjectionSurfaceQuad.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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
// Material wrapper generated by shader translator tool
using System;
using UnityEngine;
namespace Kopernicus
{
namespace MaterialWrapper
{
public class PQSProjectionSurfaceQuad : 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";
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; }
// Steep Tiling, default = 1
public const String steepTilingKey = "_steepTiling";
public Int32 steepTilingID { get; private set; }
// Steep Blend, default = 1
public const String steepPowerKey = "_steepPower";
public Int32 steepPowerID { get; private set; }
// Steep Fade Start, default = 20000
public const String steepTexStartKey = "_steepTexStart";
public Int32 steepTexStartID { get; private set; }
// Steep Fade End, default = 30000
public const String steepTexEndKey = "_steepTexEnd";
public Int32 steepTexEndID { get; private set; }
// Deep ground, default = "white" { }
public const String deepTexKey = "_deepTex";
public Int32 deepTexID { get; private set; }
// Deep MT, default = "white" { }
public const String deepMultiTexKey = "_deepMultiTex";
public Int32 deepMultiTexID { get; private set; }
// Deep MT Tiling, default = 1
public const String deepMultiFactorKey = "_deepMultiFactor";
public Int32 deepMultiFactorID { get; private set; }
// Main Texture, default = "white" { }
public const String mainTexKey = "_mainTex";
public Int32 mainTexID { get; private set; }
// Main MT, default = "white" { }
public const String mainMultiTexKey = "_mainMultiTex";
public Int32 mainMultiTexID { get; private set; }
// Main MT Tiling, default = 1
public const String mainMultiFactorKey = "_mainMultiFactor";
public Int32 mainMultiFactorID { get; private set; }
// High Ground, default = "white" { }
public const String highTexKey = "_highTex";
public Int32 highTexID { get; private set; }
// High MT, default = "white" { }
public const String highMultiTexKey = "_highMultiTex";
public Int32 highMultiTexID { get; private set; }
// High MT Tiling, default = 1
public const String highMultiFactorKey = "_highMultiFactor";
public Int32 highMultiFactorID { get; private set; }
// Snow, default = "white" { }
public const String snowTexKey = "_snowTex";
public Int32 snowTexID { get; private set; }
// Snow MT, default = "white" { }
public const String snowMultiTexKey = "_snowMultiTex";
public Int32 snowMultiTexID { get; private set; }
// Snow MT Tiling, default = 1
public const String snowMultiFactorKey = "_snowMultiFactor";
public Int32 snowMultiFactorID { get; private set; }
// Steep Texture, default = "white" { }
public const String steepTexKey = "_steepTex";
public Int32 steepTexID { get; private set; }
// Deep Start, default = 0
public const String deepStartKey = "_deepStart";
public Int32 deepStartID { get; private set; }
// Deep End, default = 0.3
public const String deepEndKey = "_deepEnd";
public Int32 deepEndID { get; private set; }
// Main lower boundary start, default = 0
public const String mainLoStartKey = "_mainLoStart";
public Int32 mainLoStartID { get; private set; }
// Main lower boundary end, default = 0.5
public const String mainLoEndKey = "_mainLoEnd";
public Int32 mainLoEndID { get; private set; }
// Main upper boundary start, default = 0.3
public const String mainHiStartKey = "_mainHiStart";
public Int32 mainHiStartID { get; private set; }
// Main upper boundary end, default = 0.5
public const String mainHiEndKey = "_mainHiEnd";
public Int32 mainHiEndID { get; private set; }
// High lower boundary start, default = 0.6
public const String hiLoStartKey = "_hiLoStart";
public Int32 hiLoStartID { get; private set; }
// High lower boundary end, default = 0.6
public const String hiLoEndKey = "_hiLoEnd";
public Int32 hiLoEndID { get; private set; }
// High upper boundary start, default = 0.6
public const String hiHiStartKey = "_hiHiStart";
public Int32 hiHiStartID { get; private set; }
// High upper boundary end, default = 0.9
public const String hiHiEndKey = "_hiHiEnd";
public Int32 hiHiEndID { get; private set; }
// Snow Start, default = 0.9
public const String snowStartKey = "_snowStart";
public Int32 snowStartID { get; private set; }
// Snow End, default = 1
public const String snowEndKey = "_snowEnd";
public Int32 snowEndID { 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);
steepTilingID = Shader.PropertyToID(steepTilingKey);
steepPowerID = Shader.PropertyToID(steepPowerKey);
steepTexStartID = Shader.PropertyToID(steepTexStartKey);
steepTexEndID = Shader.PropertyToID(steepTexEndKey);
deepTexID = Shader.PropertyToID(deepTexKey);
deepMultiTexID = Shader.PropertyToID(deepMultiTexKey);
deepMultiFactorID = Shader.PropertyToID(deepMultiFactorKey);
mainTexID = Shader.PropertyToID(mainTexKey);
mainMultiTexID = Shader.PropertyToID(mainMultiTexKey);
mainMultiFactorID = Shader.PropertyToID(mainMultiFactorKey);
highTexID = Shader.PropertyToID(highTexKey);
highMultiTexID = Shader.PropertyToID(highMultiTexKey);
highMultiFactorID = Shader.PropertyToID(highMultiFactorKey);
snowTexID = Shader.PropertyToID(snowTexKey);
snowMultiTexID = Shader.PropertyToID(snowMultiTexKey);
snowMultiFactorID = Shader.PropertyToID(snowMultiFactorKey);
steepTexID = Shader.PropertyToID(steepTexKey);
deepStartID = Shader.PropertyToID(deepStartKey);
deepEndID = Shader.PropertyToID(deepEndKey);
mainLoStartID = Shader.PropertyToID(mainLoStartKey);
mainLoEndID = Shader.PropertyToID(mainLoEndKey);
mainHiStartID = Shader.PropertyToID(mainHiStartKey);
mainHiEndID = Shader.PropertyToID(mainHiEndKey);
hiLoStartID = Shader.PropertyToID(hiLoStartKey);
hiLoEndID = Shader.PropertyToID(hiLoEndKey);
hiHiStartID = Shader.PropertyToID(hiHiStartKey);
hiHiEndID = Shader.PropertyToID(hiHiEndKey);
snowStartID = Shader.PropertyToID(snowStartKey);
snowEndID = Shader.PropertyToID(snowEndKey);
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); }
}
// Steep Tiling, default = 1
public Single steepTiling
{
get { return GetFloat (Properties.Instance.steepTilingID); }
set { SetFloat (Properties.Instance.steepTilingID, value); }
}
// Steep Blend, default = 1
public Single steepPower
{
get { return GetFloat (Properties.Instance.steepPowerID); }
set { SetFloat (Properties.Instance.steepPowerID, value); }
}
// Steep Fade Start, default = 20000
public Single steepTexStart
{
get { return GetFloat (Properties.Instance.steepTexStartID); }
set { SetFloat (Properties.Instance.steepTexStartID, value); }
}
// Steep Fade End, default = 30000
public Single steepTexEnd
{
get { return GetFloat (Properties.Instance.steepTexEndID); }
set { SetFloat (Properties.Instance.steepTexEndID, value); }
}
// Deep ground, default = "white" { }
public Texture2D deepTex
{
get { return GetTexture (Properties.Instance.deepTexID) as Texture2D; }
set { SetTexture (Properties.Instance.deepTexID, value); }
}
public Vector2 deepTexScale
{
get { return GetTextureScale (Properties.deepTexKey); }
set { SetTextureScale (Properties.deepTexKey, value); }
}
public Vector2 deepTexOffset
{
get { return GetTextureOffset (Properties.deepTexKey); }
set { SetTextureOffset (Properties.deepTexKey, value); }
}
// Deep MT, default = "white" { }
public Texture2D deepMultiTex
{
get { return GetTexture (Properties.Instance.deepMultiTexID) as Texture2D; }
set { SetTexture (Properties.Instance.deepMultiTexID, value); }
}
public Vector2 deepMultiTexScale
{
get { return GetTextureScale (Properties.deepMultiTexKey); }
set { SetTextureScale (Properties.deepMultiTexKey, value); }
}
public Vector2 deepMultiTexOffset
{
get { return GetTextureOffset (Properties.deepMultiTexKey); }
set { SetTextureOffset (Properties.deepMultiTexKey, value); }
}
// Deep MT Tiling, default = 1
public Single deepMultiFactor
{
get { return GetFloat (Properties.Instance.deepMultiFactorID); }
set { SetFloat (Properties.Instance.deepMultiFactorID, 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); }
}
// Main MT, default = "white" { }
public Texture2D mainMultiTex
{
get { return GetTexture (Properties.Instance.mainMultiTexID) as Texture2D; }
set { SetTexture (Properties.Instance.mainMultiTexID, value); }
}
public Vector2 mainMultiTexScale
{
get { return GetTextureScale (Properties.mainMultiTexKey); }
set { SetTextureScale (Properties.mainMultiTexKey, value); }
}
public Vector2 mainMultiTexOffset
{
get { return GetTextureOffset (Properties.mainMultiTexKey); }
set { SetTextureOffset (Properties.mainMultiTexKey, value); }
}
// Main MT Tiling, default = 1
public Single mainMultiFactor
{
get { return GetFloat (Properties.Instance.mainMultiFactorID); }
set { SetFloat (Properties.Instance.mainMultiFactorID, value); }
}
// High Ground, default = "white" { }
public Texture2D highTex
{
get { return GetTexture (Properties.Instance.highTexID) as Texture2D; }
set { SetTexture (Properties.Instance.highTexID, value); }
}
public Vector2 highTexScale
{
get { return GetTextureScale (Properties.highTexKey); }
set { SetTextureScale (Properties.highTexKey, value); }
}
public Vector2 highTexOffset
{
get { return GetTextureOffset (Properties.highTexKey); }
set { SetTextureOffset (Properties.highTexKey, value); }
}
// High MT, default = "white" { }
public Texture2D highMultiTex
{
get { return GetTexture (Properties.Instance.highMultiTexID) as Texture2D; }
set { SetTexture (Properties.Instance.highMultiTexID, value); }
}
public Vector2 highMultiTexScale
{
get { return GetTextureScale (Properties.highMultiTexKey); }
set { SetTextureScale (Properties.highMultiTexKey, value); }
}
public Vector2 highMultiTexOffset
{
get { return GetTextureOffset (Properties.highMultiTexKey); }
set { SetTextureOffset (Properties.highMultiTexKey, value); }
}
// High MT Tiling, default = 1
public Single highMultiFactor
{
get { return GetFloat (Properties.Instance.highMultiFactorID); }
set { SetFloat (Properties.Instance.highMultiFactorID, value); }
}
// Snow, default = "white" { }
public Texture2D snowTex
{
get { return GetTexture (Properties.Instance.snowTexID) as Texture2D; }
set { SetTexture (Properties.Instance.snowTexID, value); }
}
public Vector2 snowTexScale
{
get { return GetTextureScale (Properties.snowTexKey); }
set { SetTextureScale (Properties.snowTexKey, value); }
}
public Vector2 snowTexOffset
{
get { return GetTextureOffset (Properties.snowTexKey); }
set { SetTextureOffset (Properties.snowTexKey, value); }
}
// Snow MT, default = "white" { }
public Texture2D snowMultiTex
{
get { return GetTexture (Properties.Instance.snowMultiTexID) as Texture2D; }
set { SetTexture (Properties.Instance.snowMultiTexID, value); }
}
public Vector2 snowMultiTexScale
{
get { return GetTextureScale (Properties.snowMultiTexKey); }
set { SetTextureScale (Properties.snowMultiTexKey, value); }
}
public Vector2 snowMultiTexOffset
{
get { return GetTextureOffset (Properties.snowMultiTexKey); }
set { SetTextureOffset (Properties.snowMultiTexKey, value); }
}
// Snow MT Tiling, default = 1
public Single snowMultiFactor
{
get { return GetFloat (Properties.Instance.snowMultiFactorID); }
set { SetFloat (Properties.Instance.snowMultiFactorID, value); }
}
// Steep Texture, default = "white" { }
public Texture2D steepTex
{
get { return GetTexture (Properties.Instance.steepTexID) as Texture2D; }
set { SetTexture (Properties.Instance.steepTexID, value); }
}
public Vector2 steepTexScale
{
get { return GetTextureScale (Properties.steepTexKey); }
set { SetTextureScale (Properties.steepTexKey, value); }
}
public Vector2 steepTexOffset
{
get { return GetTextureOffset (Properties.steepTexKey); }
set { SetTextureOffset (Properties.steepTexKey, value); }
}
// Deep Start, default = 0
public Single deepStart
{
get { return GetFloat (Properties.Instance.deepStartID); }
set { SetFloat (Properties.Instance.deepStartID, value); }
}
// Deep End, default = 0.3
public Single deepEnd
{
get { return GetFloat (Properties.Instance.deepEndID); }
set { SetFloat (Properties.Instance.deepEndID, value); }
}
// Main lower boundary start, default = 0
public Single mainLoStart
{
get { return GetFloat (Properties.Instance.mainLoStartID); }
set { SetFloat (Properties.Instance.mainLoStartID, value); }
}
// Main lower boundary end, default = 0.5
public Single mainLoEnd
{
get { return GetFloat (Properties.Instance.mainLoEndID); }
set { SetFloat (Properties.Instance.mainLoEndID, value); }
}
// Main upper boundary start, default = 0.3
public Single mainHiStart
{
get { return GetFloat (Properties.Instance.mainHiStartID); }
set { SetFloat (Properties.Instance.mainHiStartID, value); }
}
// Main upper boundary end, default = 0.5
public Single mainHiEnd
{
get { return GetFloat (Properties.Instance.mainHiEndID); }
set { SetFloat (Properties.Instance.mainHiEndID, value); }
}
// High lower boundary start, default = 0.6
public Single hiLoStart
{
get { return GetFloat (Properties.Instance.hiLoStartID); }
set { SetFloat (Properties.Instance.hiLoStartID, value); }
}
// High lower boundary end, default = 0.6
public Single hiLoEnd
{
get { return GetFloat (Properties.Instance.hiLoEndID); }
set { SetFloat (Properties.Instance.hiLoEndID, value); }
}
// High upper boundary start, default = 0.6
public Single hiHiStart
{
get { return GetFloat (Properties.Instance.hiHiStartID); }
set { SetFloat (Properties.Instance.hiHiStartID, value); }
}
// High upper boundary end, default = 0.9
public Single hiHiEnd
{
get { return GetFloat (Properties.Instance.hiHiEndID); }
set { SetFloat (Properties.Instance.hiHiEndID, value); }
}
// Snow Start, default = 0.9
public Single snowStart
{
get { return GetFloat (Properties.Instance.snowStartID); }
set { SetFloat (Properties.Instance.snowStartID, value); }
}
// Snow End, default = 1
public Single snowEnd
{
get { return GetFloat (Properties.Instance.snowEndID); }
set { SetFloat (Properties.Instance.snowEndID, value); }
}
// PlanetOpacity, default = 1
public Single planetOpacity
{
get { return GetFloat (Properties.Instance.planetOpacityID); }
set { SetFloat (Properties.Instance.planetOpacityID, value); }
}
public PQSProjectionSurfaceQuad() : base(Properties.shader)
{
}
[Obsolete("Creating materials from shader source String is no longer supported. Use Shader assets instead.")]
public PQSProjectionSurfaceQuad(String contents) : base(contents)
{
base.shader = Properties.shader;
}
public PQSProjectionSurfaceQuad(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 shader required");
}
}
}
}