         sdf = min(sdf_diele, min(sdf_metal, sdf_diffu));
         iters++;
     }
+    hit = start + t*dir;
     if (t>=maxDist || iters>=MAX_MARCH_STEPS) return false;
-    hit = start + t*dir;
     return true;
 }
 

        }
    }


    // Convert wavelenght to RGB (sRGB color space)
    vec3 RGB = texture2D(WavelengthToRgb, vec2(w, 0.5)).rgb;
    vec3 color = RGB * L;
