Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for 3D textures #8

Open
clindsey opened this issue Feb 1, 2023 · 3 comments
Open

support for 3D textures #8

clindsey opened this issue Feb 1, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@clindsey
Copy link

clindsey commented Feb 1, 2023

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
clindsey added a commit to clindsey/gpu-io that referenced this issue Feb 1, 2023
clindsey added a commit to clindsey/gpu-io that referenced this issue Feb 1, 2023
clindsey added a commit to clindsey/gpu-io that referenced this issue Feb 1, 2023
clindsey added a commit to clindsey/gpu-io that referenced this issue Feb 1, 2023
@amandaghassaei
Copy link
Owner

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.

@amandaghassaei amandaghassaei changed the title missing 3D texture example in readme support for 3D textures Feb 1, 2023
@amandaghassaei amandaghassaei added the enhancement New feature or request label Feb 2, 2023
@clindsey
Copy link
Author

clindsey commented Feb 6, 2023

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

@amandaghassaei
Copy link
Owner

cool demo - that makes sense. I'll keep you posted if I make progress on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants