Using three-dimensional smoothed particle hydrodynamics simulations, we investigate the formation of multiple stellar populations (MSPs) in globular clusters (GCs) within the context of their parent galaxies. In our scenario, the second generation (2G) of stars originate from both asymptotic giant branch (AGB) polluters and pristine gas accreted from the host galaxy. Previous theoretical and numerical studies have demonstrated that this 'AGB with dilution' model has the potential to alleviate several problems faced by the classical AGB scenario. However, the accretion of pristine gas on to the GC has yet to be investigated within the context of the parent galaxy. This paper presents the preliminary results from our original simulation code which models GC formation from giant molecular clouds in a host galaxy, and subsequent gas accretion on to the GC. By simulating the genesis of the 2G over a 370 Myr time frame, we demonstrate that the fraction of 2G stars are inextricably linked to the GC's environment. Our simulations rationalize the wide variety of abundance patterns, kinematics, and 2G concentrations by altering the initial conditions of both the GC progenitor and the host galaxy itself. Most notably, we reproduce a positive correlation between the fraction of 2G stars and the initial mass of the cluster. We discuss the physical implications of our scenario and compare our simulations with observations of the Galactic GC 47 Tucanae (47 Tuc). Finally, we present scaling relations that encompass the wider GC population and serve as a reference for future observations.