-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow particles to be arbitrary meshes. (#377)
Currently, Hanabi requires that particles be 2D quads. This is sufficient for a good deal of VFX, but in many cases 3D objects are required: smoke puffs, bullet casings, etc. This commit fixes this deficiency by allowing particles to take on arbitrary meshes. To set the mesh of a particle, use the new `EffectAsset::mesh` builder method. By default, the mesh is a 2D quad. The implementation is straightforward. The previously-hard-wired quad vertices have been replaced with a `Handle<Mesh>`. The patch uses the existing `bevy_render` infrastructure to upload the mesh to the GPU and retrieve the vertices. Perhaps the most significant change is the generalization of rendering to allow for indexed drawing in addition to non-indexed. Because indexed drawing has a different on-GPU format for indirect draw commands from that of non-indirect draw commands, some additional bookkeeping is required. This patch also adds support for a few features useful for 3D rendering: * A `size3` attribute has been added, to allow the size to be controlled in 3D. * The `SetSizeModifier` now takes a 3D size gradient instead of a 2D one. * Vertex normals are available to modifiers via the `normal` shader variable, as long as they call the new `RenderContext::set_needs_normal` method. A new example, `puffs`, has been added to demonstrate the use of 3D meshes. It depicts the Bevy test fox running with cartoony smoke puffs emitted at a constant rate behind it. Each puff consists of multiple spherical mesh particles offset with some random jitter. A custom Lambertian lighting modifier is supplied with the example, in order to make the smoke puffs not appear solid white. (This modifier dramatically improves the look of this example, but it's very limited, so I didn't upstream it to Hanabi proper. A proper PBR lighting modifier would be useful, but would be a significant amount of work, so I chose to defer that to a follow-up.)
- Loading branch information
Showing
33 changed files
with
823 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.