From e80177774cdf7af0e04f5bc15a881802d94b09d2 Mon Sep 17 00:00:00 2001 From: "Spencer C. Imbleau" Date: Sun, 4 Aug 2024 15:13:36 -0400 Subject: [PATCH] refactor: core pipeline changes (#73) Addresses some friction where the `VelloRenderer` was not a resource and required Locals temporarily. This was mainly observed in the `cube3d` example. Likewise, the rendering params such as `use_cpu` and `antialiasing` were not configurable and the use of `RenderLayers` were cleaned up after @ChristopherBiscardi brought up some comments after #71. @ChristopherBiscardi Please let me know if you still have concerns with RenderLayers. --- CHANGELOG.md | 8 +- examples/cube3d/src/main.rs | 15 ++-- examples/render_layers/src/main.rs | 48 +++-------- src/lib.rs | 18 +--- src/plugin.rs | 51 ++++++++--- src/render/mod.rs | 81 ++++++++++++++--- src/render/plugin.rs | 78 +++++++++-------- src/render/systems.rs | 40 ++++----- src/text/{ => FiraMono}/FiraMono-subset.ttf | Bin src/text/FiraMono/LICENSE | 91 ++++++++++++++++++++ 10 files changed, 294 insertions(+), 136 deletions(-) rename src/text/{ => FiraMono}/FiraMono-subset.ttf (100%) create mode 100644 src/text/FiraMono/LICENSE diff --git a/CHANGELOG.md b/CHANGELOG.md index 48b02c8..e811896 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,10 +15,14 @@ Subheadings to categorize changes are `added, changed, deprecated, removed, fixe - There is now a `default_font` feature that uses the same `FiraMono-subset.ttf` font used in the bevy/default_font feature. - There is now a `render_layers` example. - There is now a `cube_3d` example. +- You may now choose the render layers for the Vello canvas. This can be configured through the `VelloPlugin`. +- You may now choose to use CPU rendering with Vello and configure anti-aliasing. This can be configured through the `VelloPlugin`. ### Changed - `VelloPlugin` now has configuration. To retain previous behavior, use `VelloPlugin::default()`. +- `VelloRenderer` is now a resource. +- The `VelloRenderer` will attempt CPU fallback if it cannot obtain a GPU. - The font API has changed significantly. Please visit `examples/text` for further usage. This is to prepare for additional text features such as linebreak behavior, bounded text, and text justification. - `VelloText` has been renamed to `VelloTextSection`. - `VelloText.content` has been renamed to `VelloText.value`. @@ -27,11 +31,13 @@ Subheadings to categorize changes are `added, changed, deprecated, removed, fixe - The field `VelloAssetBundle.vector` was renamed to `VelloAssetBundle.asset`. - Renamed `VelloAssetAlignment` to `VelloAssetAnchor`. Fields were renamed `alignment` were renamed to `asset_anchor`. - Renamed `VelloTextAlignment` to `VelloTextAnchor`. Fields were renamed `alignment` were renamed to `text_anchor`. -- The `SSRenderTarget` (fullscreen quad that renders your frame) no longer renders at a zepth of `-0.001`. This was a legacy hack used to ensure Gizmos rendered on-top. +- The `SSRenderTarget` (fullscreen quad that renders your frame) no longer renders at a zepth of `-0.001`. This was a legacy hack used to ensure Gizmos rendered on-top. `RenderLayers` should be used now (there's an example). ### Removed - Removed `ZFunction`s from the render pipeline. Now ordering is based solely on the `Transform`'s z component. If you dependeded on this behavior, you'll need to adjust the transform Z in a system prior to render. +- `VelloRenderPlugin` is now private, as it is not helpful for downstream developers to add manually. +- Removed `VelloCanvasMaterial` from prelude, as it is not typical to use. ### Fixed diff --git a/examples/cube3d/src/main.rs b/examples/cube3d/src/main.rs index 11cf294..60ad858 100644 --- a/examples/cube3d/src/main.rs +++ b/examples/cube3d/src/main.rs @@ -33,7 +33,11 @@ fn main() { let mut app = App::new(); app.add_plugins(DefaultPlugins) - .add_plugins(VelloPlugin::default()) + .add_plugins(VelloPlugin { + use_cpu: false, + antialiasing: vello::AaConfig::Msaa8, + ..default() + }) .add_systems(Startup, setup) .add_systems(Update, cube_rotator_system) .add_plugins(ExtractComponentPlugin::::default()); @@ -115,15 +119,14 @@ fn setup( } fn render_texture( - mut vello_renderer: Local>, + renderer: Res, + render_settings: Res, target: Query<&VelloTarget>, device: Res, gpu_images: Res>, queue: Res, time: Res