bevy/assets/textures
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
..
fantasy_ui_borders UI Texture 9 slice (#11600) 2024-02-07 20:07:53 +00:00
Game Icons add an example using UI & states to create a game menu (#2960) 2022-01-14 19:09:42 +00:00
parallax_example Add parallax mapping to bevy PBR (#5928) 2023-04-15 10:25:14 +00:00
rpg example: add rpg assets for use in examples (maybe pair this down in the future) 2020-06-05 17:26:41 -07:00
simplespace Simple 2d rotation example (#3065) 2022-01-25 22:10:11 +00:00
array_texture.png Extend the Texture asset type to support 3D data (#903) 2020-11-22 12:04:47 -08:00
Ryfjallet_cubemap.png Support array / cubemap / cubemap array textures in KTX2 (#5325) 2022-07-30 07:02:58 +00:00
Ryfjallet_cubemap_astc4x4.ktx2 Support array / cubemap / cubemap array textures in KTX2 (#5325) 2022-07-30 07:02:58 +00:00
Ryfjallet_cubemap_bc7.ktx2 Support array / cubemap / cubemap array textures in KTX2 (#5325) 2022-07-30 07:02:58 +00:00
Ryfjallet_cubemap_etc2.ktx2 Support array / cubemap / cubemap array textures in KTX2 (#5325) 2022-07-30 07:02:58 +00:00
Ryfjallet_cubemap_readme.txt Support array / cubemap / cubemap array textures in KTX2 (#5325) 2022-07-30 07:02:58 +00:00
slice_square.png Sprite slicing and tiling (#10588) 2024-01-15 15:40:06 +00:00
slice_square_2.png Sprite slicing and tiling (#10588) 2024-01-15 15:40:06 +00:00
spiaggia_di_mondello_1k.hdr add HDR image loader 2020-07-27 11:37:45 +02:00