A new report out today in Energy and Environmental Science shows that a conversion to an 80 percent solar and wind-based energy system is possible in the United States, but it will require a significant advancement in energy storage technologies or hundreds of billions of dollars invested in renewable energy infrastructure.

The researchers looked at 36 years’ worth of hourly sun and wind data in the continental US in order to get a better understanding of the unique geophysical barriers faced by renewable systems in the US.

“The sun sets and the wind doesn’t always blow,” Steven Davis, an associate professor of Earth system science at UC Irvine, said in a statement. “If we want a reliable power system based on these resources, how do we deal with their daily and seasonal changes?”

The first step in the process was identifying just what those seasonal changes were and how they related to seasonal energy demand. Obviously, solar power can only be collected during the day, but the amount of solar energy available also fluctuates with the seasons—there’s 3.7 times more sun during the longest days of the summer compared to the shortest days of winter.

Wind availability is much more variable than the sun, although the amount of wind available peaks in spring and hits a low during the summer months. But the fluctuations in wind availability on a daily basis is pretty irregular and can be hard to predict, which makes wind-power the less reliable of the two main renewable energy options considered in the paper.

This new report is not the first time that scientists have claimed that a four-fifths renewable energy grid is possible in the US. A 2012 report commissioned by the US Department of Energy’s National Renewable Energy Laboratory claimed that the US could meet 80 percent of its electricity needs with renewable energy by 2050. Likewise, a 2016 study published in Nature found that it is possible to reduce 80 percent of US carbon emissions with an optimized network of wind and solar generators with current technologies and without storage.

Both of these studies came under fire in a study published in The Proceedings of the National Academy of Sciences last year, which cited methodological lapses as the source of the reports’ incredibly optimistic outlook for the future of renewable energy in the US.

The difference with the new report is that it is much more tempered when it comes to the difficulties of transitioning to an 80 percent solar and wind-powered economy. The primary barriers in this respect are transmission and storage.

When it comes to wind energy, access to this resource varies greatly with geographic location. This means that an area rich in wind resources but low in energy demand will experience a glut of energy. To make an 80 percent renewable energy economy work, this energy will have to be transferred elsewhere with minimal loss. According to the report’s authors, this could be accomplished with a cross-country network of high voltage transmission lines, although this infrastructure project would cost hundreds of billions to execute.

Still, this is cheaper than the other option considered by the researchers, which is to rely on a network of large energy storage facilities. These would essentially function as massive batteries that could be used at night when solar energy isn’t available.

Read More: Inside the Tesla Gigafactory Opening Party

The US has a power demand of 450 gigawatts, which means that a network of energy storage facilities able to bank 12 hours of solar energy at a time would need to have a storage capacity of approximately 5.4 terrawatt-hours. According to the researchers, this much storage capacity would take the Tesla Gigafactory—Elon Musk’s giant battery production facility in Nevada—150 years to produce at current rates, and cost over $1 trillion.

Ultimately, the study highlights the need for cheap energy storage solutions as a prerequisite for transitioning to a majority renewable energy grid in the US. Musk’s foray into ultra-efficient battery production with the Gigafactory is a step in that direction, but will not be nearly enough to support a robust renewable economy. In the meantime, the researchers say low-carbon-emission sources of energy, such as nuclear power, will be necessary to keep the lights on in the US.

Still, the researchers are hopeful that a transition to a mostly solar and wind-energy regime is possible.