The use of efficient design parameters in the initial stages of the life cycle of a building project helps to reduce the final energy demand. This article presents research results on the relation between the morphology of a building and its energy efficiency. Three types of residential buildings are analyzed: the single-family detached house, semidetached house and multidwelling building. The cases studied modeled in EnergyPlus to obtain building energy consumption per useful built surface. Also considered is the energy produced, thanks to the installation of photovoltaic solar panels on the building roof and on 50 % of the south façade surface. The paper provides a method to obtain the curve that shows the difference between the energy demand of residential buildings for various uses (HVAC, lighting, etc.) and the energy generated by installed solar panels in the building. The results reveal that the single-family detached housing model is the less energy-efficient. In the case of multidwelling houses, the optimal building height is obtained to reduce building energy consumption depending on total useful built area. The results show that up to 25 % of multidwelling building energy demand can be satisfied by solar energy on the rooftop and the façade. The balance between the energy demand and energy production of the building highlights the dimensional parameters that define optimal building shape from an energy efficiency perspective. The results obtained can be usefully applied to estimate the optimal geometric characteristics for a building of the same total surface area, which maximally reduces the final energy demand.