0
\$\begingroup\$

Very simple question: Is it possible to process a vbo through different shaders? If so, how? What I want is sth like this:

reflectionShader.bind(); //starts shader
reflectionShader.load(some_values); //loads uniform vars into shader
process(vbo); //"renders" vbo using bound shader
reflectionShader.unbind(); //stops shader
refractionShader.bind();
refractionShader.load(some_other_values);
process(vbo);
refractionShader.unbind();
render(vbo); //output to screen
\$\endgroup\$
1
  • \$\begingroup\$ I don't think most systems support that as a single batch if that's your intention. Maybe if your broaden your explanation of what you hope to acheive, someone can help you find another alternative. \$\endgroup\$
    – RobStone
    Aug 7, 2015 at 12:58

1 Answer 1

1
\$\begingroup\$

The way to do this is with a FBO (Frame Buffer Object).

You can render each pass to a FBO and use it as a texture input in the next stage, any kind of deferred shading and post processing is reliant upon this functionality.

https://www.opengl.org/wiki/Framebuffer_Object

\$\endgroup\$
2
  • \$\begingroup\$ So by that you mean rendering it x times and putting the results on top of each other? That should work. I wont mark your answer as correct yet, because mb theres a better solution to this than using fbos :-) \$\endgroup\$
    – l'arbre
    Aug 7, 2015 at 13:46
  • \$\begingroup\$ Unfortunately your only options in OpenGL are either to use a texture, a uniform or shader storage buffer (which may be a texture in the implementation anyway). For your case, where you need to draw the entire screen using a technique and feed it as the input into the next technique, I don't think there's much you can do other than use an FBO. \$\endgroup\$
    – cfehunter
    Aug 7, 2015 at 14:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .