// forward-fog factor (0 = clear, 1 = full fog; u_fogColor.a = enabled 0/1) — shared by the world // passes so transparent/additive draws fog by their own depth, not the background's. // requires _graphics_uniforms.glsl. highp: world positions span the 200 m far plane float fogFactor(highp vec3 worldPos) { highp float dist = length(u_cameraPos - worldPos); return clamp((dist - u_fogParams.x) / max(u_fogParams.y - u_fogParams.x, 0.0001), 0.0, 1.0) * u_fogColor.a; }