The Nets will have about $40 million in cap space this summer, and they got an up-close look Wednesday at one of their primary expected targets: DeMar DeRozan.

The Toronto shooting guard had 15 points, five assists, four boards and two steals in the Raptors’ 91-74 win at Barclays Center. He has a player option worth just more than $10 million for next season, but a source close to DeRozan told The Post that he will opt out, becoming a free agent. But that doesn’t guarantee he’ll be a Net, or anything other than a Raptor.

“I can tell you he’ll opt out. But how he feels about Brooklyn — or anybody else — I can’t say. Only he can answer that,’’ said the source, who added that DeRozan feels he’s been treated well by the Raptors and “has a trait that’s been lost by so many players. It’s called loyalty.”

DeRozan came into Wednesday 11th in the league in scoring at 22.9 points per game, and averaged 25.0 on 47.1 percent shooting last month, cutting down on his jump shots and getting to the rim or the line consistently. In short, he’d be just what the Nets need.

With starting point guard Jarrett Jack gone and backups Shane Larkin and Donald Sloan green, the Nets need Joe Johnson more than ever. They need him to not only pick up the scoring slack for Jack, but some of the playmaking as well. But after his first consecutive 20-point games since March 2014, Johnson came back to earth with five points on 2-of-7 shooting and team-worst minus-18.

“It was just a lack of ball movement. The ball stick and we took a lot of tough shots,’’ said Johnson of the Nets’ offensive woes. “I thought the defense was solid for a good part of the game, but they went on a little run. … For the most part defensively is pretty good; offensively is where we’re hurting ourselves.’’

About the only highlight was Brook Lopez (game-high 24) hitting a no-look circus shot behind his back as he was fouled. Naturally, he missed the foul shot. It was that kind of game.

The Nets didn’t have to face DeMarre Carroll after the Toronto forward had arthroscopic surgery on his right knee that morning.