Jump to content
  • Advertisement
Sign in to follow this  
CDProp

OpenGL Updating Sparse Texture Data (OpenGL)

This topic is 2637 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!