Skip to content

polish compute_mesh example - #25784

Draft
JasmineLowen wants to merge 1 commit into
bevyengine:mainfrom
JasmineLowen:polish-compute-mesh-example
Draft

JasmineLowen wants to merge 1 commit into
bevyengine:mainfrom
JasmineLowen:polish-compute-mesh-example

Conversation

@JasmineLowen

Copy link
Copy Markdown
Contributor
  • remove "chunk" wording that is irrelevant at this point
  • improve DataRanges Uniform
  • add Globals uniform and recompute mesh each frame

animated

- remove "chunk" wording that is irrelevant at this point
- improve `DataRanges` Uniform
- add `Globals` uniform and recompute mesh each frame
@JasmineLowen
JasmineLowen force-pushed the polish-compute-mesh-example branch from a85f803 to 4acb5ce Compare September 14, 2026 16:40

@ChristopherBiscardi ChristopherBiscardi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not convinced by the motivation here (well there isn't any motivation listed in the PR description actually, as of this comment). Regenerating the mesh every frame is not the purpose of this example and is the default behavior if you run a compute shader so doesn't really need to be exemplified. The implication in the example is that the compute is somewhat heavy and should be done once. For example: generating terrain chunks around a player.

I'm also not convinced by the custom abstractions for set_vec3/get_vec3. These seem to add more indirection that I'm not sure is actually helpful.

So these are changes, but not for any stated purpose afaict. It's just a different example now which in isolation is fine. I guess we could have a simple "generate mesh every frame" example and a separate terrain chunk example.

@alice-i-cecile alice-i-cecile added A-Rendering Drawing game state to the screen C-Examples An addition or correction to our examples X-Contentious There are nontrivial implications that should be thought through S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels Sep 14, 2026
@github-project-automation github-project-automation Bot moved this to Needs SME Triage in Rendering Sep 14, 2026
@alice-i-cecile

Copy link
Copy Markdown
Member

could have a simple "generate mesh every frame" example and a separate terrain chunk example

Mhmm, grounding this stuff in real world patterns that people might actually want and putting them in the usage examples seems like a better path forward to me. It makes these sorts of questions about "what should we teach and why" a lot clearer.

@alice-i-cecile alice-i-cecile added D-Straightforward Simple bug fixes and API improvements, docs, test and examples D-Shaders This code uses GPU shader languages labels Sep 14, 2026
@JasmineLowen

Copy link
Copy Markdown
Contributor Author

Hmm good points. I'll update the description a bit more tomorrow.

I personally read the example as a very basic intro into creating a mesh with a compute shader and rendering it with the bevy mesh pipeline.

I totally see the use case for chunks and huge meshes in general that you are describing (I actually also do that in a personal project!). But I guess then we (or I) should split this into a separate example that is a bit more refined around that topic.

Currently it was kinda confusing to read about chunks while rendering two cubes. I also think that an example with some truely huge mesh would reveal some other pain points. For example the allocation of an empty mesh as it's currently done in the existing example takes some time and leads to stutter if its big enough.

The idea about the regeneration each frame came from my personal journey lately. The last thing I did was render compute generated geometry with a custom pipeline on every frame. But that meant losing the good parts of bevys mesh pipeline like the pbr lighting. In contrast to that, you could use the compute mesh example approach to get all the nice parts of bevys mesh pipeline IF your mesh is small and cheap enough to be regenerated each frame. Here, a better allocation strategy would probably also improve the example.

@beicause

Copy link
Copy Markdown
Member

Regenerating the mesh every frame is not the purpose of this example and is the default behavior if you run a compute shader so doesn't really need to be exemplified. The implication in the example is that the compute is somewhat heavy and should be done once. For example: generating terrain chunks around a player.

In my opinion, computing the mesh every frame is exactly the biggest advantage of compute shaders and a more common use case, because it avoids uploading data from CPU, while the advantage of computing it only once is often less significant.

@JasmineLowen

Copy link
Copy Markdown
Contributor Author

In my opinion, computing the mesh every frame is exactly the biggest advantage of compute shaders and a more common use case, because it avoids uploading data from CPU, while the advantage of computing it only once is often less significant.

Well to some degree Chris is right. I didn't notice he recently landed a new example for mesh rendering via a compute shaders. I think this is a better way to render with compute than my changes here with the small animation.

Nevertheless, I guess splitting the example in a very basic one and an intermediate one would be a good idea.

@JasmineLowen
JasmineLowen marked this pull request as draft September 15, 2026 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Rendering Drawing game state to the screen C-Examples An addition or correction to our examples D-Shaders This code uses GPU shader languages D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged X-Contentious There are nontrivial implications that should be thought through

Projects

Status: Needs SME Triage

Development

Successfully merging this pull request may close these issues.

4 participants