Cannot specify correct main-world entity ID for two render-world entities extracted from the same main-world entity.
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
## Bevy version
Release 0.16
## \[Optional\] Relevant system information
```ignore
2025-05-19T15:29:36.012887Z INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "macOS 15.5 Sequoia", kernel: "24.5.0", cpu: "Apple M3", core_count: "8", memory: "24.0 GiB" }
2025-05-19T15:29:36.063713Z INFO bevy_render::renderer: AdapterInfo { name: "Apple M3", vendor: 0, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Metal }
```
## What you did
I have a custom rendering pipeline for using imposters/shader rasterization to efficiently render molecular models using the ball-and-stick visualization technique common in chemistry. Basically I draw a view-aligned quad for each sphere that is an atom, and another quad for each bond (cylinder connecting the atoms, technically a capsule as it is drawn with a signed distance function for the line segment connecting the atoms).
Because the shaders for drawing a sphere and a cylinder/capsule are different, these are actually two render pipelines. So a single `Molecule` entity in the main world gets extracted into TWO entities in the render world: `ExtractedAtoms` and `ExtractedBonds`. When I queue up the rendering commands for each, I am required to provide both the render-world entity IDs (the IDs of the `ExtractedAtoms` or `ExtractedBonds` entities) -and- the main-world entity ID (the `Molecule` single entity).
## What went wrong
If I provide the same `Molecule` main-world entity ID for both the atom and the bond render pipelines, NOTHING gets rendered. If I provide made-up / nonexistent main-world IDs (e.g. casting their render-world IDs to be `MainEntity` IDs) I also get a blank screen.
I have to queue draw commands with `ExtractedAtoms` using the correct main-world entity ID of the `Molecule` it came from, and `ExtractedBonds` using a made-up entity ID, or vice versa. If I do this, BOTH render correctly.
I admit I don't fully understand all the details of the bevy rendering system works, and each of the required parameters to the many APIs required to setup a custom pipeline and draw calls. However it would seem to me a bug that this unusual combination of real main-world and fake main-world entity IDs is required in order for the draw calls to be executed.
I would expect that the same `Molecule` main-world entity ID should be used for both, so that things like a render buffer for entity IDs (for picking) work correctly.
## Additional information
Relevant code is available here:
https://github.com/atomCAD/atomCAD/blob/25aafeaa614a0741a3aaa8e13ebc70923ac1d262/src/atoms.rs#L523-L534
Contributor guide
Research direction
Start with the linked code in src/atoms.rs#L523-L534 and trace how the extracted atom and bond entities are queued with their render-world and main-world entity IDs. Investigate why using the same Molecule main-world ID for both prevents rendering; done means both pipelines render while using that shared ID.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100