A Scanner Darkly

The United States has lost the war on drugs. Substance D, a powerful and dangerous drug that causes bizarre hallucinations, has swept the country. Approximately 20% of the total population is addicted. In response, the government has developed an invasive, high-tech surveillance system and a network of undercover officers and informants.
Bob Arctor is one of these undercover agents, assigned to immerse himself in the drug's underworld and infiltrate the supply chain. Sometime in the past, Arctor was abandoned by his wife and two children, leaving him alone in a now-rundown suburban house in Anaheim, California; the house has since been repopulated by Arctor's two drug-addicted, layabout housemates: Luckman and Barris. The three spend their days intoxicated and having long, paranoiac conversations. At the police station, Arctor maintains privacy by wearing a "scramble suit" that constantly changes every aspect of his appearance and he is known only by the code name "Fred." Arctor's senior officer, "Hank", and all other undercover officers, also wear scramble suits, protecting their identities even from each other.
Since going undercover, Arctor himself has become addicted to Substance D and he has befriended the main woman he has been spying on: a cocaine addict and Substance D supplier named Donna. Arctor hopes to purchase large enough quantities of Substance D from Donna that she is forced to introduce him to her own supplier, but he has also developed seemingly unrequited romantic feelings towards her.
At work, Hank orders Arctor to step up surveillance on Donna and her associates; however, Arctor's house is now at the center of his own investigation, since this is where Donna and the other addicts in her and Arctor's life now spend most of their time. Hank names Bob Arctor as the suspected ringleader, and thus orders Arctor to spy on himself. Arctor, therefore, has to even more carefully plan his double life, though his prolonged use of Substance D is damaging his brain, causing him to sometimes forget his own identity. Meanwhile, the justified paranoia of Arctor's housemates reaches extreme levels, and Barris secretly communicates to the police his exaggerated belief that Donna and Arctor are terrorists; Barris unknowingly conveys this information in the presence of Arctor himself, whose identity at the time is hidden behind his scramble suit.
After Barris supplies the police with a faked recording allegedly proving his claims about Donna and Arctor, Hank orders that Barris be held on charges of providing false information. After Barris's arrest, Hank reveals to Arctor that he has deduced him to be the true identity of "Fred" by a process of elimination. Arctor seems legitimately surprised and repeats his own name in a disoriented, unfamiliar tone. Hank informs him that the real purpose of the surveillance was to catch Barris, not Arctor, and that the police were deliberately increasing Barris's paranoia until he attempted to cover his tracks. Hank reprimands Arctor for becoming addicted to Substance D, and warns him that he will be disciplined, likely with just a fine but possibly a few months of penal labor. Hank "phones" Donna, asks her to take Arctor to New-Path, a corporation that runs a series of rehabilitation clinics, and Arctor, who is rapidly becoming more disoriented, leaves Hank's office, cursing Hank aloud. Afterwards, Hank enters the locker room and removes his scramble suit, revealing his true identity to the audience: Donna. At the New-Path clinic, Arctor experiences the symptoms of Substance D withdrawal, including more severe brain damage. He mindlessly repeats what others tell him and utters mostly simplistic responses.
Some time later, Donna (revealed to be another false name) converses with a fellow police officer, Mike, and the audience learns that New-Path is responsible for the manufacture and distribution of Substance D; ironically they use victims of the drug to tend their crops, since (being nearly mindless) they can be trusted not to reveal New-Path's secret. Donna expresses her growing ethical aversion to their police work, in which they deliberately selected Arctorâwithout his knowledgeâto become addicted to Substance D all along; his health was sacrificed so that he might eventually enter a New-Path rehabilitation center unnoticed as a genuine addict and collect incriminating evidence of New-Path's Substance D farms. Donna and Mike debate whether Arctor's mind will recover enough so that he grasps the situation and returns from serving his sentence with substantial evidence to shut down New-Path.
In the final scene, New-Path gives Arctor a new name and sends him from the clinic to a labor camp at an isolated New-Path farm, where he spots rows of blue flowers hidden between rows of corn. These flowers, referenced throughout the film, are the source of Substance D. As the film ends, Arctor hides a blue flower in his boot, apparently prepared to hand it over to the authorities during his upcoming Thanksgiving respite, though it is not at all clear whether he has recovered enough of his mental faculties to do so.
End credits[edit]
The end credits feature an abridged version of the afterword of Philip K. Dick's novel, in which Dick lists people he knew who have suffered serious permanent physical or mental damage (brain damage, psychosis, pancreatic trauma, etc.) or death as a result of drug use. Dick includes his own name on the list, as "Phil", a victim of permanent pancreatic damage.
Linklater adds another name to the credits and dedicates the film to the memory of Louis H. Mackey, an influential philosophy professor at the University of Texas at Austin; he had appeared in two of Linklater's previous films. Mackey died in 2004.

Question: Whose novel do the end credits feature?
Answer: Philip K. Dick's novel.