                 float dist = length( lightPositions[i] - pos );
                 float att = max( 1., dist * dist );
                 /* totalColor += lightColors[i] * color / att; */
-                totalColor += lightColors[i] * color * max(0., dot(normal, lightDir)) / att;
+                totalColor += lightColors[i] * hit.color * max(0., dot(hit.normal, lightDir)) / att;
             }
 
             /* return vec4(min(totalColor * vis, ambientColor), 1.0); */


vec4 trace(vec3 pos, vec3 dir)
{
    float lastDist = 10000.0;
    int depth = 0;
    vec3 normal;
    /* vec3 color = vec3( 0., 0., 0. ); */
    vec3 color = vec3( 0., 0., 0. );
    const vec3 ambientColor = vec3( 0.05, 0.05, 0.1 );
    while( true ) {
        bool hit = false;
        float d = mindist(pos, hit, normal, color);

        if( hit ) {
            if( pos.z >= -1. ) {
                return vec4(1.,1.,0.,1.);
            }


            float vis = 0.0;
            float maxvis = 0.0;
            HitInfo dummyHit;
            for( int i = 0; i < 4; ++i )
            {
                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);
            }
