I'm trying to do some bone animation. I don't want the whole skeleton to be loaded to the GLSL shader every time, even tough it's not needed, because one vertex is parented to one bone, not more. My question is simple: (How) can i return some value from the vertex shader back to my code? I'm using LWJGL/Java

  • \$\begingroup\$ Believe it or not, you actually cant. What you can do is write pixels out to a buffer, and then read the buffer later. \$\endgroup\$ – mklingen Feb 14 '15 at 15:23
  • \$\begingroup\$ There is also GL_ATOMIC_COUNTER_BUFFER atomic increments, and the transform feedback buffer in Daniel Carlsson's answer below. Watching answers carefully, this is an interesting question to me... \$\endgroup\$ – david van brink Feb 14 '15 at 19:29
  • \$\begingroup\$ Ok, then I just load the whole Skeleton into the shader, isn't a huge thing, but could impact performance :/ \$\endgroup\$ – Addi Feb 14 '15 at 19:48

You can use a Transform Feedback Buffer to output from your vertex shader, your question is not very specific though so I can't be sure if this is truly what you want to do.

  • \$\begingroup\$ Can TFB be used by the CPU to conditionalize some of the later rendering? (The OP seems to imply that this what they want; they may be not approaching their particular problem right though, not sure.) \$\endgroup\$ – david van brink Feb 14 '15 at 19:31
  • 1
    \$\begingroup\$ Yes you can, but as always when reading buffers from the CPU you have to keep in mind that the buffer might not be filled yet just because your rendering the next frame in the CPU. You need to use glFenceSync​ to make sure you have valid output in the buffer. \$\endgroup\$ – Daniel Carlsson Feb 14 '15 at 22:12

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.