When you want to take into account as many contributing factors as possible, you will need a complete radiative transfer model, preferably a physics-based one (as opposed to fast radiative transfer models that are often incorporated into weather or climate models).
A radiative transfer model takes as input atmospheric composition in one or three dimensions, scattering databases for suspended matter such as aerosols or clouds (if the model includes scattering from particles), a molecular spectroscopic database such as HITRAN, as well as many configuration parameters. Some models are only valid for certain areas of the atmospheric spectrum. Some make line-by-line calculations (where "line" here means a location in the spectrum), others make broadband estimates directly. Examples of well-known line-by-line models that cover visible wavelengths include LBLRTM and LibRadtran. They may not be able to calculate visibility directly, but they should be able to calculate those quantities from which visibility can be estimated.