Frages is a creative coding project launched by Cosa Mentale which aims to explore different forms that the generation of visuals by code can take and their aesthetic or experience potential.
Generative_Visual_Art

FRAGES is the diminutive of “fragment” which is the part inside the code that controls the display of the pixels on the screen.The title of this project thus derives from a very precise term inside a technique called “shader”

FRAG / 03

Compute shader from unity
Texture2D<float4> reader;  RWTexture2D<float4> writer; Texture2D<float4> reader2;  RWTexture2D<float4> writer2; Texture2D<float4> reader3; RWTexture2D<float4> writer3; SamplerState _LinearClamp;

float rd (float t) {return frac(sin(dot(floor(t),12.45))*4597.268);}
float no (float t) {return lerp(rd(t),rd(t+1.0),smoothstep(0.,1.,frac(t)));}
float it(float t) {float r = 0.; float a = 0.5; for (int i = 0; i < 3; i++) {r += no(t / a)*a; a *= 0.5;}return r;}
float rand (float2 uv ) {return frac ( sin ( dot ( floor(uv),float2(94.25,43.14)))*4587.236);}
float noise ( float2 uv) {float a = rand(uv);float b = rand (uv+float2(1,0));float c = rand (uv+float2(0,1));float d = rand ( uv+float2(1,1));float2 u =smoothstep(0.,1.,frac(uv));return lerp (a,b,u.x)+(c-a)*u.y*(1.-u.x)+(d-b)*u.x*u.y;}
float fmb ( float2 uv) {float val = 0.;float amp = 0.5;for (int i =0; i<6; i++){val += amp* rand (uv);uv*=2.;amp*=.5;}return val;}
float li (float2 uv, float2 a , float2 b) { float2 ua = uv-a ; float2 ba = b-a; float h = clamp(dot(ua,ba)/dot(ba,ba),0.,1.); return length(ua-ba*h);}
float cross2d( float2 a, float2 b ) { return a.x*b.y - a.y*b.x; }float2 ca( float2 p, float2 a, float2 b, float2 c, float2 d ){float2 res = float2(-1.0,-1.0);float2 e = b-a;float2 f = d-a;float2 g = a-b+c-d;float2 h = p-a; float k2 = cross2d( g, f );float k1 = cross2d( e, f ) + cross2d( h, g );float k0 = cross2d( h, e ); float w = k1*k1 - 4.0*k0*k2;
if( w<0.0 ) return float2(-1.0,-1.0);w = sqrt( w ); float ik2 = 0.5/k2;float v = (-k1 - w)*ik2; if( v<0.0 || v>1.0 ) v = (-k1 + w)*ik2;float u = (h.x - f.x*v)/(e.x + g.x*v);
if( u<0.0 || u>1.0 || v<0.0 || v>1.0 ) return float2(-1.0,-1.0);res = float2( u, v ); return res;}
[numthreads(8,8,1)]
void CSMain (uint2 id : SV_DispatchThreadID) {
float2 f = float2(id.x,id.y);float2 uv = f/iResolution;
float vo1 = it(_time1*2.+13.); float vo2 = it(_time1*2.+45.); float2 p1 = float2(vo1,vo2); float2 p2 = (p1-reader2.SampleLevel(_LinearClamp,float2(0.,0.),0).rg)*10.;
float2 r1 = (float2 (rd(vo1*78.236),rd(vo2*68.257))-float2(0.5,0.5))*0.2;float2 r2 = (float2 (rd(vo1*15.265),rd(vo2*35.004))-float2(0.5,0.5))*0.2;
float2 f1 = p1+r1; float2 f2 = p1+r2; float2 f3 = f2+p2; float2 f4 = f1+p2;
float2 l1 = ca ( uv+float2(fmb((uv+vo1)*10.),fmb((uv+vo2)*10.))*0.01 ,f1,f2,f3,f4+0.0001); float2 l2 = ca ( uv ,f1,f2,f3,f4);
float m1 =step(0.01,l1.x);  float m2 =step(0.01,l2.x); float m3 = max(m1,m2);float2 mv = smoothstep(0.5,0.6,float2 (fmb(l1*3.+vo1*45.236),fmb(l1*3.+vo2*78.236))); float2 mv2 = smoothstep(0.5,0.6,float2 (fmb(l2*3.+vo1*15.886),fmb(l2*3.+vo2*39.784)));float2 c1 = lerp(lerp(float2(0.5,0.5),mv2,m2),mv,m1);float2 buff = lerp(float2(0.5,0.5),
reader.SampleLevel(_LinearClamp,uv+float2(0.5,0.5)/iResolution+(reader.SampleLevel(_LinearClamp,uv+float2(2.,2.)/iResolution,0).zw-0.5)*0.1,0).zw,
step(0.01,frac(_time))); float mf = max(max(step(0.51,buff.x),step(buff.x,0.49)),m3); float2 c2 = lerp(lerp(float2(0.5,0.5),buff,0.95),c1,m3); float3 c = float3(rd(vo1*658.885),rd(vo1*33.421),rd(vo2*78.821)); float3 fc = lerp(c,reader3.SampleLevel(_LinearClamp,uv+float2(0.5,0.5)/iResolution,0).xyz,mf);float2 tr = float2(lerp(0.4,0.5,abs((vo1-0.5)*2.))*lerp(-1.,1.,step(0.5,vo1)),lerp(1.,0.85,abs((vo2-0.5)*2.))); float2 b = tr; float2 v = float2(0.0,0.0);
for(int l=0;l<20;l++){ if ( dot(b,b) > pow(iResolution.y,2.0) ) break; float2 p = b; for(int i=0;i<5;i++) {
float2 pos = f+p;  float rot=0.0; for(int i=0;i<5;i++) {
rot+=dot(reader.SampleLevel(_LinearClamp,float2(frac((pos+p)/iResolution.xy)),0).x-float2(0.5,0.5),float2(-1.,1.)*p.yx); p=float2(tr.x*p.x+tr.y*p.y,-tr.y*p.x+tr.x*p.y); }v+=p.yx* rot/5.0/dot(b,b); p=float2(tr.x*p.x+tr.y*p.y,-tr.y*p.x+tr.x*p.y);} b*=2.0;}  float co=reader.SampleLevel(_LinearClamp,frac((f+v*float2((no(_time1+81.36)-0.5)*4.,(no(_time1+43.65)-0.5)*-4.))/iResolution.xy),0).x;  co += smoothstep(0.05,0.,distance(f/iResolution,float2(vo1,vo2)))*no(_time1+69.23); float delta = 0.001; float2 texcoord = f/iResolution; float2 tuv = (-texcoord +0.5)*0.01*0.5; float cf = 0.; float2 uv2 = texcoord;
for ( int i = 0; i < 64; i++ ) {  float depth = (float(i) ) / 64.;  uv2 -= tuv ;  cf = reader.SampleLevel(_LinearClamp, uv2+tuv*64.,0).x; if ( 1.-dot(cf, 1.) < depth) break;}
writer[id]=float4(co,cf,c2); writer2[id]=float4(p1,0.,0.); writer3[id]=float4(fc,mf);}

