Skip to content

Commit 28059fe

Browse files
committed
punched up cloud shader before moving project onto other computer
1 parent 7b0a716 commit 28059fe

File tree

1 file changed

+39
-13
lines changed

1 file changed

+39
-13
lines changed

assets/shaders/sky.frag

+39-13
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,47 @@ const vec3 RANDOM_VECTORS[6] = vec3[6]
3838
vec3(-0.16852403f, 0.14748697f, 0.97460106f)
3939
);
4040

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+
4162
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);
4464

65+
mat3 rot = rotate_around_x(-abs(sin(time / 20.)) * 90.);
66+
sun_dir *= rot;
67+
return sun_dir;
4568
}
4669

4770
vec3 getSunColor() {
4871
//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;
5275
}
5376

5477
vec3 getSkyColor() {
5578
//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);
5782
}
5883

5984
int check_pos(vec2 x, float size) {
@@ -163,7 +188,7 @@ float HG(vec3 inv, vec3 outv, float g) {
163188
float density(vec3 p,vec3 weather) {
164189
p.x += time*10.0;
165190
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);
167192
float fbm = n.g*0.625+n.b*0.25+n.a*0.125;
168193
weather.x = smoothstep(0.65, 1.0, weather.x);
169194
float g = densityHeightGradient(height_fraction, weather.z);
@@ -173,7 +198,7 @@ float density(vec3 p,vec3 weather) {
173198
base_cloud *= cloud_coverage;
174199
vec2 whisp = texture(curl, p.xy*0.001).xy;
175200
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;
177202
float hfbm = hn.r*0.625+hn.g*0.25+hn.b*0.125;
178203
hfbm = mix(hfbm, 1.0-hfbm, clamp(height_fraction*10.0, 0.0, 1.0));
179204
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) {
217242
}
218243
float powshug = 1.0-exp(-ldt*t*ss*2.0);
219244
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;
222248
}
223-
L/=L+1.0;
224-
//L = sqrt(L);
225-
249+
L = U2Tone(L);
250+
L /= U2Tone(vec3(50.0));
251+
L = sqrt(L);
226252
T = clamp(1.0-T, 0.0, 1.0);
227253
//L = texture(perlworl, pos*0.0002).xxx;
228254
return vec4(L, T);

0 commit comments

Comments
 (0)