-
Hi guys! I recently work on implementing a DVR renderer, and for that, I need to load volumes, which are 3D textures with single channel in my case. I've been learning along with learn-wgpu but in this tutorial, it does not mention how to load 3D textures. I had several trials myself and searched for a while, but I still cannot resolve this problem. It seems now only textures of glTexImage3D(GL_TEXTURE_3D, 0, GL_R32F, volume_dim.x, volume_dim.y, volume_dim.z, 0, GL_RED, GL_UNSIGNED_SHORT,
data_array); So, Now, I don't know how to do the similar thing with WebGPU. I could use But, are there any workarounds that are easier/faster/lossless and enable filtering? Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
If you are targeting WebGPU proper (i.e. the Web and most portable native configuration), then indeed R32F is not filterable. I don't think it's guaranteed to be filterable in OpenGL either, but this native API has higher tolerance for undefined behavior than we do. At the same time, we don't have R16Unorm, which would seem appropriate here. Again, the reason here is that it's not portable. The OpenGL uploading code you posted is guaranteed to be slow: it's not a data copy, it's an actual conversion of each texel to a new format (going from U16 to R32F). My recommendation is to use Note that you'd have to convert the data to R16F yourself - there is nothing built into WebGPU that does this. |
Beta Was this translation helpful? Give feedback.
If you are targeting WebGPU proper (i.e. the Web and most portable native configuration), then indeed R32F is not filterable. I don't think it's guaranteed to be filterable in OpenGL either, but this native API has higher tolerance for undefined behavior than we do.
At the same time, we don't have R16Unorm, which would seem appropriate here. Again, the reason here is that it's not portable.
The OpenGL uploading code you posted is guaranteed to be slow: it's not a data copy, it's an actual conversion of each texel to a new format (going from U16 to R32F).
My recommendation is to use
R16Float
here. It has effective 11 bits of precision, which is one bit short from what you need. If your dat…