accommodate inspector change
[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 "light_clearskies_stddef.glsl"
13 #include "common_world.glsl"
14 #include "motion_vectors_fs.glsl"
15
16 float stars1( vec3 rd, float rr, float size ){
17 vec3 co = rd * rr;
18
19 float a = atan(co.y, length(co.xz)) + 4.0 * PI;
20
21 float spaces = 1.0 / rr;
22 size = (rr * 0.0015) * fwidth(a) * 1000.0 * size;
23 a -= mod(a, spaces) - spaces * 0.5;
24
25 float count = floor(sqrt(pow(rr, 2.0) * (1.0 - pow(sin(a), 2.0))) * 3.0);
26
27 float plane = atan(co.z, co.x) + 4.0 * PI;
28 plane = plane - mod(plane, PI / count);
29
30 vec2 delta = rand33(vec3(plane, a, 0.0)).xy;
31
32 float level = sin(a + spaces * (delta.y - 0.5) * (1.0 - size)) * rr;
33 float ydist = sqrt(rr * rr - level * level);
34 float angle = plane + (PI * (delta.x * (1.0-size) + size * 0.5) / count);
35 vec3 center = vec3(cos(angle) * ydist, level, sin(angle) * ydist);
36 float star = smoothstep(size, 0.0, distance(center, co));
37 return star;
38 }
39
40 void main(){
41 compute_motion_vectors();
42
43 vec3 rd = -normalize(aNorm);
44
45 float star = 0.0;
46 for( float j = 1.0; j <= 4.1; j += 1.0 ){
47 float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j));
48 star += stars( rd, 1.94 * pow( 1.64, j ), m ) * (1.0 / pow(4.0, j));
49 }
50
51 oColour = vec4( vec3(star*20.0), 1.0);
52 }