How can I render many instanced cubes that use an array texture? #18340
Unanswered
adamsoutar
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello!
I am experimenting with Bevy for the first time and it is for the most part everything I'm looking for. Just recently I've been tripped up by this problem and unable to find any demo (that I understand) that helps with what I'm looking for.
My game looks like this:
It's a collection of simple cubes that have one of 12 textures. In this screenshot, the user is only playing a simple board - 5 blocks wide by 5 tall by 5 deep. But these puzzle boards can get massive (80+ blocks per edge, totalling ~38,000 cubes on screen). imo. this is a perfect design to add GPU Instancing to, and what I want is to use Array Textures to get the entire board to render in one draw call even though some blocks have different textures.
So far, I've tried modifying the
array_texture
example to add a new shader uniform that controls the index used, so that each block can still use the sameMesh
andMaterial
(to get automatic instancing), but that didn't work because the index on the material was shared, giving all the blocks the same texture.custom_shader_instancing
is a little closer to what I'm looking for, but its examplewgsl
shader is missing a lot of thepbr
code from thearray_texture
one, and its Rust code is 10x+ more complicated, involving a lot of concepts I don't understand (like why are opaque cubes being drawn in a pass calledTransparent3d
?)Is there a middle ground?
I basically just want the
array_texture
example to benefit from Automatic GPU Instancing, ideally by adding a component to each entity that contains its desired texture index.Beta Was this translation helpful? Give feedback.
All reactions