change material concurrently

I working on an AI project with UE4.17 Currently I want to change material in one frame take a photo, and change it back to the originally material all in one frame. However, I noticed that if I call SetMaterial(0, TheMaterial), it will markRender state dirty and render at the end of the frame, so I cannot achieve what I want. Is there any work around for this problem?