Honestly it comes and goes. Sometimes you just have to either slog through the valley, or accept that you're in a valley and seek joy elsewhere until you get through it. All the while, keep looking for new stuff, staying curious, learning.. that'll insure you have a big backlog of interesting things to get motivated about the next time you're back on an upswing.