A Scanner Darkly is a science fiction story that reflects the harsh realities of 1970s drug culture. In the novel, undercover cop Bob Arctor takes the illegal drug Substance D in order to pass as a dealer; however, one of the drug's side effects is a split in the two hemispheres of the brain, so Bob quickly loses his grasp on his two identities and two realities. The book delves into the theme of inner versus outer identity and examines the theme of sacrifice for the greater good.
The protagonist is Bob Arctor, member of a household of drug users, who is also living a parallel life as Agent Fred, an undercover police agent assigned to spy on Arctor's household. Arctor/Fred shields his identity from those in the drug subculture and from the police. (The requirement that narcotics agents remain anonymous, to avoid collusion and other forms of corruption, becomes a critical plot point late in the book.) While posing as a drug user, Arctor becomes addicted to "Substance D" (also referred to as "Slow Death", "Death" or "D"), a powerful psychoactive drug. A conflict is Arctor's love for Donna, a drug dealer, through whom he intends to identify high-level dealers of Substance D.
When performing his work as an undercover agent, Arctor goes by the name "Fred" and wears a "scramble suit" that conceals his identity from other officers. Then he is able to sit in a police facility and observe his roommates through "scanners," audio-visual surveillance devices that are placed throughout the house. Arctor's use of the drug causes the two hemispheres of his brain to function independently or "compete". When Arctor sees himself in the videos saved by the scanners, he does not realize that it is him. Through a series of drug and psychological tests, Arctor's superiors at work discover that his addiction has made him incapable of performing his job as a narcotics agent. They do not know his identity because he wears the scramble suit, but when his police supervisor suggests to him that he might be Bob Arctor, he is confused and thinks it cannot be possible.
Donna takes Arctor to "New-Path", a rehabilitation clinic, just as Arctor begins to experience the symptoms of Substance D withdrawal. It is revealed that Donna has been a narcotics agent all along, working as part of a police operation to infiltrate New-Path and determine its funding source. Without his knowledge, Arctor has been selected to penetrate the organization. As part of the rehab program, Arctor is renamed "Bruce" and forced to participate in cruel group-dynamic games, intended to break the will of the patients.
The story ends with Bruce working at a New-Path farming commune, where he is suffering from a serious neurocognitive deficit, after withdrawing from Substance D. Although considered by his handlers to be nothing more than a walking shell of a man, "Bruce" manages to spot rows of blue flowers growing hidden among rows of corn and realizes that the blue flowers are Mors ontologica , the source of Substance D. The book ends with Bruce hiding a flower in his shoe to give to his "friends"—undercover police agents posing as recovering addicts at the Los Angeles New-Path facility—on Thanksgiving.