uniform sampler2D uTexGarbage; in vec4 aColour; in vec2 aUv; in vec3 aNorm; in vec3 aCo; in vec3 aWorldCo; // Spooky! const vec3 uCamera = vec3(0.0); #include "light_clearskies_stddef.glsl" #include "common_world.glsl" #include "motion_vectors_fs.glsl" float stars1( vec3 rd, float rr, float size ){ vec3 co = rd * rr; float a = atan(co.y, length(co.xz)) + 4.0 * PI; float spaces = 1.0 / rr; size = (rr * 0.0015) * fwidth(a) * 1000.0 * size; a -= mod(a, spaces) - spaces * 0.5; float count = floor(sqrt(pow(rr, 2.0) * (1.0 - pow(sin(a), 2.0))) * 3.0); float plane = atan(co.z, co.x) + 4.0 * PI; plane = plane - mod(plane, PI / count); vec2 delta = rand33(vec3(plane, a, 0.0)).xy; float level = sin(a + spaces * (delta.y - 0.5) * (1.0 - size)) * rr; float ydist = sqrt(rr * rr - level * level); float angle = plane + (PI * (delta.x * (1.0-size) + size * 0.5) / count); vec3 center = vec3(cos(angle) * ydist, level, sin(angle) * ydist); float star = smoothstep(size, 0.0, distance(center, co)); return star; } void main(){ compute_motion_vectors(); vec3 rd = -normalize(aNorm); float star = 0.0; for( float j = 1.0; j <= 4.1; j += 1.0 ){ float m = mix(0.6, 0.9, smoothstep(1.0, 2.0, j)); star += stars( rd, 1.94 * pow( 1.64, j ), m ) * (1.0 / pow(4.0, j)); } oColour = vec4( vec3(star*20.0), 1.0); }