def compute_lod_in(lod, cur_img, transition_kimg):
  """Compute value for lod_in, the variable that controls fading in new layers."""
  return lod + min(
      1.0, max(0.0, 1.0 - (float(cur_img) / (transition_kimg * 1000))))