Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.12: Image Settings and Bind Group Ergonomics #791

Merged
merged 5 commits into from
Nov 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions content/news/2023-10-21-bevy-0.12/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,98 @@ Since our last release a few months ago we've added a _ton_ of new features, bug

<!-- more -->

## ImageLoader Settings

<div class="release-feature-authors">authors: @cart, @Kanabenki</div>

To take advantage of the new [`AssetLoader`] settings in **Bevy Asset V2**, we've added [`ImageLoaderSettings`] to [`ImageLoader`].

This means that you can now configure the sampler, SRGB-ness, and the format, on a per-image basis. These are the defaults, as they appear in **Bevy Asset V2** meta files:

```rust
(
format: FromExtension,
is_srgb: true,
sampler: Default,
)
```

When set to `Default`, the image will use whatever is configured in [`ImagePlugin::default_sampler`].

However, you can set these values to whatever you want!

```rust
(
format: Format(Basis),
is_srgb: true,
sampler: Descriptor((
label: None,
address_mode_u: ClampToEdge,
address_mode_v: ClampToEdge,
address_mode_w: ClampToEdge,
mag_filter: Nearest,
min_filter: Nearest,
mipmap_filter: Nearest,
lod_min_clamp: 0.0,
lod_max_clamp: 32.0,
compare: None,
anisotropy_clamp: 1,
border_color: None,
)),
)
```

[`ImagePlugin::default_sampler`]: https://dev-docs.bevyengine.org/bevy/render/prelude/struct.ImagePlugin.html#structfield.default_sampler
[`ImageLoaderSettings`]: https://dev-docs.bevyengine.org/bevy/render/texture/struct.ImageLoaderSettings.html

## Bind Group Ergonomics

<div class="release-feature-authors">authors: @robtfm, @JMS55</div>

When defining "bind groups" for low-level renderer features, we use the following API api:

```rust
render_device.create_bind_group(
"my_bind_group",
&my_layout,
&[
BindGroupEntry {
binding: 0,
resource: BindingResource::Sampler(&my_sampler),
},
BindGroupEntry {
binding: 1,
resource: my_uniform,
},
],
);
```

This works reasonably well, but for large numbers of bind groups, the `BindGroupEntry` boilerplate makes it harder than necessary to read and write everything (and keep the indices up to date).

**Bevy 0.12** adds additional options:

```rust
// Sets the indices automatically using the index of the tuple item
render_device.create_bind_group(
"my_bind_group",
&my_layout,
&BindGroupEntries::sequential((&my_sampler, my_uniform)),
);
```

```rust
// Manually sets the indices, but without the BindGroupEntry boilerplate!
render_device.create_bind_group(
"my_bind_group",
&my_layout,
&BindGroupEntries::with_indexes((
(2, &my_sampler),
(3, my_uniform),
)),
);
```

## UI Node Outlines

<div class="release-feature-authors">authors: @ickshonpe</div>
Expand Down Expand Up @@ -398,6 +490,7 @@ A meta file for an unprocessed image looks like this:
settings: (
format: FromExtension,
is_srgb: true,
sampler: Default,
),
),
)
Expand All @@ -414,6 +507,7 @@ A meta file for an image configured to be processed looks like this:
loader_settings: (
format: FromExtension,
is_srgb: true,
sampler: Default,
),
saver_settings: (),
),
Expand All @@ -438,6 +532,7 @@ The final "output" metadata for the processed image looks like this:
settings: (
format: Format(Basis),
is_srgb: true,
sampler: Default,
),
),
)
Expand Down
Loading