I decide I want to try a bit of "something new", and I pay someone to induce a Capgras delusion in me. At which point, my wife seems like an imposter. I wish to have sex with this new person, and I am also sure my real wife has given me permission to, prior to this. You can tell me as much as you like that it's "really" my wife, but, in my delusion, I am quite sure it's just someone who looks like her, and delightfully and consentfully have sex with the imposter new person -- who is giving their consent the whole time -- with all the thrill that entails. Afterwards, the delusion wears off, and I realise it was just sex with my wife. Everyone has consented at every point to this.
If I am suffering a delusion, and you know that, then you know that I am not mentally competent. You know that, if I agree to something, I do not correctly understand what I am agreeing to. Any expression of consent you extract from me is invalid.
The consent during cannot be valid. It's not informed: in fact it's specifically misled, and that is known to the other participant.