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\$
  • \$\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 '15 at 12:58
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\$
  • \$\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\$ – Addi Aug 7 '15 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 '15 at 14:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.