Open Cazadorro opened 2 months ago
Thanks for the excellent report! Are you able to reproduce this on the latest commit?
Thanks for the excellent report! Are you able to reproduce this on the latest commit?
Yes, it still happens exactly the same way.
Just to verify, this is how I reproduced on the newest commit
{git = https://github.com/bevyengine/bevy.git, rev="8bfe635"}
in my cargo.tomlAwesome thank you!
The comment above the line get_world_from_local(0u)
explained the reason: 0u
might not be the correct index of the instancing mesh when there are other meshes.
Passing in the correct index via another uniform will fix it.
Here's a good example: https://github.com/EmiOnGit/warbler_grass
(replace phases: Query<&RenderPhase<...>>
with phases: Res<ViewSortedRenderPhases<Transparent3d>>
for bevy 0.14)
From what I can tell because of the RenderPhase changes some of the fields are crate private so you aren't able to use the solution @yyrust suggested.
From what I can tell because of the RenderPhase changes some of the fields are crate private so you aren't able to use the solution @yyrust suggested.
Is this possible in the latest or 14.x?
It is possible with sorted render phases, so the method above would work. I'm still trying to find a way with binned render phases.
Bevy version
0.14.2
[Optional] Relevant system information
Windows 11
[Nvidia RTX A2000 8gb laptop GPU, vendor: 4318, device: 9658, device_type: DiscreteGpu, driver: "Nvidia", driver_info: "536.67", backend: Vulkan]
What you did
I ran the rendering example https://bevyengine.org/examples-webgpu/shaders/shader-instancing/ and added a new spherical pbr bundle (full code listing later)
What went wrong
What I expected: the default centered instanced example to display, with out moving. What actually happened: The instancing example somehow inherited the transform information of that new bundle, and adding it before or after the instanced example bundle doesn't change the result.
Additional information
Where I expected the instance example to render:
Where it ended up rendering (centered on sphere):
Source code:
src/main.rs:
assets/shaders/instancing.wgsl:
Cargo.toml:
I've tested this with manually setting transforms in the spatial bundle for the example, and it still doesn't work properly. The only thing I can think of is maybe the spatial bundle transform doesn't get sent to the Render phase, but the PBR bundle transform does, so maybe the default information just appears like it works when nothing is added, but when a PBR bundle is added, the transform uniform is overwritten for the spatial bundle instance as well when rendering. Waaaay too complicated for me to figure out though.