final shader that receive the passe from the compute shader



float ov(float x, float y){if (x < 0.5)return 2.0*x*y;elsereturn 1.0 - 2.0*(1.0 - x)*(1.0 - y);}
float3 ov3 (float3 a , float3 b){return float3 (ov(a.x,b.x),ov(a.y,b.y),ov(a.z,b.z));}
float rd (float t) {return frac(sin(dot(floor(t),12.45))*4597.268);}
float no (float t) {return lerp(rd(t),rd(t+1.0),smoothstep(0.,1.,frac(t)));}
float4 nm ( float2 uv , float _r, float _s ){
float2 texel = _resolution/_ScreenParams; float2 n = float2(0.0, texel.y);float2 e = float2(texel.x, 0.0);float2 s = float2(0.0, -texel.y);float2 w = float2(-texel.x, 0.0);
float d = tex2D(_reader, uv).y;float d_n = tex2D(_reader, frac(uv+n) ).y;float d_e = tex2D(_reader, frac(uv+e) ).y;float d_s = tex2D(_reader, frac(uv+s) ).y;float d_w = tex2D(_reader, frac(uv+w) ).y; float d_ne = tex2D(_reader, frac(uv+n+e)).y;float d_se = tex2D(_reader, frac(uv+s+e)).y;float d_sw = tex2D(_reader, frac(uv+s+w)).y;float d_nw = tex2D(_reader, frac(uv+n+w)).y;
float dxn[3];float dyn[3];float dcn[3]; dcn[0] = 0.5;dcn[1] = 1.0; dcn[2] = 0.5;dyn[0] = d_nw - d_sw;dyn[1] = d_n - d_s; dyn[2] = d_ne - d_se;dxn[0] = d_ne - d_nw; dxn[1] = d_e - d_w; dxn[2] = d_se - d_sw; float den = 0.0;float3 avd = float3(0.,0.,0.);float ma = d+d_n+d_e+d_s+d_w+d_ne+d_se+d_sw+d_nw/9.;
for(int i = 0; i < 3; i++) {for(int j = 0; j < 3; j++) {float2 dxy = float2(dxn[i], dyn[j]);float w = dcn[i] * dcn[j];float3 bn = reflect(normalize(float3(_s*dxy, -1.0)), float3(0,1,0));
avd += w * bn;den += w;}}return float4(avd /= den,ma);}
fixed4 frag (v2f i) : SV_Target
{

float2 texcoord = i.uv; float maxColor = COLORS - 1.0;
float3 col = saturate(tex2D(_reader3, i.uv)).xyz*saturate(tex2D(_reader3, i.uv)).a;float c2 = smoothstep(_r3,_r4,dot(col,float3(0.3,0.59,0.11)));float3 nor = nm( texcoord,_r1,_r2);float ft = (abs(nor.x)+abs(nor.y));float3 hu = saturate(3.0*abs(1.0-2.0*frac(ft+float3(0.0,-1.0/3.0,1.0/3.0)))-1);float3 fin = lerp(hu*ft,col, saturate(tex2D(_texf, i.uv)).a);
float halfColX = 0.5 / _LUT_TexelSize.z; float halfColY = 0.5 / _LUT_TexelSize.w;float threshold = maxColor / COLORS;
float xOffset = halfColX + fin.r * threshold / COLORS;float yOffset = halfColY + fin.g * threshold;float cell = floor(fin.b * maxColor);
float2 lutPos = float2(cell / COLORS + xOffset, yOffset);float3 fr = tex2D(_LUT, lutPos).xyz;float t = tex2D(_texf2, texcoord).y;float nb = lerp(c2,1.-c2,t);float3 fr3 = float3 (nb,nb,nb);float3 resu = lerp(fr,fr3,step(0.9,rd(_Time.x*1000.)));
return float4(resu,1.);
}

