Spatial and ontogenetic variance in local densities modify selection on demographic traits