Outside does not matter (IMO).
Indoors, it matters very much. Density, duration, air handling are also important. But masks matter a lot.
Masks matter for bacteria. A doctor in Israel recently came down with a 2nd bout of Covid after treating a Covid patient. Doctors wear masks but they don’t practice social distancing when treating patients.