FRAG / 16

#define pi 3.14159265359
struct scene{float dist;int em;float re;vec3 col;};
float se = 0.0;
float rd() {return (fract(sin( (se += 1.0)) * 43758.5453));}
vec3 rdv(){    float theta = rd() * (6.283); float z = rd() * 2.0 - 1.0; float a = sqrt(1.0 - z * z); vec3 v = vec3(a * cos(theta), a * sin(theta), z); return v * sqrt(rd());}
mat2 rot(float r){float c = cos(r);float s = sin(r);return mat2(c, -s, s, c);}
float box(vec3 p, vec3 s){vec3 d = abs(p) - s; return length(max(d, 0.0)) + min(max(d.x, max(d.y, d.z)), 0.0);}
scene opOR(in scene a, in scene b){ if (a.dist < b.dist){return a;} return b;}
scene map(vec3 p){  float fb = 1.+(sin(0.5*pi*0.5)*0.5+0.5)  ;  vec3 b = p;
    for(int i =0 ; i < 9; i ++ ) {b = vec3(1.5,fb,1.5)*abs(b/dot(b,b))-vec3(0.2,0.5,0.5);}   
    scene li = scene(length(p)-0.1, 1, 1.0, vec3(40.)); scene art = scene( length(b)-0.4,0,1.2, vec3(1.)); scene scene = opOR(li, art); return scene;}
vec3 norm(vec3 p){vec2 en=vec2(0.,0.01);return normalize(map(p).dist -vec3(map(p-en.yxx).dist,map(p-en.xyx).dist,map(p - en.xxy).dist));}
scene raymarch(in vec3 ro, in vec3 rd){ float t = 0.0;
    scene sceneOutput = scene(50.,  0, 1.2, vec3(0.03));
    for (int i = 0; i < 100; ++i){ scene sce = map(ro + rd * t); if (sce.dist < 0.01){ sceneOutput = scene(t, sce.em,sce.re,sce.col); break;} t += sce.dist; if (t > 20.){break;} }
    return sceneOutput;}
