gpu-io
gpu-io copied to clipboard
support for 3D textures
README.md file has a TODO
note to add an example of working with 3D textures, it would be nice to have.
- Show how to store 3D data in a 1D array.
- Show how to work with the 3D texture in the shader, including how to access the texture data using 3D coordinates
Thanks for bringing this up! To be honest this probably requires a bigger change on my end. I actually think it would make sense to officially support dense 3D textures within GPULayer (for webgl2/webgpu, and then maybe implement a fallback for webgl1). I would just need to add that functionality to GPULayer and then make another test page to make sure that the filtering is working across browsers (I bet hardware linear filtering is not supported on mobile safari, will need to be polyfilled with a trilinear interpolation function).
I probably didn't word it well, but in the readme the TODO was referring to using the 1D GPULayer hack to store vertex information for 3D meshes to do simulations on those (e.g. https://apps.amandaghassaei.com/msh-parser/demo/). I'm planning to add a soft-body simulation at some point, but haven't found the time yet.
Let me dig into this and see what is required, might actually be an easy fix.
I'm curious what types of things you might want to do with 3D textures? I've been sticking to 2D just bc it's hard to compute large 3D textures in real-time.
Ah, that makes sense.
I'm using 3D textures for maintaining and sorting positions and velocities of boids. Normally boids need to know about every other boid, but with a 3D texture that stores positions in an organized way, I can find the neighbors of a boid more efficiently. I learned about the technique from this article.
Here's something quick I made, with over 32,000 boids; tested in Mac Chrome and Safari - https://clindsey.github.io/mosquito-swarm/ https://github.com/clindsey/mosquito-swarm
cool demo - that makes sense. I'll keep you posted if I make progress on this!