testing
This commit is contained in:
78
shader.glsl
78
shader.glsl
@ -1,16 +1,18 @@
|
||||
#version 120
|
||||
uniform float time;
|
||||
uniform vec2 resolution;
|
||||
uniform sampler2D texture_sampler;
|
||||
uniform sampler2D texts;
|
||||
|
||||
|
||||
float zoom = 1.;
|
||||
float gTime = 0.;
|
||||
|
||||
int getBeat(void) {
|
||||
return floor(abs(time*4) / (60./133) );
|
||||
float getBeat(void) {
|
||||
return floor(abs(time*4.) / (60./133.) );
|
||||
}
|
||||
int getBar(void) {
|
||||
return floor(abs(time) / (60./133));
|
||||
float getBar(void) {
|
||||
return floor(abs(time) / (60./133.));
|
||||
}
|
||||
|
||||
vec2 csqr(vec2 a) {
|
||||
@ -91,12 +93,12 @@ void CoolSphere(out vec4 fragColor, in vec2 fragCoord) {
|
||||
// raymarch
|
||||
vec3 col = raymarch(ro, rd, tmm);
|
||||
if(tmm.x < 0.)
|
||||
col = texture2D(texture_sampler, rd).rgb;
|
||||
col = texture2D(texture_sampler, rd.xy).rgb;
|
||||
else {
|
||||
vec3 nor = (ro + tmm.x * rd) / 2.;
|
||||
nor = reflect(rd, nor);
|
||||
float fre = pow(.5 + clamp(dot(nor, rd), 0.0, 1.0), 3.) * 1.3;
|
||||
col += texture2D(texture_sampler, nor).rgb * fre;
|
||||
col += texture2D(texture_sampler, nor.xy).rgb * fre;
|
||||
|
||||
}
|
||||
|
||||
@ -157,7 +159,7 @@ float map(vec3 pos, float time) {
|
||||
return box_set1;
|
||||
}
|
||||
|
||||
void mainImage2(out vec4 fragColor, in vec2 fragCoord) {
|
||||
vec4 mainImage2(vec2 fragCoord) {
|
||||
vec2 p = (fragCoord.xy * 2. - resolution.xy) / min(resolution.x, resolution.y);
|
||||
vec3 ro = vec3(0., -0.2, time * 4.);
|
||||
vec3 ray = normalize(vec3(p, 1.5));
|
||||
@ -179,12 +181,9 @@ void mainImage2(out vec4 fragColor, in vec2 fragCoord) {
|
||||
|
||||
t += d * 0.55;
|
||||
}
|
||||
|
||||
col = vec3(ac * 0.02);
|
||||
|
||||
col += vec3(0., 0.2 * abs(sin(time)), 0.5 + sin(time) * 0.2);
|
||||
|
||||
fragColor = vec4(col, 1.0 - t * (0.02 + 0.02 * sin(time)));
|
||||
return vec4(col, 1.0 - t * (0.02 + 0.02 * sin(time)));
|
||||
}
|
||||
|
||||
vec3 palette(float t) {
|
||||
@ -204,24 +203,35 @@ float rand(vec2 co) {
|
||||
return fract(sin(sn) * c);
|
||||
}
|
||||
|
||||
vec3 random(vec2 coord) {
|
||||
float rng = rand(vec2(coord.x+time, coord.y));
|
||||
return vec3(0.05, 0.05, 0.05) * rng;
|
||||
vec3 random(vec2 uv) {
|
||||
float rng = rand(vec2(uv.x+time, uv.y));
|
||||
vec3 col = vec3(0.0+rng*0.1, 0.2+rng*0.1, 0.4+rng*0.1);
|
||||
col.x += sin(uv.x+time*0.2)*0.1;
|
||||
col.y += sin(uv.y+time*0.2)*0.1;
|
||||
col.z += sin(uv.y+time*0.2)*0.1;
|
||||
return col;
|
||||
|
||||
}
|
||||
|
||||
|
||||
vec3 wave(vec2 uv, float phase, float _offset, float height, float waveLenght, float color) {
|
||||
float val = -(sin(phase+uv.x*waveLenght+time) + (uv.y*6.+height)+_offset)*0.055;
|
||||
val *= 1. + sin(phase + uv.x*waveLenght+time) + (uv.y*6.-height+_offset);
|
||||
// return smoothstep(0.0, 32.0, val) * palette(color/360.);
|
||||
return clamp(val, 0., 1.) * palette(color/360.);
|
||||
//return smoothstep(0.0, 1.0, val) * palette(color/360.);
|
||||
return clamp(val, 0., .9) * palette(color/360.);
|
||||
}
|
||||
|
||||
vec2 waveTexture(vec2 uv) {
|
||||
uv.y = clamp(sin(uv.x*7. + time)/10. + uv.y, 0., 1.)+0.4;
|
||||
uv.x += sin(time);
|
||||
return uv;
|
||||
float gStartTime = 0.;
|
||||
float gPrevTime = -0.1;
|
||||
|
||||
vec4 waveTexture(vec2 uv) {
|
||||
uv.y = sin(uv.x*5. + time)/25. + uv.y;
|
||||
uv.x -= (time-gStartTime)*0.2;
|
||||
vec4 tex = texture2D(texts, uv);
|
||||
if (tex.y > 0. && (gPrevTime != gStartTime)) {
|
||||
gStartTime = time;
|
||||
gPrevTime = gStartTime;
|
||||
}
|
||||
return vec4(tex.rgb, 1.0);
|
||||
}
|
||||
|
||||
|
||||
@ -229,29 +239,27 @@ void TextScroller(out vec4 fragColor, in vec2 fragCoord )
|
||||
{
|
||||
// Normalized pixel coordinates (from -1 to 1, origo at 0,0)
|
||||
vec2 uv = (fragCoord*2. - resolution) / resolution;
|
||||
vec2 uv2 = (fragCoord / resolution);
|
||||
vec3 col = vec3(0., 0.3, 0.6);
|
||||
col += texture2D(texts, waveTexture(uv2));
|
||||
col += wave(uv, 0., 1., 3., 1., sin(time+0.3)*360.);
|
||||
vec3 col = vec3(0., 0.4, 0.6);
|
||||
col += wave(uv, 0., 1., 3., 1., sin(time+0.3)*90.);
|
||||
col += wave(uv, sin(time), 0., 3., -1., sin(time-1.2)*120.);
|
||||
col += wave(uv, -3., 0., 3., 1., sin(time+0.5)*90.);
|
||||
col += random(uv*2.);
|
||||
// Output to screen
|
||||
fragColor = vec4(col, 1.);
|
||||
vec4 outBuf = waveTexture(uv * 0.1);
|
||||
fragColor = mainImage2(fragCoord)*0.5 + (vec4(col, 1.0)*outBuf); // + vec4(random(uv*2.), 1.0);
|
||||
|
||||
}
|
||||
|
||||
void main(void) {
|
||||
if (getBar() <= 32)
|
||||
TextScroller(gl_FragColor, gl_FragCoord.xy);
|
||||
else
|
||||
|
||||
TextScroller(gl_FragColor, gl_FragCoord.xy);
|
||||
/*else
|
||||
{
|
||||
mainImage2(gl_FragColor, gl_FragCoord.xy);
|
||||
vec3 l;
|
||||
vec4 l;
|
||||
vec2 texttop = vec2(0., -.35), pt = (gl_FragCoord.xy / resolution) - texttop;
|
||||
if(pt.y > 0.) {
|
||||
l = gl_FragColor + texture2D(texts, pt);
|
||||
}
|
||||
|
||||
gl_FragColor = vec4(l * (1.0), 1.0);
|
||||
}
|
||||
}
|
||||
gl_FragColor = l;
|
||||
} */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user