A Utah college professor stopped in the middle of his macroeconomics lecture to confess to his students that he had viewed child pornography, according to a new report.

The 42-year-old part-time instructor at Utah Valley University, whose name was not released, started discussing his addiction out of the blue Dec. 3, a search warrant affidavit obtained by KSL-TV revealed.

The campus police department reviewed video of the lecture, which was recorded on a thumb drive, before contacting the Department of Homeland Security, the outlet reported.

About an hour and a half into his class, the professor “ceases his discussion of the subject matter related to macroeconomics and begins talking to his students about taking them on a/his ‘spiritual journey.’ It was during this portion of the video that [he] makes statements about his involvement with viewing child pornographic materials,” the affidavit said.

“Tonight I am going to beg your pardon to share my filth with you,” he continued, according to the document. “The very worst thing that I can share with you is the fact that I have seen youth — beautiful, wonderful children of this earth, in compromising positions, and sexual positions. … If we are talking about a line in the sand then we are taking it south of an area that we shouldn’t be. … I’m sorry, but I have seen that.”

He insisted that he had never inappropriately touched anyone and does not have a “library” of these lewd images — “except what is in his head,” according to the affidavit.

“If you are a human being who I saw, I am not sorry that I saw you … as terrible as that sounds,” the instructor continued. “I am sorry that I looked at you in that way. … I am sorry that I chose to look at you in that way.”

He referred to his porn-viewing habit as “not art” and “embarrassing,” the court document revealed.

Several students anonymously filed ethics complaints about the in-class confession, according to the report.

The professor did not mention the ages of the children whose images he said he viewed, one student wrote. He also declined to include when the viewing occurred or whether he faced disciplinary action.

A Homeland Security investigator obtained a warrant to search the professor’s home and seize any electronic items that might contain child pornography, the station reported. It wasn’t clear what specifically was removed from the home.

The instructor “was confronted about his in-class confession” by Laura Carlson, the school’s director of equal opportunity/affirmative action, on Dec. 4 — and then he resigned, according to the affidavit.

Scott Trotter, a spokesman for the school, told the outlet that the teacher “was employed at Utah Valley University from August 2014 to December 2018,” but no longer works there.

He had not been arrested or charged by Thursday, according to the station — and phone messages left for him went unreturned.