An optimal band gap that allows for a high solar-to-fuel energy conversion efficiency is one of the key factors to achieve sustainability. We investigate computationally the band gaps and optical spectra of functional perovskites composed of layers of the two cubic perovskite semiconductors BaSnO3 and BaTaO2N. Starting from an indirect gap of around 3.3 eV for BaSnO3 and a direct gap of 1.8 eV for BaTaO2N, different layerings can be used to design a direct gap of the functional perovskite between 2.3 and 1.2 eV. The variations of the band gap can be understood in terms of quantum confinement and tunneling. We also calculate the light absorption of the different heterostructures and demonstrate a large sensitivity to the detailed layering.