Multiple Scene
https://scrapbox.io/files/69ce5a449ea0767ac8630dbf.mp4
code:multiple_scene.glsl
float bpm = fGlobalTime*120/60;
vec4 plas( vec2 v, float time )
{
float c = 0.5 + sin( v.x * 10.0 ) + cos( sin( time + v.y ) * 20.0 );
return vec4( sin(c * 0.2 + cos(time)), c * 0.15, cos( c * 0.1 + time / .4 ) * .25, 1.0 );
}
// Scene 1
vec4 s1(vec2 fc,vec2 res) {
vec2 uv = (fc-.5*res)/min(res.x,res.y);
vec2 m;
m.x = atan(uv.x / uv.y) / 3.14;
m.y = 1 / length(uv) * .2;
float d = m.y;
float f = texture( texFFT, d ).r * 100;
m.x += sin( fGlobalTime ) * 0.1;
m.y += fGlobalTime * 0.25;
vec4 t = plas( m * 3.14, fGlobalTime ) / d;
t = clamp( t, 0.0, 1.0 );
return f + t;
}
// Scene 2
vec4 s2(vec2 fc,vec2 res) {
vec2 uv = (fc-.5*res)/min(res.x,res.y);
vec2 m;
m.x = atan(uv.x / uv.y) / 3.14;
m.y = 1 / length(uv) * .2;
float d = m.y;
float f = texture( texFFT, d ).r * 100;
m.x += sin( fGlobalTime ) * 0.1;
m.y += fGlobalTime * 0.25;
vec4 t = plas( m * 3.14, fGlobalTime ) / d;
t = clamp( t, 0.0, 1.0 );
return f*5 + sin(t*5);
}
// Scene 3
vec4 s3(vec2 fc,vec2 res) {
vec2 uv = (fc-.5*res)/min(res.x,res.y);
vec2 m;
m.x = atan(uv.x / uv.y) / 3.14;
m.y = 1 / length(uv) * .2;
float d = m.y;
float f = texture( texFFT, d ).r * 100;
m.x += sin( fGlobalTime ) * 0.1;
m.y += fGlobalTime * 0.25;
vec4 t = plas( m * 3.14, fGlobalTime ) / d;
t = clamp( t, 0.0, 1.0 );
return 1-(f + t);
}
//Scene 4
vec4 s4(vec2 fc,vec2 res) {
vec2 uv = (fc-.5*res)/min(res.x,res.y);
vec2 m;
m.x = atan(uv.x / uv.y) / 3.14;
m.y = 1 / length(uv) * .2;
float d = m.y;
float f = texture( texFFT, d ).r * 100;
m.x += sin( fGlobalTime ) * 0.1;
m.y += fGlobalTime * 0.25;
vec4 t = plas( m * 3.14, fGlobalTime ) / d;
t = clamp( t, 0.0, 1.0 );
return floor(f + t);
}
void main(void)
{
// Keep uv between 0 and 1 as we will decide a point between 0,1 to determine separation vec2 uv = vec2(gl_FragCoord.x / v2Resolution.x, gl_FragCoord.y / v2Resolution.y);
// We will need to modify this so do copy
vec2 fc = gl_FragCoord.xy,res=v2Resolution.xy;
// Separation point, vec2(.5) means middle = All window are equal
// Then mix and smooth to create transition
vec2 s = mix(
vec2(.5), // Midlle point , all windwos visible
smoothstep(-.3,.3,vec2(sin(bpm*.25),cos(bpm*.25))), // Rotation between all scene
smoothstep(-.1,.1,sin(bpm*.125)) // Transition from individual to all
);
// Determine where we are based on the separation point
bvec2 l = lessThan(uv,s);
// If we are in lower bound, do nothing
// If we are in higher bound, offset the FC by the resolution * separation point
fc-=mix(res*s,vec2(0),l);
// If we are lower bound, resolution is resolution* separation point
// if we are higer bound, resolution is resolution * (1-separation point)
res*=mix(1-s,s,l);
// manage out color per scene
if(l.y&&l.x) out_color= s4(fc,res); // Bottom left
if(l.y&&!l.x) out_color= s3(fc,res); // Bottom right
if(!l.y&&l.x) out_color= s2(fc,res); // Top left
if(!l.y&&!l.x) out_color= s1(fc,res);// Top right
}