Substance D is basically methamphetamine. Philip K. Dick was living in a houseful of speed-freaks during the period he was writing about in A Scanner Darkly.