Skip to content

Instantly share code, notes, and snippets.

@rasteron
Created February 24, 2016 15:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rasteron/097ff90e009542c58950 to your computer and use it in GitHub Desktop.
Save rasteron/097ff90e009542c58950 to your computer and use it in GitHub Desktop.
#include "Uniforms.glsl"
#include "Samplers.glsl"
#include "Transform.glsl"
#include "ScreenPos.glsl"
#include "Lighting.glsl"
varying vec2 vScreenPos;
precision mediump float;
uniform vec2 resolution = vec2(1366.0,768.0);
#ifdef COMPILEPS
uniform float cElapsedTime;
uniform vec2 cSpeed;
#endif
uniform float shift;
float rand(vec2 n) {
return fract(cos(dot(n, vec2(12.9898, 4.1414))) * 43758.5453);
}
float noise(vec2 n) {
const vec2 d = vec2(0.0, 1.0);
vec2 b = floor(n), f = smoothstep(vec2(0.0), vec2(1.0), fract(n));
return mix(mix(rand(b), rand(b + d.yx), f.x), mix(rand(b + d.xy), rand(b + d.yy), f.x), f.y);
}
float fbm(vec2 n) {
float total = 0.0, amplitude = 1.0;
for (int i = 0; i < 4; i++) {
total += noise(n) * amplitude;
n += n;
amplitude *= 0.5;
}
return total;
}
void VS()
{
mat4 modelMatrix = iModelMatrix;
vec3 worldPos = GetWorldPos(modelMatrix);
gl_Position = GetClipPos(worldPos);
vScreenPos = GetScreenPosPreDiv(gl_Position);
}
void PS() {
const vec3 c1 = vec3(12.0/255.0, 10.0/212.0, 71.0/255.0);
const vec3 c2 = vec3(218.0/255.0, 220.0/255.0, 11.4/755.0);
const vec3 c3 = vec3(0.2, 0.0, 0.0);
const vec3 c4 = vec3(162.0/255.0, 1.0/255.0, 4.4/955.0);
const vec3 c5 = vec3(3.1);
const vec3 c6 = vec3(1.151);
vec2 p = gl_FragCoord.xy * 8.0 / resolution.xx;
float q = fbm(p - cElapsedTime * 0.1);
vec2 r = vec2(fbm(p + q + cElapsedTime * cSpeed.x - p.x - p.y), fbm(p + q - cElapsedTime * cSpeed.y));
vec3 c = mix(c1, c2, fbm(p + r)) + mix(c3, c4, r.x) - mix(c5, c6, r.y);
float grad = gl_FragCoord.y / resolution.y;
gl_FragColor = vec4(c * cos(shift * gl_FragCoord.y / resolution.y), 1.0);
gl_FragColor.xyz *= 1.0-grad;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment