mirror of
https://github.com/bevyengine/bevy
synced 2024-11-29 16:10:19 +00:00
ab16f5ed6a
> 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
1.9 KiB
1.9 KiB
Bevy Credits
Adapted Code
- hecs
- legion_transform
- wgpu-rs examples
- yaks: ArchetypeSet, borrowed some ideas from their scheduler implementation
Inspiration
- game engines: amethyst, coffee
- ecs: legion, shipyard, yaks
Assets
- Generic RPG Pack (CC0 license) by Bakudas and Gabe Fern
- Environment maps (
.hdr
files) from HDRIHaven (CC0 license) - Alien from Kenney's Space Kit (CC0 1.0 Universal)
- Cake from Kenney's Food Kit (CC0 1.0 Universal)
- Ground tile from Kenney's Tower Defense Kit (CC0 1.0 Universal)
- Game icons from Kenney's Game Icons (CC0 1.0 Universal)
- Space ships from Kenny's Simple Space Kit (CC0 1.0 Universal)
- UI borders from Kenny's Fantasy UI Borders Kit (CC0 1.0 Universal)
- glTF animated fox from glTF Sample Models
- Low poly fox by PixelMannen (CC0 1.0 Universal)
- Rigging and animation by @tomkranis on Sketchfab (CC-BY 4.0)
- FiraMono by The Mozilla Foundation and Telefonica S.A (SIL Open Font License, Version 1.1: assets/fonts/FiraMono-LICENSE)
- Barycentric from mk_bary_gltf (MIT OR Apache-2.0)
MorphStressTest.gltf
, MorphStressTest (CC-BY 4.0 by Analytical Graphics, Inc, Model and textures by Ed Mackey)