@@ -38,22 +38,47 @@ const vec3 RANDOM_VECTORS[6] = vec3[6]
38
38
vec3 (- 0 .16852403f, 0 .14748697f, 0 .97460106f)
39
39
);
40
40
41
+
42
+ vec3 U2Tone(vec3 x) {
43
+ const float A = 0.15 ;
44
+ const float B = 0.50 ;
45
+ const float C = 0.10 ;
46
+ const float D = 0.20 ;
47
+ const float E = 0.02 ;
48
+ const float F = 0.30 ;
49
+
50
+ return ((x* (A* x+ C* B)+ D* E)/ (x* (A* x+ B)+ D* F))- E/ F;
51
+ }
52
+
53
+
54
+ mat3 rotate_around_x(float angle_degrees)
55
+ {
56
+ float angle = radians (angle_degrees);
57
+ float _sin = sin (angle);
58
+ float _cos = cos (angle);
59
+ return mat3 (1 , 0 , 0 , 0 , _cos, - _sin, 0 , _sin, _cos);
60
+ }
61
+
41
62
vec3 getSunDirection() {
42
- return vec3 (0.0 , 1.0 , 0.0 );
43
- // return normalize(vec3(0.0, cos(time*0.01+1.2), -sin(time*0.01+1.2)));
63
+ vec3 sun_dir = vec3 (0.0 , 1.0 , 0.0 );
44
64
65
+ mat3 rot = rotate_around_x(- abs (sin (time / 20 .)) * 90 .);
66
+ sun_dir *= rot;
67
+ return sun_dir;
45
68
}
46
69
47
70
vec3 getSunColor() {
48
71
// should shift with sun color
49
- // vec3 dir = getSunDirection();
50
- return suncol;
51
- // return vec3(dir.y, 0.0, 0.0) ;
72
+ vec3 dir = getSunDirection();
73
+ return mix ( vec3 ( 0.9 , 0.8 , 0.6 ), suncol, dir.y) ;
74
+ // return suncol ;
52
75
}
53
76
54
77
vec3 getSkyColor() {
55
78
// soon make this a gradient based on sun direction
56
- return skycol;
79
+
80
+ // return mix(vec3(0.9, 0.8, 0.5), skycol, getSunDirection().y);
81
+ return vec3 (0.99 , 0.7 , 0.5 );
57
82
}
58
83
59
84
int check_pos(vec2 x, float size) {
@@ -163,7 +188,7 @@ float HG(vec3 inv, vec3 outv, float g) {
163
188
float density(vec3 p,vec3 weather) {
164
189
p.x += time* 10.0 ;
165
190
float height_fraction = GetHeightFractionForPoint(p, vec2 (float (sky_b_radius), float (sky_t_radius)));
166
- vec4 n = texture(perlworl, p* 0.0002 );
191
+ vec4 n = texture(perlworl, p* 0.0006 );
167
192
float fbm = n.g* 0.625 + n.b* 0.25 + n.a* 0.125 ;
168
193
weather.x = smoothstep (0.65 , 1.0 , weather.x);
169
194
float g = densityHeightGradient(height_fraction, weather.z);
@@ -173,7 +198,7 @@ float density(vec3 p,vec3 weather) {
173
198
base_cloud *= cloud_coverage;
174
199
vec2 whisp = texture(curl, p.xy* 0.001 ).xy;
175
200
p.xy += whisp* 300.0 * (1.0 - height_fraction);
176
- vec3 hn = texture(worl, p* 0.002 ).xyz;
201
+ vec3 hn = texture(worl, p* 0.004 ).xyz;
177
202
float hfbm = hn.r* 0.625 + hn.g* 0.25 + hn.b* 0.125 ;
178
203
hfbm = mix (hfbm, 1.0 - hfbm, clamp (height_fraction* 10.0 , 0.0 , 1.0 ));
179
204
base_cloud = remap(base_cloud, hfbm* 0.2 , 1.0 , 0.0 , 1.0 );
@@ -217,12 +242,13 @@ vec4 march(vec3 pos, vec3 dir, int depth) {
217
242
}
218
243
float powshug = 1.0 - exp (- ldt* t* ss* 2.0 );
219
244
powshug = mix (1 .0f, powshug, clamp ((- dot (normalize (ldir), normalize (dir)) * 0 .5f) + 0 .5f, 0.0 , 1.0 ));
220
- vec3 ambient = 0.5 * getSkyColor()* mix (0.5 , 1.0 , height_fraction);
221
- L += (ambient+ getSunColor()* lT* powshug* 2.0 * phase)* (1.0 - dt)* T* ss;
245
+ vec3 ambient = 0.5 * getSkyColor()* mix (0.25 , 1.0 , height_fraction);
246
+ vec3 sunC = getSunColor();
247
+ L += (ambient+ sunC* lT* powshug* 2.0 * phase)* (1.0 - dt)* T* ss;
222
248
}
223
- L/= L + 1.0 ;
224
- // L = sqrt(L );
225
-
249
+ L = U2Tone(L) ;
250
+ L /= U2Tone( vec3 ( 50.0 ) );
251
+ L = sqrt (L);
226
252
T = clamp (1.0 - T, 0.0 , 1.0 );
227
253
// L = texture(perlworl, pos*0.0002).xxx;
228
254
return vec4 (L, T);
0 commit comments