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

Use ofFbo with shaders

$
0
0

@UmiKOMPnMI4QrmG wrote:

i want to use ofFbo in shader.

ofFbo one,two;
ofEasyCam cam;
ofShader shader;


void setup(){
    int w=ofGetWidth();
    one.allocate(w/4,w/4);
    two.allocate(w/4,w/4);
    one.begin();

	ofPushMatrix(); ofTranslate(w / 8, w / 8);
	ofSphere(22);
	ofPopMatrix();

	one.end();

	shader.begin();
	shader.setUniformTexture("texture",one.getTexture(), 0);
    shader.setUniformMatrix4f("mvpM", cam.getModelViewProjectionMatrix());
    shader.setUniformMatrix4f("tM", tMatrix);
	two.draw(0, 0);
	shader.end();
}

void draw(){
    cam.begin();
	two.draw(0, 0);
	cam.end();
}

Shader contents↓

uniform mat4 mvpM;
uniform mat4 tM;// ofMatrix4x4(0.5,0,0,0,  0, 0.5,0,0,  0,0, 1,0, 0.5, 0.5,0,1);
in vec4 position;
in vec4 texcoord;
out vec4 vTexCoord;

void main() {
    vTexCoord=tM*texcoord;
    gl_Position = mvpM*position;
}

//fragmentShader

uniform float time;
uniform sampler2D  tex;
in vec4 vTexCoord;
out vec4 fragColor;

void main (void) {
    vec4 Col=texture(tex,vTexCoord.xy);
    fragColor=Col;
}

but, this makes the screen black

If drawn with (Fbo)one.↓

I want to make the drawing result of (Fbo)one the same as the drawing result of (Fbo)two.
....Help me

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles