shader is noisy

https://github.com/daanvanhasselt/lensflare

i used this lensflare example successfully on multiple occasions but recently i migrated to a mac mini with intel hd graphics 4000 512 mb and the light scatter shader creates strange noise.

i see the same on a laptop with NVIDIA GeForce GT 650M 1024 MB, not thought on a mac mini with the radeon graphics card.

all computers run mountain lion.

i draw the shader inside an FBO because i want to run the resulting image through some other shaders.

but somehow the shader produces a very pixilated noisy image.

???thx

.vert

  
  
  
varying vec2 texCoordVar;  
  
void main(){  
   // texCoordVar[0] = gl_MultiTexCoord0; //.st;  
    texCoordVar = gl_MultiTexCoord0.st;  
	gl_Position = ftransform();  
}  
  

.frag

  
  
#version 120  
#extension GL_ARB_texture_rectangle : enable  
  
uniform float exposure;  
uniform float decay;  
uniform float density;  
uniform float weight;  
uniform vec2 lightPositionOnScreen;  
  
uniform sampler2DRect firstPass;  
  
varying vec2 texCoordVar;  
  
const int NUM_SAMPLES = 100;  
  
void main(){  
    vec2 texCoord = texCoordVar; //[0].st;  
 //   vec2 texCoord = texCoordVar[0].st;  
  
    vec2 deltaTextCoord = vec2( texCoord - lightPositionOnScreen.xy );  
    deltaTextCoord *= 1.0 / float(NUM_SAMPLES) * density;  
    float illuminationDecay = 1.0;  
      
    for (int i = 0; i < NUM_SAMPLES; i++) {  
        texCoord -= deltaTextCoord;  
        vec4 sample = texture2DRect(firstPass, texCoord);  
        sample *= illuminationDecay * weight;  
        gl_FragColor += sample;  
        illuminationDecay *= decay;  
    }  
    gl_FragColor *= exposure;  
}  
  

.cpp

  
  
  
scattering.load("shaders/lightScattering2");  
  
	ofFbo::Settings settings;  
    settings.width = ofGetWidth();  
    settings.height = ofGetHeight();  
    settings.internalformat = GL_RGB; //A32F; //GL_RGBA;  
	  
    lightRays.allocate(settings);  
  
    lightRays.begin();  
	ofClear(0);  
	scattering.begin();  
   
  	scattering.setUniform1f("exposure", exposure);  
	scattering.setUniform1f("decay", decay);  
	scattering.setUniform1f("density", density);  
	scattering.setUniform1f("weight", weight);  
	scattering.setUniform2f("lightPositionOnScreen", lightPosition.x, lightPosition.y);  
    scattering.setUniformTexture("firstPass", firstPass, 0);  
  
	  
	firstPass.draw(0, 0);  
  
 /*  
    glBegin(GL_QUADS);  
      // firstPass.bind();  
    	//glBegin(GL_POLYGON);  
	int x = 0;  
	int y = 0;  
  
     
	glTexCoord2f(x, y);  
	glVertex2f(x, y);  
	  
	x = ofGetWidth();  
	glTexCoord2f(x, y);  
	glVertex2f(x, y);  
	  
	y = ofGetHeight();  
	glTexCoord2f(x, y);  
	glVertex2f(x, y);  
	  
	x = 0;  
	glTexCoord2f(x, y);  
	glVertex2f(x, y);  
//	 firstPass.unbind();  
      
	glEnd();  
   */  
      
	  scattering.end();  
    lightRays.end();  
  
  

sometimes i get this error:
[error] GL_VERTEX_SHADER shader failed to compile
[error] GL_VERTEX_SHADER shader reports:
ERROR: 0:6: Incompatible types (float and vec4) in assignment (and no available implicit conversion)

when i change the shader code to use texCoordVar[0].st

thanks to the great people on the openframeworks freenote channel i was able to debug my shader problem.

here is the shader code:

.vert

  
  
#version 120  
  
varying vec2 texCoordVar;  
  
void main(){  
    texCoordVar = gl_MultiTexCoord0.st;  
	//gl_Position = ftransform();  
     gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;  
}  
  

.frag

  
  
#extension GL_ARB_texture_rectangle : enable  
  
  
uniform float exposure;  
uniform float decay;  
uniform float density;  
uniform float weight;  
uniform vec2 lightPositionOnScreen;  
  
uniform sampler2DRect firstPass;  
  
varying vec2 texCoordVar;  
  
  
const int NUM_SAMPLES = 100;  
  
void main(){  
    vec2 texCoord = texCoordVar;  
    vec2 deltaTextCoord = vec2( texCoord - lightPositionOnScreen.xy );  
    deltaTextCoord *= 1.0 / float(NUM_SAMPLES) * density;  
  
    float illuminationDecay = 1.0;  
      
    vec4 tmpColor = vec4(0.0,0.0,0.0,0.0); //gl_FragColor;  
   
    for (int i = 0; i < NUM_SAMPLES; i++) {  
        texCoord -= deltaTextCoord;  
       vec4 sample = texture2DRect(firstPass, texCoord);  
       sample *= illuminationDecay * weight;  
        tmpColor += sample;  
        
        illuminationDecay *= decay;  
    }  
    tmpColor*= exposure;  
      
     gl_FragColor = clamp(tmpColor,vec4(0.0,0.0,0.0,0.0),vec4(1.0,1.0,1.0,1.0)); //  
}  
  

it was tested on a mid 2012 mbp with with retina screen, which has intel HD Graphics 4000 512 MB and NVIDIA GeForce GT 650M.
osx 10.8.2

and

a late 2012 mac mini intel HD Graphics 4000 512 mb, 2.3 ghz core i7
osx 10.8.2

as mentioned the shader was running well on macs with radeon but in combination with other code i noticed a frame drop/ stutter. so i tried a mac with intel graphics card.

on these machines the shader seems to work but i still see a stutter.
min 2011
2.7 ghz intel core i7
8gb
amd radeon hd 6630M 256 mb
10.7 and 10.8

the shader part of this lens flare simulation project. it creates a bit of a light scatter.
http://lozano-hemmer.com/semioptics-for-spinoza.php