diff --git a/distortion_field.glsl b/distortion_field.glsl new file mode 100644 index 0000000..572c1d2 --- /dev/null +++ b/distortion_field.glsl @@ -0,0 +1,25 @@ +#include +#include + +parameter float timeScale = 1.0 : range(0.5, 6.0); + +glsl vec4 drawStars(vec2 pos) { + vec2 origin = shadron_Dimensions / 2; + vec2 loc = pos * shadron_Dimensions; + float distFromOrigin = distance(loc, origin); + + float noiseMult = 10 + distFromOrigin + shadron_Time * timeScale; + + // Color some of the stars + float blueValue = step(0.75, perlinNoise((pos + vec2(0.33, -0.1)) * noiseMult)); + float redValue = step(0.75, perlinNoise((pos + vec2(0.39, 0.94)) * noiseMult)); + vec4 red = vec4(redValue, 0.0, 0.0, redValue); + vec4 blue = vec4(0.0, 0.0, blueValue, blueValue); + vec4 background = red + blue + vec4(1.0); + + vec4 starMask = vec4(vec3(0.0), 1.0 - step(0.9, perlinNoise(pos * noiseMult))); + + return vec4(mix(background.rgb, starMask.rgb, starMask.a), 1.0); +} + +animation distortionField = glsl(multisample, 1600, 900);