vec4 raytrace(in vec2 uv){vec3 ro = vec3(uv, 0.0);vec3 rd = normalize(vec3(uv, 1.));vec3 color = vec3(0.0);vec3 mco = vec3(0.0);float atten = 1.0;float bounces = 1.;
    for (int i = 0; i <5; ++i) {scene sce = raymarch(ro, rd);if (sce.em == 0){ vec3 p = ro + rd * sce.dist; vec3 n = norm(p); 
            rd = n + rdv() * sce.re;ro = p + rd * 0.1;mco += (sce.col) * atten; bounces += 1.0; atten *= 0.5; }
        else { color = mix(sce.col, mco * sce.col, max(0.0, float(i))); break;} 
} color/=bounces; return vec4(color,1.);} void main() { vec2 uc = (gl_FragCoord.xy)/iResolution.xy; float time = float(iFrame); se = (iResolution.y *gl_FragCoord.x / iResolution.x + gl_FragCoord.y / iResolution.y);se += time; vec2 uv = (gl_FragCoord.xy / iResolution.xy * 2.0 - 1.0) ;
uv.x *= iResolution.x/iResolution.y; vec4 color = raytrace(uv ); gl_FragColor = vec4(color.xyz,1.); }

FRAG / 16

out vec4 fragColor;
#define PI 3.14159265359
#define TAU (PI*2.0)
#define mul(a, b) ((a) * (b))
vec3 seed = vec3(0);
float random(){    return fract(sin(fract(sin(dot(seed.xy, vec2(12.9898, 78.233)) * (seed.z += 1.0)) * 43758.5453))*753.5453123);}
vec3 ortho(vec3 v) { return abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y);}
vec3 getSampleBiased(vec3 dir, float power) {dir = normalize(dir);vec3 o1 = normalize(ortho(dir));vec3 o2 = normalize(cross(dir, o1));vec2 r = vec2(random(), random());r.x = r.x * 2. * PI;r.y = pow(r.y, 1.0 / (power + 1.0));float oneminus = sqrt(1.0 - r.y * r.y);return cos(r.x) * oneminus * o1 + sin(r.x) * oneminus * o2 + r.y * dir;}
mat2 rot(float r){float c = cos(r), s = sin(r);return mat2(c, s, -s, c);}
float tor( vec3 p,vec2 t){vec2 q = vec2(length(p.xy)-t.x,p.z);return length(q)-t.y;}
struct scene{float dist;vec3 color;bool emissive;float specular;}; scene add(scene a, scene b){if (a.dist < b.dist) return a; return b;}
scene map(vec3 p){float va1 =sin(time*0.25)*0.;for (int i = 0 ; i < 12 ; i++){p = vec3(1.47+va1,1.5,1.4)*abs(p/dot(p,p))-vec3(0.49,0.5,0.1);}float b1 = length(p)-1.;scene m1 = scene( b1,vec3(1.),false,0.);return m1;}
bool raytrace(vec3 ro, vec3 rd, out scene data){float t = 0.0;for (int i = 0; i < 150+min(0,iFrame); ++i){scene d = map(ro + rd * t);if (d.dist < 0.001){data = d;data.dist = t;return true;}t += d.dist;if (t > 80.0) break;}return false;}
vec3 pathtrace(vec2 uv){float tt= time*0.1;vec3 ro = vec3(0.,0.,-5.);vec3 rd = normalize(vec3(uv, 1.7));ro.xz*=rot(tt);rd.xz*=rot(tt);vec3 sunDir = normalize(vec3(0.4, 0.8, -0.1));vec3 sunColor = vec3(1.);vec3 direct = vec3(0, 0, 0), luminance = vec3(1.);
for (int b = 0; b < 4+min(0,iFrame); ++b){
scene data;
if (raytrace(ro, rd, data))
{vec2 e = vec2(0, 0.01);vec3 p = ro + rd * data.dist;vec3 n = normalize(vec3(map(p + e.yxx).dist - map(p - e.yxx).dist,map(p + e.xyx).dist - map(p - e.xyx).dist,map(p + e.xxy).dist - map(p - e.xxy).dist));
if (data.specular>0.)rd = getSampleBiased(normalize(reflect(rd, n)), data.specular);else rd = getSampleBiased(n, 1.0);ro = p + rd * 0.2;luminance *= data.color;
if (!data.emissive){ vec3 sunSampleDir = getSampleBiased(sunDir, 980.0);float ndl = dot(n, sunSampleDir);scene tmp;
if (ndl > 0.0 && !raytrace(ro, sunSampleDir, tmp)){direct += luminance * ndl * sunColor;}}
else{direct += luminance;}}
else{return direct + luminance *0.002;}}
return vec3(0, 0, 0);} void main(void) { vec2 uv = inData.v_texcoord; vec2 uc = uv;vec4 prevFrame = texture(prevPass, uv);seed = vec3(uv,time);uv = (uv * 2.0 - 1.0) * vec2(resolution.x / resolution.y, 1.0);
vec2 jitter = 2.0 / resolution.xy * (vec2(random(), random()) * 2.0 - 1.0);
vec3 color = pathtrace(uv + jitter);vec4 prevcolor = texture(prevPass,uc);
fragColor = prevcolor;
vec3 result = vec3(0.);float fac = 40.;float fr = fract(iFrame/fac)*fac; float frame = 1./(fr+1.);
if (fr >1){result = mix(prevcolor.rgb,color.rgb,frame);}
fragColor = vec4(result,1.);     }

