Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

Implementing shader question

$
0
0

@Maedd wrote:

Hey!

I am trying to implement the blur shader from the examples into my code.
The problem is, that I can only see the image [index] = 1. [index] = 0 doesnt show. I would like to see them both at the same time. Can it be that it somehow gets overwritten by index = 1? If I dont use the blur-shader, I see both images at the same time. Any suggestions?
Thank you :slight_smile:

void ofApp::draw(){
    for(index = 0; index < 2; index++){
//here apparently only the index = 1 gets send to the BrightnessTreshold::draw() function, or maybe index = 0 gets visually overwritten by index = 1 ?
        bimg[index].draw(alpha[index], x[index], y[index], z[index], zoom[index], blur[index]);
    }
}


void BrightnessTreshold::draw(float alpha, float x, float y, float z, float zoom, float blur){

    fboBlurOnePass.begin();
        shaderBlurX.begin();
        shaderBlurX.setUniform1f("blurAmnt", blur);

  //--------------------------------------------------------------------- 
 // drawing the mesh, with a simple alphachannel - shader
    easyCam.setPosition(image.getWidth()/2, image.getHeight()/2, zoom);
    easyCam.begin();
        ofPushMatrix();
    
            ofTranslate(image.getWidth()/2, image.getHeight()/2);
                ofRotateXDeg(x);
                ofRotateZDeg(y);
                ofRotateYDeg(z);
            ofTranslate(-image.getWidth()/2, -image.getHeight()/2);
 
            shaderAlpha.begin();
                shaderAlpha.setUniform1f("alpha", alpha);
                mesh.draw();
            shaderAlpha.end();
    
        ofPopMatrix();
    easyCam.end();
  //---------------------------------------------------------------------  

        shaderBlurX.end();
    fboBlurOnePass.end();

    fboBlurTwoPass.begin();
        shaderBlurY.begin();
            shaderBlurY.setUniform1f("blurAmnt", blur);
            fboBlurOnePass.draw(0, 0);
        shaderBlurY.end();
    fboBlurTwoPass.end();
    
    ofSetColor(ofColor::white);
    fboBlurTwoPass.draw(0,0, w, h);
}

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles