Skip to content

programmatic video rendering framework that is actually fast

1.1 KB
Raw Blame
// FlowingGradient + a backlit sphere. The composition is reconstructed from the reference.
half4 main(float2 coord) {
    float2 uv=coord/iResolution.xy;
    float2 p=(coord-iResolution.xy*.5)/iResolution.y;
    float3 silk=flowingGradient(uv,18.0+iTime*.40,1.6,float3(.001,.0005,.007),
                               float3(.025,.002,.075),float3(.0,.003,.008),float3(.008,.001,.024));
    float2 center=float2(.02,.77-.04*sin(iTime*.20));
    float radius=.45+.015*sin(iTime*.24);
    float d=length(p-center)-radius;
    float angle=atan(p.x-center.x,-p.y+center.y);
    float spread=.105+.085*(.5+.5*sin(angle*2.0-.4));
    float halo=exp(-max(d,0.0)/spread)*(1.0-smoothstep(-.018,.008,-d));
    float3 tint=mix(float3(.34,.045,1),float3(.46,.46,1),smoothstep(-.6,.65,p.x));
    float3 color=silk+tint*halo*.85;
    float bloom=exp(-dot((p-float2(.08,.52))*float2(.9,1.2),(p-float2(.08,.52))*float2(.9,1.2))*3.0);
    color+=tint*bloom*.12;
    float inside=1.0-smoothstep(-.005,.005,d);
    color=mix(color,silk*.68+float3(.055,.01,.15)*exp(-abs(d)*12.0),inside);
    return finish(color,coord);
}