Artifacts appearing in slitscan

Hi all

I’m creating a simple slitscan effect. I have a shader that executes 2 actions:

1 - Add a column of pixels from the centre of the camera feed to the far left of an ofFbo.
2 - Shift all the other pixels to the right.

Simple right? Well apparently not. I’m getting some strange artifacts appearing in a semi-repeatable way. They always appear to offset the pixels once they get to a certain point - the image below should explain this.

I’ve also tried this without the shader - drawing the fbo to itself, slightly offset with the slitscan column to the left - and saw the same issue. Any ideas?

Here’s the code stripped back as far as possible without using ofVideoGrabber:

testApp.h

  
  
#pragma once  
  
#include "ofMain.h"  
  
class testApp : public ofBaseApp{  
  
public:  
    void setup();  
    void update();  
    void draw();  
      
    ofShader slitscanShader;  
    ofFbo slitScanFbo;  
};  
  
  

testApp.cpp

  
  
#include "testApp.h"  
#define STRINGIFY(A) #A  
  
void testApp::setup()  
{     
    string shaderProgram = STRINGIFY(  
                                        uniform sampler2DRect tex0;  
                                        uniform float time;  
                                           
                                        void main(void)  
                                        {  
                                            if (gl_FragCoord.x < 4.0)  
                                            {  
                                                gl_FragColor = vec4(gl_FragCoord.y / 255.0,  
                                                                    (sin(time * 20.0) + 1.0) * 0.5,  
                                                                    0.0,  
                                                                    1.0);  
                                            }  
                                            else  
                                            {  
                                                gl_FragColor = texture2DRect(tex0, gl_FragCoord.st + vec2(-4, 0));  
                                            }  
                                        }  
                                     );  
      
    slitscanShader.setupShaderFromSource(GL_FRAGMENT_SHADER, shaderProgram);  
    slitscanShader.linkProgram();  
      
    ofFbo::Settings settings;  
    settings.width = 480;  
    settings.height = 480;  
    settings.internalformat = GL_RGBA;  
    settings.numSamples = 0;  
    slitScanFbo.allocate(settings);  
}  
  
void testApp::update()  
{  
    slitScanFbo.begin();  
    slitscanShader.begin();  
    slitscanShader.setUniform1f("time", ofGetElapsedTimef());  
    slitScanFbo.draw(0, 0);  
    slitscanShader.end();  
    slitScanFbo.end();  
}  
  
void testApp::draw()  
{  
    slitScanFbo.draw(0, 0);  
}  
  

![](http://forum.openframeworks.cc/uploads/default/3061/Screen Shot 2013-10-28 at 17.49.09.png)