In my shaders I want to store extra information in a texture that will be retrieved later by the CPU, to do so I’m using imageStore() to write the information in a bound texture :
self.data_texture = Texture()
self.data_texture.setup_2d_texture(255,255,Texture.T_unsigned_byte, Texture.F_rgba8)
self.data_texture.set_clear_color(LColor(0, 0, 0, 0))
self.render.set_shader_input("data_store", self.data_texture)
Once the frame has been rendered, I retrieve the texture data on the CPU :
self.base.graphicsEngine.extract_texture_data(self.data_texture, self.base.win.gsg)
So far so good, however not all pixel of the data texture are written (most of the time because there are no object on that part of the screen/texture), so I need to clear the texture before each frames, but simply calling data_texture.clear_image()
does not seem to work, parts of the texture that should be cleared still contains data from previous frames.
So, is there a way to clear the texture on the GPU or should I replace the texture each frame ?