Updating Sparse Texture Data (OpenGL)

Started by
2 comments, last by Digitalfragment 12 years, 7 months ago
Greetings,

I apologize if the title is a bad description. Basically, I have a fairly large 3D texture that I'm using for a density field in a marching cubes application. Every frame, I need to update several hundred texels. However, these texels are not contiguous. So, I have the option of a) updating the whole texture (turns out to be way too slow), b) updating the contiguous "bound" of the area that is to be updated (potentially as bad as a because the updates are so sparse), or c) updating one texel at a time (slow, but surprisingly faster than a).

Is there a better way? I was thinking about maybe having a separate 1D texture that I fill with values the values to be updated (for each texel, r/g/b contains the coordinate on the 3D texture to be updated, and the alpha component contains the density value). Then, I could do a pre-pass where I render to the 3D texture using the 1D texture as the source, and voila. Only problem is, this is really hand-wavy. I don't know if a 3D texture can be a render target, and even if it could, the nature of a fragment shader seems to be that I don't decide which pixel to write to.

So, I thought I'd check in with you folks to see if anyone has faced this issue before. It'd be really nice to have some method where I can update all of the texels I want to, and no others, without using hundreds of draw calls.
Advertisement

Greetings,

I apologize if the title is a bad description. Basically, I have a fairly large 3D texture that I'm using for a density field in a marching cubes application. Every frame, I need to update several hundred texels. However, these texels are not contiguous. So, I have the option of a) updating the whole texture (turns out to be way too slow), b) updating the contiguous "bound" of the area that is to be updated (potentially as bad as a because the updates are so sparse), or c) updating one texel at a time (slow, but surprisingly faster than a).

Is there a better way? I was thinking about maybe having a separate 1D texture that I fill with values the values to be updated (for each texel, r/g/b contains the coordinate on the 3D texture to be updated, and the alpha component contains the density value). Then, I could do a pre-pass where I render to the 3D texture using the 1D texture as the source, and voila. Only problem is, this is really hand-wavy. I don't know if a 3D texture can be a render target, and even if it could, the nature of a fragment shader seems to be that I don't decide which pixel to write to.

So, I thought I'd check in with you folks to see if anyone has faced this issue before. It'd be really nice to have some method where I can update all of the texels I want to, and no others, without using hundreds of draw calls.


Not 100% on the openGL api for it, but in DX 2D slices of 3D volume can be bound as a rendertarget, and on DX11 hardware multiple slices of a 3D volume can be bound essentially as an MRT.

I've updated individual pixels of very large rendertargets with pointsprites before, which worked fairly well (that was for a particle system that kept all of its memory on the gpu)
That's pretty interesting. I will see what I can do via OpenGL along those lines. Do you think there's some sort of CUDA/OpenCL thing I can do? I don't really have any experience with GPGPU.

That's pretty interesting. I will see what I can do via OpenGL along those lines. Do you think there's some sort of CUDA/OpenCL thing I can do? I don't really have any experience with GPGPU.


The NVidia CUDA samples do have OpenGL rendering versions, so i'm guessing its not too bad to deal with:
http://developer.nvidia.com/cuda-cc-sdk-code-samples

This topic is closed to new replies.

Advertisement