Skip to content

Instantly share code, notes, and snippets.

@CedricGuillemet
Last active January 16, 2019 05:52
Show Gist options
  • Save CedricGuillemet/3fc20701a344ee7fb375c5cd98d8f2e7 to your computer and use it in GitHub Desktop.
Save CedricGuillemet/3fc20701a344ee7fb375c5cd98d8f2e7 to your computer and use it in GitHub Desktop.
float val(vec2 p)
{
return step(length(p-vec2(0.2,0.7)), 0.2);
//return texture(iChannel0, src).r;
}
float GetTh(vec2 src, float sz)
{
float p = val(src);
float pul = val(src + vec2(-sz, sz));
float pur = val(src + vec2( sz, sz));
float dnl = val(src + vec2(-sz,-sz));
float dnr = val(src + vec2( sz,-sz));
return max(max(abs(pul-p), abs(pur-p)), max(abs(dnl-p), abs(dnr-p)));
}
void mainImage(out vec4 fragColor, in vec2 fragCoord)
{
vec2 uv = fragCoord/iResolution.xy;// * vec2(1.,iResolution.y/iResolution.x);
vec3 col = vec3(0.0);
//for(int i = 0;i<6;i++)
int i = 5;
{
float s = float(i);
float d = 1./(s+1.);
float sz = 0.5 / pow(2.,s);
vec2 p = floor(uv/sz)*sz + vec2(sz);
float th = GetTh(p, sz);
//if (th < 0.1)
{
col = vec3(th);//val(p));
//break;
}
//col = vec3(p, 0.0);
//col = vec3(val(p));
}
//col = vec3(val(uv));
fragColor = vec4(col,1.0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment