bevy/assets
Félix Lescaudey de Maneville ab16f5ed6a
UI Texture 9 slice (#11600)
> Follow up to #10588 
> Closes #11749 (Supersedes #11756)

Enable Texture slicing for the following UI nodes:
- `ImageBundle`
- `ButtonBundle`

<img width="739" alt="Screenshot 2024-01-29 at 13 57 43"
src="https://github.com/bevyengine/bevy/assets/26703856/37675681-74eb-4689-ab42-024310cf3134">

I also added a collection of `fantazy-ui-borders` from
[Kenney's](www.kenney.nl) assets, with the appropriate license (CC).
If it's a problem I can use the same textures as the `sprite_slice`
example

# Work done

Added the `ImageScaleMode` component to the targetted bundles, most of
the logic is directly reused from `bevy_sprite`.
The only additional internal component is the UI specific
`ComputedSlices`, which does the same thing as its spritee equivalent
but adapted to UI code.

Again the slicing is not compatible with `TextureAtlas`, it's something
I need to tackle more deeply in the future

# Fixes

* [x] I noticed that `TextureSlicer::compute_slices` could infinitely
loop if the border was larger that the image half extents, now an error
is triggered and the texture will fallback to being stretched
* [x] I noticed that when using small textures with very small *tiling*
options we could generate hundred of thousands of slices. Now I set a
minimum size of 1 pixel per slice, which is already ridiculously small,
and a warning will be sent at runtime when slice count goes above 1000
* [x] Sprite slicing with `flip_x` or `flip_y` would give incorrect
results, correct flipping is now supported to both sprites and ui image
nodes thanks to @odecay observation

# GPU Alternative

I create a separate branch attempting to implementing 9 slicing and
tiling directly through the `ui.wgsl` fragment shader. It works but
requires sending more data to the GPU:
- slice border
- tiling factors

And more importantly, the actual quad *scale* which is hard to put in
the shader with the current code, so that would be for a later iteration
2024-02-07 20:07:53 +00:00
..
android-res/mipmap-mdpi android example polish (#845) 2020-11-11 16:31:16 -08:00
branding Remove unused namespace declarations (#10965) 2023-12-13 22:29:16 +00:00
data Added Support for Extension-less Assets (#10153) 2024-01-31 14:58:08 +00:00
docs Improve Mesh documentation (#9061) 2023-07-31 18:55:42 +00:00
environment_maps Implement minimal reflection probes (fixed macOS, iOS, and Android). (#11366) 2024-01-19 07:33:52 +00:00
fonts Add the license for the FiraMono font (#3589) 2022-05-06 19:29:43 +00:00
irradiance_volumes Implement irradiance volumes. (#10268) 2024-02-06 23:23:20 +00:00
lightmaps Implement lightmaps. (#10231) 2024-01-02 20:38:47 +00:00
models Implement irradiance volumes. (#10268) 2024-02-06 23:23:20 +00:00
pixel Add example for pixel-perfect grid snapping in 2D (#8112) 2023-12-26 17:15:50 +00:00
scenes Fix scene example (#11289) 2024-01-22 15:14:41 +00:00
shaders Implement irradiance volumes. (#10268) 2024-02-06 23:23:20 +00:00
sounds Add simple collision sound to breakout (#4331) 2022-04-14 20:20:38 +00:00
textures UI Texture 9 slice (#11600) 2024-02-07 20:07:53 +00:00