The aim of this paper is the creation of 3D porosity patterns from virtual models of granular soil or asphalt with controlled characteristics, namely air voids content and voids size. 3D soil/asphalt models are generated by combining 2D planes of virtual particles that are converted to 3D and stacked to obtain a multilayered structure that can represent effectively real samples. The virtual samples are generated with an algorithm that places and grows particles randomly inside a 2D domain of chosen shape and size. The particles can be circles or ellipses, and they are grown based on the biological concept of contact inhibition, thus, they stop growing as soon as they touch each other. The convergence of the algorithm is based on the planar air voids content, which is used as the target of each simulation. Since the method is based on the randomization of all the parameters of interest, it is possible to create a virtually infinite number of different 3D slabs of arbitrary thickness from any number of 2D randomized layers. In the 3D soil/asphalt models there exists a portion of space that is not occupied by particles and can be considered as the void network seen in real samples. The virtual porosity patterns are generated with a sampling method that is able to find the empty space in any previously-generated 3D soil/asphalt domain. The 3D representations of the voids are meant to recreate the porous channels seen in real specimens in order to allow their use for numerical simulations, e.g. for the analysis of permeability or for the study of thermal convection phenomena. The comparison between the distribution of virtual voids and real void data from X-ray CT scans is performed. Using a statistical method to exclude the outliers in the analysis of data, it is shown that the pore size distribution of virtual specimens is very similar to that of real ones, thus, confirming the validity of the approach.