Skip to content

Commit

Permalink
Create distortion_field.glsl
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel authored Nov 20, 2016
1 parent c0ff2f6 commit a1bc57a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions distortion_field.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <multisample>
#include <perlin>

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<drawStars, 4>, 1600, 900);

0 comments on commit a1bc57a

Please sign in to comment.