Most of this was just copied from the TerrainPopulatedRenderer class