 
             float vis = 0.0;
             float maxvis = 0.0;
-            vec3 dummyNormal, dummyColor;
+            HitInfo dummyHit;
             for( int i = 0; i < 4; ++i )
             {
-                vec3 vispos = pos + normal * 0.5 * float(i);
-                float d = mindist( vispos, hit, dummyNormal, dummyColor );
-                float occl = clamp( d, 0.0, 1.0 );
+                vec3 vispos = pos + hit.normal * 0.5 * float(i);
+                /* float d = mindist( vispos, hit, dummyNormal, dummyColor ); */
+                mindist( vispos, dummyHit );
+                float occl = clamp( dummyHit.distance, 0.0, 1.0 );
                 vis += occl / float(i+1);
                 maxvis += 1.0 / float(i+1);
             }

    return pos;
}

void mindistSphere(
    vec3 spherePos, float sphereSize, bool deform,
    vec3 pos,
    inout float mindist, inout bool hit, inout vec3 normal, inout vec3 color)
{
    vec3 localSpherePos = pos - spherePos;
    if( deform )

    }
    float dist2sphere = max( 0.0, sqrt(dot(localSpherePos, localSpherePos)) - sphereSize );

    if( dist2sphere < hit.distance )
    {
        hit.distance = dist2sphere;
        if( dist2sphere < hitThreshhold )
        {
            hit.hit = true;
            hit.normal = normalize(localSpherePos);
            hit.color = vec3( 1., 1., 1. );
        }
    }
}

void mindistPlane(vec3 planeDir, float planeDist, vec3 pos, inout HitInfo hit)
{
    /* vec3 distortedPos = displace( pos ); */
    vec3 distortedPos = pos;
    float dist2plane = max( 0.0, dot(distortedPos - planeDist*planeDir, planeDir) );

    if( dist2plane < hit.distance )
    {
        hit.distance = dist2plane;
        if( dist2plane < hitThreshhold )
        {
            hit.hit = true;
            float d = 0.001;
            /* vec3 du = displace( vec3(pos.x + d, pos.y, pos.z) ) - displace( vec3(pos.x - d, pos.y, pos.z) ); */
            /* vec3 dv = displace( vec3(pos.x, pos.y, pos.z + d) ) - displace( vec3(pos.x, pos.y, pos.z - d) ); */
            /* normal = cross( normalize( dv ), normalize( du ) ); */
            hit.normal = planeDir;

            /// show distance from origin
            /* float c = step( 1.0, mod( centerDist, 2.0 ) ); */
