Export Geometry from shader

Does anyone has any idea on how to export geometry from shaders?

if you are using OF from master or the nightly builds you can use transform feedback to export the output of a vertex or geometry shader into an ofBufferObject that can then be drawn binding it to an ofVbo. there’s an example here:

be aware that the nightly builds right now don’t have external dependencies as we are in the process of removing them from the main repository but you can easily download them using the script in scripts/your_platform/download_libs.sh or simply download them from http://ci.openframeworks.cc/libs and uncompress them in the libs folder

1 Like

This example is super useful! However I got blocked with something else; how is it possible to copy the ofVbo into a mesh in order to save as a 3d file?

you can access the buffer from the vbo with getVertexBuffer(), once you have the buffer you can map it and access it’s memory to for example copy it to an ofMesh like:

auto & buffer = vbo.getVertexBuffer();
auto * memory = buffer.map<glm::vec3>(GL_READ_ONLY);
mesh.addVertices(memory, buffer.size() / sizeof(glm::vec3));
buffer.unmap();
1 Like