There’s a lot of good answers here that talk about the different parts of the brain.
What I feel might be missing here is that a brain cannot really simulate reality. Imagination only lets us relive our senses, like sight and hearing. Our eyes bring in light to create 2D pictures. We can never imagine a truly 3D picture. Yet our world is 3D.
So how does the brain let us imagine? Well it simply uses the same functions that it uses when you see or hear things for real. But instead of asking the eyes of ears for input, it uses past inputs that have been stored in memory.
Latest Answers