Intentional Hall of Mirrors Shader

Godot Version

4.3

Question

I’m very new to Godot Shaders and I was aiming to create what I had hoped was a simple effect. I’m trying to create a material shader I can apply to both meshes and (potentially, depending on compatibility) the sky shader which emulates a retro-game effect typically called “Hall of Mirrors” (Hall of mirrors effect | Doom Wiki | Fandom) where the frame buffer is not cleared and uses the data from the previous buffer instead.

I figured the shader would be two parts, one to render a texture with screen space coordinates so the UV is aligned to the screen at all times (again, I’m new to a lot of these terms outside of a modelling software context so please excuse any misuse), and the other to capture the previous frame and use it as this texture from part one.

I’ve tried this a couple of different ways, manually grabbing the viewport.get_texture() and passing it in to the shader as an albedo parameter in _process, using RenderingServer.viewport_set_clear_mode to NEVER to try to keep the buffer from being overwritten with the default fill color, and other combinations of these along with a BackBufferCopy node, etc.

So to state a few tangible questions;

  1. Is this effect something I can achieve in Godot without having to hack into the render code
  2. How to actually accomplish this with shaders and/or scripts.