-
Notifications
You must be signed in to change notification settings - Fork 0
/
aurora.cginc
65 lines (47 loc) · 1.43 KB
/
aurora.cginc
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
#include "globals.cginc"
#include "interpolators.cginc"
#include "math.cginc"
#include "noise.cginc"
#include "cnlohr.cginc"
#ifndef __AURORA_INC
#define __AURORA_INC
struct AuroraPBR {
float4 albedo;
float3 diffuse;
float depth;
};
float2 rotate2D(float2 v, float theta) {
return mul(float2x2(
cos(theta), -sin(theta),
sin(theta), cos(theta)), v);
}
AuroraPBR getAurora(v2f i) {
AuroraPBR result;
result.albedo.a = 1;
// Map onto [-1, 1]
float t = _Time[1];
float2 uv = i.uv0;
float c = 0;
uv = rotate2D(uv, t * .101);
uv *= 0.9;
float c_term = sin(3.14159265 * uv.x * uv.x + t) - 0.25;
c = c_term * c_term;
uv = rotate2D(uv, -t * .67);
c_term = (sin(-3.14159265 * uv.x * uv.x * 4 + t/4) - 0.25) * .5;
c += c_term * c_term;
uv = rotate2D(uv, t * .31);
c += (sin(-3.14159265 * uv.y * uv.y * 16 + t/8) - 0.25) * .25;
uv = rotate2D(uv, t * .15);
c += (sin(-3.14159265 * uv.x * uv.y * 16 + t/16) - 0.25) * .125;
c *= 0.5;
c -= sin(3.14159265 * uv.x * uv.y * 16) * .5 + 0.5;
const float2 uv_c = i.uv0 * 2.0 - 1;
float center_distance_term = saturate(1.0 - dot(uv_c, uv_c));
c *= center_distance_term * center_distance_term * center_distance_term * center_distance_term;
result.albedo.rgb = saturate(c);
result.diffuse = 0;
float4 clip_pos = mul(UNITY_MATRIX_VP, float4(i.worldPos, 1.0));
result.depth = clip_pos.z / clip_pos.w;
return result;
}
#endif // __AURORA_INC