corrected opacityMiddle calculation