Skip to content

Whats the proper way to update a uniform for each mesh? #3244

Answered by kpreid
cdecompilador asked this question in Q&A
Discussion options

You must be logged in to vote

You can create two or more uniform buffers — one for each set of uniform values you want to use during that frame. You will also need a bind group for each buffer.

There are other options too, like storing arrays of values in a single buffer, which can then be indexed using attributes in the mesh data, or the instance number. Which one is best depends on exactly what you're drawing.

The way to think about the problem in general is: there should be places somewhere in your buffers (and textures) for all the data you need for one frame, all at the same time, so that the order of operations can be thought of as “write, write, draw, draw” rather than “write, draw, write, draw”. There are vari…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by cdecompilador
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants