This paper presents a methodology for applying continuously varying density distributions in Monte Carlo particle transport simulation. The capability is implemented in the Serpent 2 code, as part of an effort for developing a universal multiphysics interface for the coupling of Monte Carlo neutronics to thermal hydraulics and fuel performance codes. The method is based on rejection sampling of particle path lengths, but despite its close resemblance to the Woodcock delta-tracking method, the routine can be used with conventional surface tracking as well. The modified tracking routine is put to the test in a simple boiling water reactor pin-cell calculation with continuously changing void distribution in the coolant channel.