Generative caractere landscape serie

A


out vec4 fragColor;
float hs(vec2 p){ return fract(sin(dot(p,vec2(45.,94.)))*7845.236+time*5.);}
float rd (float t) {return fract(sin(dot(floor(t),12.45))*4597.268);}
float no (float t) {return mix(rd(t),rd(t+1.0),smoothstep(0.,1.,fract(t)));}
float no (vec2 p){ vec2 f = floor(p); p = smoothstep(0.,1.,fract(p));vec2 se = vec2(95.,145.); vec2 v1 = dot(se,f)+vec2(0.,se.y);vec2 v2 = mix(fract(sin(v1)*8458.265),fract(sin(v1+se.x)*8458.265),p.x);return mix(v2.x,v2.y,p.y);}
float it (float t){ float r = 0. ; float a = 0.5; for(int i = 0 ; i < 3 ; i++){r += no(t/a)*a; a*=0.5;} return r;}
float it (vec2 t){ float r = 0. ; float a = 0.5; for(int i = 0 ; i < 5 ; i++){r += no(t/a)*a; a*=0.5;} return r;}
void main(void){
vec2 uv = inData.v_texcoord;
vec2 f = uv * resolution; float ff = float(frame1);float vo1 = it(ff*0.02);float vo2 = it(ff*0.02+96.);
vec2 tr = vec2(mix(0.4,0.6,abs((vo1-0.5)*2.))*mix(-1.,1.,step(0.5,vo1)),mix(1.,0.5,abs((vo2-0.5)*2.)));vec2 b = tr;vec2 v = vec2(0.0,0.0);
for(int l=0;l<5;l++){if ( dot(b,b) > pow(resolution.y,2.0) ) break;vec2 p = b;
for(int i=0;i<5;i++){ vec2 pos = f+p; float rot=0.0;
for(int i=0;i<5;i++){
rot+=dot(texture(A,vec2(fract((pos+p)/resolution.xy))).a-vec2(0.5,0.5),vec2(-1.,1.)*p.yx);
p=vec2(tr.x*p.x+tr.y*p.y,-tr.y*p.x+tr.x*p.y); }
v+=p.yx* rot/5.0/dot(b,b); p=vec2(tr.x*p.x+tr.y*p.y,-tr.y*p.x+tr.x*p.y);}b*=8.0;}
float pat = smoothstep(0.5,1.,it(uv*5.+vec2(it(uv*3.-ff*0.004),it(uv*3.+95.+ff*0.004)-0.5)*0.8))+(hs(uv)-0.5);
float co=texture(A,fract((f+v*vec2((no(ff*0.01+81.36)-0.5)*10.,(no(ff*0.01+43.65)-0.5)*-10.))/resolution.xy)).a;
vec2 uc = inData.v_texcoord;vec2 uv2 = (uc-0.5)*0.005;float c = 0.;
for (int i = 0 ; i < 40 ; i++){float d = i / 40.;uc -= uv2;c = texture(A,uc).a;if(d>dot(c,1.)) {break;}}
fragColor = vec4(clamp(vec3(clamp(c,0.,1.))+(1.-pat)*0.1*(1.-c),0.,1.)-pat*c*0.2,co);}

