A Scanner Darkly ( 1977 ) is a bleak mixture of science fiction and police procedural novels . In its story , an undercover narcotics police detective begins to lose touch with reality . A Scanner Darkly ( 1977 ) is a bleak mixture of science fiction and police procedural novels ; in its story , an undercover narcotics police detective begins to lose touch with reality after falling victim to the same permanently mind altering drug , Substance D , he was enlisted to help fight .