#Custom texture regions / Source Rectangle rendering

3 messages · Page 1 of 1 (latest)

sullen plume
#

Hi, I've been touching bevy and clicking my brain around the ECS system, but there is something about the design philosophy of ECS system I cannot easily assimilate with - drawing through meshes. To clarify, I come from XNA/Monogame where rendering is directly managed by the user every frame.
This approach provided more flexibility to change what's rendered on screen without creating or destroying mesh entities, and more importantly, allowed to draw specific and arbitrary parts of textures in a simple manner.

It currently seems like in Bevy I need to create and destroy mesh entities every time I want to change the source rectangle rendered - creating subtextures of the spritesheet - which beats the purpose of having a spritesheet to prevent frequent rendertarget changes completely. Bevy's TextureAtlas implementation doesn't help either, as it only can handle frames of fixed size.

So the question is: Is there an idiomatic way in Bevy to do something like immediate-mode 2D rendering — similar to SpriteBatch in Monogame or manually submitting draw calls each frame — especially for rendering specific source rectangles from a texture without needing to spawn/despawn ECS entities every time?

hushed cosmos
#

Bevy's rendering stuff is pretty much optional - if you want you can always fall back to using wgpu directly which is basically the draw call stuff you're asking for. I believe you still may need to talk between the render world and the main world, but otherwise it's up to you how that's all set up

sullen plume
#

Great suggestion! Considered using wgpu directly too, but as it would be too much of a pain for my ass that cannot render a triangle directly in graphic libraries without internet references, I decided to dig about RenderStage::Queue instead:
https://github.com/bevyengine/bevy/discussions/5162

GitHub

Is there a way to render/draw a mesh for a single frame without need to spawn an entity? The use case for for a visual gizmo system. I've attempted trying to use wgpu and winit directly but was...