B

out vec4 fragColor;
float character(float n, vec2 p){p = floor(p*vec2(4.0, -4.0) + 2.5);if (clamp(p.x, 0.0, 4.0) == p.x && clamp(p.y, 0.0, 4.0) == p.y&& int(mod(n/exp2(p.x + 5.0*p.y), 2.0)) == 1) return 1.0;return 0.0;}
void main(void){
vec2 uv = inData.v_texcoord;vec2 pix = uv*resolution; float val =4;float val2 = val*2.;
float t = texture(prevPass,(floor(pix/val2)*val2)/resolution.xy).x;float g = smoothstep(0.,1.,t);g = 1.-g;
float gray =0.5- abs(g-0.5);int n = 0;
if (gray > 0.05) n = 4096;if (gray > 0.1) n = 65600;if (gray > 0.15) n = 4329604; if (gray > 0.2) n = int(mix(1118480,17043521,step(0.5,uv.x))); if (gray > 0.25) n = int(mix(12718220,6426758,step(0.5,uv.x))); if (gray > 0.3) n = 332772;if (gray > 0.35) n = 15255086; if (gray > 0.4) n = 15252014;if (gray > 0.45) n = 11512810;
vec2 p = mod(pix/val, 2.0) - vec2(1.0);float col = character(n, p); float r1 = mix(col,1.-col,step(0.5,g));
fragColor = vec4(r1);}


FRAG / 07

out vec4 fragColor;
float rd(float t){return fract(sin(dot(floor(t),45.))*7845.236);}
void main(void)
{
vec2 uv = -1. + 2. * inData.v_texcoord;
vec2 uc = inData.v_texcoord;
uv.x*=resolution.x/resolution.y;
float v1 = rd(time*4.);
float an = step(0.5,rd(time*4.+95.));
vec2 v2 = (mix(vec2(v1,0.5),vec2(0.5,v1),an)-0.5)*0.2;
vec2 v3 = vec2(texture(A,vec2(0.25,0.8)).a,texture(A,vec2(0.75,0.8)).a);
vec2 v4 =clamp(v2+v3,-1.,1.);
float v5 = mix(an,mix(v4.x,v4.y,step(0.5,uc.x)),step(0.5,uc.y));
vec2 p1 = v3;
float p2 = length(uv+p1);
float p3 = mix(length(uv.x+p1.x),length(uv.y+p1.y),1.-an);
float l1 = max(step(0.2,length(uv.x+p1.x)),step(0.2, length(uv.y+p1.y)));
vec2 l2 = texture(A,uc).yz;
float l3 = min(l1,l2.y+0.01);
float l4 = step(0.9,l3);
float l5 = min(p3,l2.x+0.01);
fragColor = vec4(l4,l5,l3,v5);
}

FRAG / 14

float no(vec2 p){vec2 f = floor(p); p =smoothstep(0.,1.,fract(p));vec2 se = vec2(45.,98.); vec2 v1 = dot(f,se)+vec2(0.,se.y);float t = 7845.236+time*0.5;vec2 v2 = mix(fract(sin(v1)*t),fract(sin(v1+se.x)*t),p.x);return mix(v2.x,v2.y,p.y);}
vec3 ov(vec3 a , vec3 b ) { return mix(2.*a*b,1.-2.*(1.-a)*(1.-b),step(vec3(0.5),a));}

A

out vec4 fragColor;
float get_average(vec2 uv){
const float points = 15.0;vec2 scale = (11 / resolution.xy);float res = texture(prevFrame, uv).r;
for (float point = 0.0; point < points; point++){float r = (0.2) * point;
res += texture(A, uv + vec2(sin(r), cos(r)) * scale).r;}res /= points;return res;}
void main(void){
vec2 uv = inData.v_texcoord; vec2 uc = (uv-0.5)*2.; uc.x *= resolution.x/resolution.y;
float md1 = smoothstep(0.,1.,no(uc*2.))-0.8; float np = get_average(uv); float b1 =sin(np*(md1*1.+5))+md1;
fragColor = vec4(b1);}

