 
     bool useDebugColor = false;
 
-    const int numSteps = 64;
+    int numSteps = 64;
+    float lengthRatio = totalRayMarchLength / (CLOUD_Y_END - CLOUD_Y_START);
+    lengthRatio = clamp(lengthRatio, 1.0, 2.0);
+    numSteps = int(float(numSteps) * lengthRatio);
+
     const int inscatSteps = 6;
     
     float cosTheta = dot(camera.direction, -sunDir);

}

// #todo: Replace with a packed texture
vec2 sampleCloudShapeAndErosion(vec3 wPos) {
    vec2 uv = 0.5 + wPos.xz / CLOUD_Y_START;
    vec2 moving_uv = vec2(uv.x + getWorldTime() * WIND_SPEED, uv.y);


                for (int j = 0; j < inscatSteps; ++j) {
#if 0 // Cone sample
                    vec3 samplePos = P + coneRadius * noiseKernel[j] * float(j);
                    tau += (sigma_a + sigma_s) * sampleCloud(samplePos, 0) * segLight;

                    PL += PL_step;
                    coneRadius += CONE_STEP;
#else
                    tau += (sigma_a + sigma_s) * sampleCloud(PL, 0) * segLight;
                    PL += PL_step;
#endif
                }
