Hi! After many years I’m back to use OF and I’m very happy.
I’m trying compute shader to move some particles.
Is it possibile to use texture data (from an fbo) inside a compute shader?
I’m not sure if I have to use the “setUniformTexture” like this:
(but don’t know how to get the data inside the compute shader)
or if I need to create an ofBufferObject where I store my data.
The point is that I need to update the data of the texture inside my OF update function.
Any suggestions?
Hey @Mauro glad you’re back working with OF again! Have you looked at the textureBufferInstancedExample? While it doesn’t have a compute shader, I’m thinking a similar approach would work. Its uses an ofBufferObject and an ofTexture that has been allocated with .allocateAsBufferTexture().
Also one more quick thought. An ofBufferObject and associated ofTexture will allow data to be computed (updated) by the cpu before it’s sent to the gpu, like in the example.
Multiple passes of shaders can also update data on the gpu. The gpuParticleSystemExample uses ofFbos for position and velocity data, and shaders calculate new values for those textures every frame. The GL_RGBA32F format for textures can be helpful when doing calculations with shaders.