export default `#define MAX_STEPS 1280
#define MAX_DIST 1280.
#define E 0.00001
#define PI 3.141592

vec3 rotX(vec3 v, float a) {
    return vec3(v.x, v.y * cos(a) - v.z * sin(a), v.y * sin(a) + v.z * cos(a));
}
vec3 rotY(vec3 v, float a) {
    return vec3(v.x * cos(a) + v.z * sin(a), v.y, v.z * cos(a) - v.x * sin(a));
}
vec3 rotZ(vec3 v, float a) {
    return vec3(v.x * cos(a) - v.y * sin(a), v.x * sin(a) + v.y * cos(a), v.z);
}

float sdfSphere(vec3 p, float r) {
    return length(p) - r;
}

float scene(vec3 p) {
    int		index = -1;
    float d = 10000.;
    float sd1 = sdfSphere(p, 1.);
    d = min(sd1, d);
    return d;
}

vec2 march(vec3 ro, vec3 rd) {
    float dO = 0.;
    float mind = 10000.;
    float index;
    for (int steps = 0; steps < MAX_STEPS; steps++) {
        vec3 p = ro + rd * dO;
        float dS = scene(p);
        if (dS < mind)
            mind = dS;
        dO += dS;
        if (dS < E || dO > MAX_DIST)
            break;
    }
    return vec2(dO, mind);
}

vec3 normal(vec3 p) {
    float d = scene(p);
    vec2 e = vec2(0.001, 0);
    vec3 n = d - vec3(
        		scene(p - e.xyy),
                scene(p - e.yxy),
                scene(p - e.yyx));
    return (normalize(n));
}

float light(vec3 p, vec3 n) {
    vec3 lightPos = vec3(-5. * sin(iTime * 4.), -5. * sin(iTime * 3.), -5. * cos(iTime * 2.));
    vec3 l = normalize(lightPos - p);
    float dif = clamp(dot(l, n), 0., 1.);
    vec2 d = march(p+n*E * 30., l);
    if (d.x < length(lightPos - p))
        	dif *= 0.1;
    return (dif);
}

void mainImage( out vec4 fragColor, in vec2 fragCoord ) {
    vec2 uv = ((fragCoord - .5 * iResolution.xy) / iResolution.y);
    vec3 ro = vec3(0., 0., -4.);
    vec3 rd = normalize(vec3(uv.x, uv.y, 1.));
	vec3 col = vec3(0);
    vec2 d = march(ro, rd);

    vec3 p = ro + rd * d.x;
    vec3 n = normal(p);
    p += n * E * 10.;
    float dif = light(p, n);
    col +=  vec3(dif);
    fragColor = vec4(col, 1.0);
}`;
