Solar panels need sunlight, but not necessarily direct sunlight to generate electricity. They can still produce power on cloudy or overcast days, although output will be lower than in bright, direct sun. Modern panels are designed to work in a range of light conditions, and diffuse light can still be converted into electricity.
The amount of power you get depends on factors like the angle and orientation of the panels, shading from nearby trees or buildings, and how often sunlight reaches the array during the day. Even if panels are not in full sun, they can contribute to your energy needs, especially when paired with a battery system that stores excess power for later use.
If your roof has significant shading or faces a poor direction, a site survey can help determine whether solar panels are still a practical option and what output you can expect.