At some point of the story, the main character encounters this scientist that gives him some mechanism (a drug, or some kind of mask that filters the element that creates the illusion) that allows him to see the real world and, for example, people are pretending to be driving cars but in reality they are just walking around.
At some point of the story the main character takes a more powerful version of this drug/filter and looks at the scientist, and his body, that had recently undergone surgery, is just a mess of tubes and pipes.
I probably read it like 10 years ago, it was either a short book or just a sci-fi story.
I think I saw later a movie based on this story/book, where they mix real people with animation, starts with a woman driving a convertible in the desert and when he approaches this complex, at some point cartoons and fantasy stuff start to pop out.