BLOKS Shader Bulletin Board
Sphere Stuff
Shader Preview Unavailable
This realtime shader may be too intensive for your current device or browser.
Shader Code
float sdSphere(vec3 p, float r)
{
return length(p) - r;
}
void mainImage(out vec4 fragColor, in vec2 fragCoord)
{
vec2 uv = fragCoord.xy / iResolution.xy;
vec2 p = uv * 2.0 - 1.0;
p.x *= iResolution.x / iResolution.y;
vec3 pos = vec3(p, 0.0);
float d = sdSphere(pos, 0.5);
float sphere =
smoothstep(0.02, 0.0, abs(d));
vec3 color = vec3(0.02, 0.04, 0.08);
color += sphere * vec3(0.1, 0.7, 1.0);
fragColor = vec4(color, 1.0);
}