B

out vec4 fragColor;
float it(vec2 uv){float amp =0.5;float r =0.;for (int i = 0 ; i < 5 ; i++){r += no(uv/amp)*amp;amp*=0.5;}return r;}
void main(void){
   vec2 uv =  inData.v_texcoord; vec2 uc = (uv-0.5)*2.;uc.x *= resolution.x/resolution.y;
    float fa = 2.;float fa2 = 5.;
    vec2 b1 = vec2(no(uv*fa+45.+vec2(time,0.))-0.5,no(uv*fa+75.-vec2(time,0.))-0.5)*0.03;
    vec2 b2 = vec2(it(uv*fa2+36.+vec2(time,0.))-0.5,it(uv*fa2+98.-vec2(time,0.))-0.5)*0.04;
   vec2 base = uv+b1+b2; float m = clamp(texture(A,uv).r,0.,1.); vec2 t1 = mix(texture(B,base).xy,vec2(no(uv*2.+time+56.236),no(uv+time*2.+84.126)),m);
   fragColor = vec4(t1,0.,1.);}

C

out vec4 fragColor;
void main(void){
vec2 uv = inData.v_texcoord; vec2 uc = texture(B,uv).xy; vec4 tf = vec4(0.);
for (int i = 0 ; i <= 10 ; i++){
float fac = pow(float(i)/9,0.0008); vec2 e =vec2 (mix(0.005,0.000001,fac),0.);
vec2 t1 = texture(B,uv+e.xy).xy; vec2 t2 = texture(B,uv-e.xy).xy; vec2 t3 = texture(B,uv+e.yx).xy; vec2 t4 = texture(B,uv-e.yx).xy;
vec4 t5 = vec4((t1-t2),(t3-t4))*mix(2.,150.,fac); tf += t5;} tf /= 10.;
float t6 = (tf.x+tf.y+tf.z+tf.w)*0.5+0.5; float t7 = pow(dot(normalize(vec3(tf.xy,0.1)),vec3(0.,0.,1.)),100);
vec3 c1 = mix(vec3(0.5),3.*abs(1.-2.*fract(uc.x*0.5+0.5+uc.y*0.2+t7*0.2-t6*0.1+vec3(0.,-1./3.,1./3.)))-1.,0.5)*t6+((uc.x+uc.y)*0.5); vec3 c2 = mix(vec3(0.2),vec3(0.8),c1); vec3 c3 = ov(c2,vec3(mix(0.1,0.5,no(uc*20.))));
fragColor = vec4(c3,smoothstep(0.,1.,no(uc*100.)));}

D

out vec4 fragColor;
void main(void)
{
vec2 uv = inData.v_texcoord; vec2 uc = (uv-0.5)*0.001; vec2 e = vec2(0.00001,0.);vec4 c = vec4(0.);float c1 = 0.;float c2 = 0.;int vv = 30;
for (int i = 0 ; i < vv ; i++){ uv -= uc;float d = i / vv;
c += texture(C,uv).xyza; c1 += texture(C,uv+e.xy).z; c2 += texture(C,uv+e.yx).z;
if(d>dot(c.z,1.)){break;}} c/=vv;c1 /= vv;c2 /= vv;
vec3 n = normalize(vec3(c.z-c1,c.z-c2,0.05));
vec3 tf = ((n.x+n.y)*.25)+texture(C,inData.v_texcoord).yzx*vec3(0.8,0.8,0.4);
float tl = pow(dot(n,vec3(0.,0.,1.)),5000.);
vec3 rh = mix(vec3(0.5),3.*abs(1.-2.*fract(tl*0.8+0.8+vec3(0.,-1./3.,1./3.)))-1.,0.2)*mix(0.8,0.9,tl);
vec3 r1 = ov(ov(c.xyz,vec3(tf)),mix(vec3(0.5),rh,0.9));
vec2 ub = texture(B,inData.v_texcoord).xy; float nr =c.a;
vec3 r2 = ov(r1,vec3(mix(0.5,nr,1.)));
fragColor = vec4(r2,0.);
}