Three-phase flow is a key process occurring in subsurface reservoirs, for example, during CO 2 sequestration and enhanced oil recovery techniques such as water alternating gas (WAG) injection. Predicting three-phase flow processes, for example, the increase in oil recovery during WAG, requires a sound understanding of the fundamental flow physics in water- to oil-wet rocks to derive physically robust flow functions, i.e. relative permeability and capillary pressure. In this study, we use pore-network modelling, a reliable and physically based simulation tool, to predict the flow functions. We have developed a new pore-scale network model for rocks with variable wettability, from water- to oil-wet. It comprises a constrained set of parameters that mimic the wetting state of a reservoir. Unlike other models, it combines three main features: (1) A novel thermodynamic criterion for formation and collapse of oil layers. The new model hence captures wetting film and layer flow of oil adequately, which affects the oil relative permeability at low oil saturation and leads to accurate prediction of residual oil. (2) Multiple displacement chains, where injection of one phase at the inlet triggers a chain of interface displacements throughout the network. This allows for the accurate modelling of the mobilisation of many disconnected phase clusters that arise, in particular, during higher order WAG floods. (3) The model takes realistic 3D pore-networks extracted from pore-space reconstruction methods and CT images as input, preserving both topology and pore shape of the sample. For water-wet systems, we have validated our model with available experimental data from core floods. For oil-wet systems, we validated our network model by comparing 2D network simulations with published data from WAG floods in oil-wet micromodels. This demonstrates the importance of film and layer flow for the continuity of the various phases during subsequent WAG cycles and for the residual oil saturations. A sensitivity analysis has been carried out with the full 3D model to predict three-phase relative permeabilities and residual oil saturations for WAG cycles under various wetting conditions with different flood end-points.