Electronic and optical properties of layered RE2Ti2O7 (RE = Ce and Pr) from first principles