Please correct me if i'm wrong
fog = (len(x) * y) * (len(x) * y) = len(x) * len(x) * y * y = dot(x,x) * y^2
so I think its better to replace length with dot
also the (1.09/w)^2 can be calculated within DefaultShader