... or simply this way, no matter which scale_fill_* or scale_color_* function you use:
library(tidyverse)
ggplot(faithfuld, aes(waiting, eruptions)) +
geom_raster(aes(fill = density), alpha = 0.5) +
scale_fill_gradientn(colours = terrain.colors(10))
If you want to have changing alpha values, you map to it inside the aes as you do with any other aesthetic: geom_tile(aes(fill = density, alpha = x).