X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=shaders%2Fmodel_sky_space.fs;fp=shaders%2Fmodel_sky_space.fs;h=442e97eb5d94c78252f830606b031deaff4c8da7;hb=63fe317d7db724162561da52aa382c82ac3c29be;hp=0000000000000000000000000000000000000000;hpb=2c91a71533b4ce86b9e7fd708420ae05c74d8f52;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/shaders/model_sky_space.fs b/shaders/model_sky_space.fs new file mode 100644 index 0000000..442e97e --- /dev/null +++ b/shaders/model_sky_space.fs @@ -0,0 +1,51 @@ +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 "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); +}