ofShader: why can I only define 3 shaders?


I am using the ofShader addon to load and compile my shaders. But when I try to load more than three shaders I only get a blank screen without any errors. Even if I define more than 3 shaders without loading them nothing happenes anymore. Is there a solution for that?


EDIT: I just realised that it has something to do with the amount of FBOs I define too. Is there maybe a limit in openGL for things like that?

EDIT2: I think I solved it. I messed up the texture targets to render to thats why I didn’t see anything. Sorry for this thread.

OK!!! I just understand that the last id is not the texture ID but the id where we want the texture loaded. So after 16 can’t load more. stupid me!
I let the post active, that can be usefull for someone else!

I got quite the same problem. Only three of my objects are rendered with a shader even if more are rendered.
So, I have different objects render on a quad (up to 10) with some small video inside. For each I have 4 videoTexture, one mask and one other choosed in 3 depending on the life of the objects. I use the same shader for each objects. I can’t see only the first 3 with shader rendering. If I render by binding textures, all are rendering.

Here is the code to draw the object

rs->bubbleShaderBegin(isPresent, presentCoeff, isExplode, theta, theta2, pastTex, presentTex, alphaTex, explodeTex);  
        cout<<"shader inited with tex id : "<<pastTex.getTextureData().textureID<<", "<<presentTex.getTextureData().textureID<<", "<<alphaTex.getTextureData().textureID<<", "<<explodeTex.getTextureData().textureID<<endl;  
        glTexCoord2f(0., 0.);  
        glVertex3f(posX-sWidth/2., posY-sHeight/2., posZ);  
        glTexCoord2f(width, 0.);  
        glVertex3f(posX+sWidth/2., posY-sHeight/2., posZ);  
        glTexCoord2f(width, height);  
        glVertex3f(posX+sWidth/2., posY+sHeight/2., posZ);  
        glTexCoord2f(0., height);  
        glVertex3f(posX-sWidth/2., posY+sHeight/2., posZ);  
        glEnd() ;   

rs is a singleton with different rendering tools including my shader
and is the call of the shader

void RenderSingleton::bubbleShaderBegin(bool isPresent, float presentCoeff, bool isExplode, float theta, float theta2, ofTexture &pastTex, ofTexture &presentTex, ofTexture &alphaTex, ofTexture &explodeTex){  
    bubbleShader.setUniform1f("alphaCoeff", alphaCoeff);  
    bubbleShader.setUniform1f("contrast", contrast);  
    bubbleShader.setUniform1f("saturation", saturation);  
    bubbleShader.setUniform1f("presentCoeff", presentCoeff);  
    bubbleShader.setUniform1f("isExplode", isExplode);  
    bubbleShader.setUniformTexture("past", pastTex, (GLuint)pastTex.getTextureData().textureID);  
    bubbleShader.setUniformTexture("present", presentTex, (GLuint)presentTex.getTextureData().textureID);  
    bubbleShader.setUniformTexture("mask", alphaTex, (GLuint)alphaTex.getTextureData().textureID);  
    bubbleShader.setUniformTexture("explode", explodeTex, (GLuint)explodeTex.getTextureData().textureID);  
void RenderSingleton::bubbleShaderEnd() {  

finally, here is the shader

#extension GL_ARB_texture_rectangle : enable  
const vec3 LumCoeff = vec3 (0.2125, 0.7154, 0.0721);  
uniform sampler2DRect past;  
uniform sampler2DRect present;  
uniform sampler2DRect mask;  
uniform sampler2DRect explode;  
uniform vec3 avgluma;  
uniform float saturation;  
uniform float contrast;  
uniform float brightness;  
uniform float alphaCoeff;  
uniform float presentCoeff;  
uniform bool isExplode;  
void main()  
	vec2 pos = gl_TexCoord[0].xy ;  
    vec4 pastColor = texture2DRect(past, pos);  
    vec4 presentColor = texture2DRect(present, pos);  
	vec4 maskColor = texture2DRect(mask, pos);  
    vec3 fragColor =  mix(pastColor.rgb, presentColor.rgb, presentCoeff);  
	vec3 intensity 	= vec3 (dot(fragColor, LumCoeff));  
	vec3 color     	= mix(intensity, fragColor.rgb, saturation);  
	color          	= mix(avgluma, color, contrast);  
	color			*= brightness;  
    if (isExplode){  
        //vec4 explodeColor = texture2DRect(explode, gl_TexCoord[0].xy);  
        vec4 explodeColor = texture2DRect(explode, pos);  
        explodeColor.rgb = explodeColor.rgb * vec3(-1.) + vec3(1.);  
        gl_FragColor = vec4(color, explodeColor.r*alphaCoeff) ;  
    }else {  
        gl_FragColor = vec4(color, maskColor.r*alphaCoeff) ;  
        //gl_FragColor = vec4(color, 1.) ;  

any idea what I’m doing wrong?

1 Like