Created
August 8, 2018 21:06
-
-
Save lunasorcery/6f3ef0770acf4d2a4962cc16fd508aff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#version 410 core | |
uniform float fGlobalTime; // in seconds | |
uniform vec2 v2Resolution; // viewport resolution (in pixels) | |
uniform sampler1D texFFT; // towards 0.0 is bass / lower freq, towards 1.0 is higher / treble freq | |
uniform sampler1D texFFTSmoothed; // this one has longer falloff and less harsh transients | |
uniform sampler1D texFFTIntegrated; // this is continually increasing | |
uniform sampler2D texChecker; | |
uniform sampler2D texNoise; | |
uniform sampler2D texTex1; | |
uniform sampler2D texTex2; | |
uniform sampler2D texTex3; | |
uniform sampler2D texTex4; | |
layout(location = 0) out vec4 out_color; // out_color must be written in order to see anything | |
#define iTime fGlobalTime | |
#define pi acos(-1.) | |
float noise(vec2 p) | |
{ | |
return fract(sin(dot(p, vec2(12.43243, 4.58479)))*1234.4556); | |
} | |
float scene(vec3 p) | |
{ | |
p.x = abs(p.x); | |
return min( | |
1+p.y, | |
1-p.x | |
) + texture(texChecker, p.xz*.25+p.yz*.25).r*.2; | |
} | |
vec2 rotate(vec2 a, float b) | |
{ | |
float c = cos(b); | |
float s = sin(b); | |
return vec2( | |
a.x * c - a.y * s, | |
a.x * s + a.y * c | |
); | |
} | |
vec4 laser(vec4 color, vec2 uv) | |
{ | |
uv -= .5; | |
float w = clamp(pow(.1/length(uv),3.),0,30); | |
return color* w*.2; | |
} | |
void main(void) | |
{ | |
vec2 uv = vec2(gl_FragCoord.x / v2Resolution.x, gl_FragCoord.y / v2Resolution.y); | |
uv -= 0.5; | |
uv /= vec2(v2Resolution.y / v2Resolution.x, 1); | |
vec3 cam = vec3(0,0,iTime*5); | |
vec3 dir = normalize(vec3(uv, 1)); | |
cam.x = sin(iTime)*.3; | |
dir.xy = rotate(dir.xy, sin(iTime)*.1); | |
float t = 0; | |
for(int i = 0; i < 64;++i) | |
{ | |
t += scene(cam + dir * t)*.5; | |
} | |
vec3 h = cam + dir*t; | |
vec2 o = vec2(.001, 0); | |
vec3 n = normalize(vec3( | |
scene(h+o.xyy)-scene(h-o.xyy), | |
scene(h+o.yxy)-scene(h-o.yxy), | |
scene(h+o.yyx)-scene(h-o.yyx) | |
)); | |
//n = normalize(cross(dFdy(h), dFdx(h))); | |
out_color.rgb = fract(h*1); | |
out_color.rgb = n*.5+.5; | |
out_color = vec4(max(0,dot(n, vec3(.2,1,.1)))*.4+.05); | |
out_color /= t*.3; | |
{ | |
vec4 red = vec4(1,.1,.1,1); | |
vec4 green = vec4(.1,1,.1,1); | |
vec2 luv = vec2( | |
.3/length(dir.xy), | |
atan(dir.x, dir.y)/pi*.5 | |
); | |
out_color += laser(red, fract(luv*vec2(.01,1)+vec2(-iTime*3,-.1))); | |
out_color += laser(green, fract(luv*vec2(.01,1)+vec2(iTime*3+.5,.1))); | |
} | |
if (h.y > abs(h.x)) | |
{ | |
out_color = vec4(step(.995,noise(gl_FragCoord.xy))); | |
} | |
//out_color = laser(vec2(gl_FragCoord.x / v2Resolution.x, gl_FragCoord.y / v2Resolution.y)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment