First, the sand must undergo the process of lithification, where it gets compacted and cemented together to form sandstone. Then, through the process of metamorphism, the sandstone undergoes high temperatures and pressure deep within the Earth's crust, transforming it into metamorphic rock.