We study the effect of local stellar radiation and ultraviolet background (UVB) radiation on the physical properties of damped Lyα systems (DLAs) and Lyman limit systems (LLSs) at z = 3 using cosmological smoothed particle hydrodynamics simulations. We post-process our simulations with the authentic radiation transfer (ART) code for radiative transfer of local stellar radiation and UVB radiation. We find that the DLA and LLS cross-sections are significantly reduced by the UVB radiation, whereas the local stellar radiation does not affect them very much except in the low-mass haloes. This is because the clumpy high-density clouds near young star clusters effectively absorb most of the ionizing photons from young stars. We also find that the UVB model with a simple density threshold for the self-shielding effect can reproduce the observed column density distribution function of DLAs and LLSs very well, and we validate this model by direct radiative transfer calculations of stellar radiation and UVB radiation with high angular resolution. We show that, with a self-shielding treatment, the DLAs have an extended distribution around star-forming regions typically on ∼10–30 kpc scales, and LLSs are surrounding DLAs on ∼30–60 kpc scales. The DLA gas is less extended than the virial radius of the halo, and LLSs are distributed over the similar scale to the virial radius of the host halo. Our simulations suggest that the median properties of DLA host haloes are Mh = 2.4 × 1010 M⊙, SFR = 0.3 M⊙ yr−1, M★ = 2.4 × 108 M⊙ and Z/Z⊙ = 0.1. About 30 per cent of DLAs are hosted by haloes having SFR = 1–20 M⊙ yr−1, which is the typical star formation rate (SFR) range for Lyman break galaxies (LBGs). More than half of DLAs are hosted by the LBGs that are fainter than the current observational limit. Our results suggest that fractional contribution to LLSs from lower mass haloes is greater than for DLAs. Therefore, the median values of LLS host haloes are somewhat lower with Mh = 9.6 × 109 M⊙, SFR = 0.06 M⊙ yr−1, M★ = 6.5 × 107 M⊙ and Z/Z⊙ = 0.08. About 80 per cent of total LLS cross-section are hosted by haloes with SFR ≲ 1 M⊙ yr−1, hence most LLSs are associated with low-mass haloes with faint LBGs below the current detection limit.