mini world rendering adjustments
[carveJwlIkooP6JGAAIwe30JlM.git] / shaders / model_sky_space.fs
1 uniform sampler2D uTexGarbage;
2
3 in vec4 aColour;
4 in vec2 aUv;
5 in vec3 aNorm;
6 in vec3 aCo;
7 in vec3 aWorldCo;
8
9 // Spooky!
10 const vec3 uCamera = vec3(0.0);
11
12 #include "common_world.glsl"
13 #include "motion_vectors_fs.glsl"
14
15 float stars1( vec3 rd, float rr, float size ){
16 vec3 co = rd * rr;
17
18 float a = atan(co.y, length(co.xz)) + 4.0 * PI;
19
20 float spaces = 1.0 / rr;
21 size = (rr * 0.0015) * fwidth(a) * 1000.0 * size;
22 a -= mod(a, spaces) - spaces * 0.5;
23
24 float count = floor(sqrt(pow(rr, 2.0) * (1.0 - pow(sin(a), 2.0))) * 3.0);
25
26 float plane = atan(co.z, co.x) + 4.0 * PI;
27 plane = plane - mod(plane, PI / count);
28
29 vec2 delta = rand33(vec3(plane, a, 0.0)).xy;
30
31 float level = sin(a + spaces * (delta.y - 0.5) * (1.0 - size)) * rr;
32 float ydist = sqrt(rr * rr - level * level);
33 float angle = plane + (PI * (delta.x * (1.0-size) + size * 0.5) / count);
34 vec3 center = vec3(cos(angle) * ydist, level, sin(angle) * ydist);
35 float star = smoothstep(size, 0.0, distance(center, co));
36 return star;
37 }
38
39 void main(){
40 compute_motion_vectors();
41
42 vec3 rd = -normalize(aNorm);
43
44 float star = 0.0;
45 for( float j = 1.0; j <= 4.1; j += 1.0 ){
46 float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));
47 star += stars( rd, 1.94 * pow( 1.64, j ), m ) * (1.0 / pow(4.0, j));
48 }
49
50 oColour = vec4( vec3(star*20.0), 1.0);
51 }