Infinte Scene Feedback

Hey guys, Im building a scene and would like to be able to have the infinite feedback effect in my code.

I am able to achieve this by feedback a screen share on my mac laptops or by pointing a camera at a tv displaying the camera live feed but would love to be able to have the endless mirror effect on an openFrameworks scene.

I have posted an image below of the effect im after. Any suggestions on any techniques I should use or how to go about something like this? Thanks.

a very simple way of doing this is with an ofImage or texture, grabbing the screen, and then redrawing it. texture will be faster then ofImage, because it’s grabbing the screen data on the graphics card, and not back into RAM.

here’s a simple example:

in testApp.h:

float position;  
ofTexture screenImage;  

in testApp.cpp:

void testApp::setup(){  
	position = 0;  
	screenImage.allocate(ofGetWidth(), ofGetHeight(), GL_RGBA);  
void testApp::update(){  
	position = 500 + 250 * sin(ofGetElapsedTimef()*4);  
	screenImage.loadScreenData(0,0,ofGetWidth(), ofGetHeight());  
void testApp::draw(){  
	screenImage.draw(0+40, 0+40, ofGetWidth()-80, ofGetHeight()-80);  
	ofCircle(position, 200,20);  
	screenImage.loadScreenData(0,0,ofGetWidth(), ofGetHeight());  

the loadScreenData() is grabbing the screen pixels into a texture at the end of the draw function, and the texture is being drawn at the start.

hope this helps!

Yep that’s exactly it. Thanks Zach!! woo! this is awesome fun.


old post, great fun !

i’ve tried @zach code and even if i disable the antialiasing i get a very blurred image “inside” the feedback …
is there a way to make all this more “pixel crispy” ?


you can try this on setup:

screenImage.setTextureMinMagFilter(GL_NEAREST, GL_NEAREST);

it stops the pixel interpolation that ofTexture has by default.
but you will see that in some cases is not working as desired :confused:

thanks for bringing this up again! old post, great fun !

hi @Jordi !

Thanks for your tip ! … Yes that is solving the “blurry” iteration on the feedback loop … but as you suggested it turns into another thing and it doesn’t work at all as desired …
So I’m starting to try to do it all inside a shader to see how it goes … Anyone has done that already ? A video feedback GLSL shader on the GPU ? Doing it on the GPU gives me the hability to tweak, blend, rotate, scale the feedback loop inside the same shader and so be able to get high framerates … 120fps will be my goal.

My idea is to have an FBO where you draw the “present time” picture which will be then “feed” into the feedback loop. For the loop i think i need a PingPong FBO render as I read in some post in GLSL you can’t write to a texture that your’re reading …

So i’ll try this approach … Am i on a good direction ? Or maybe there’s a very obvious way of doing so ?

ooohhhh sounds juicy @eloi let me know if you end up successfully making this using glsl!