mcpar-land / bevy_ascii

Library for making terminal interface games with Bevy
4 stars 0 forks source link

Performance - Use Compute Shader for Z buffers #1

Open mcpar-land opened 4 years ago

mcpar-land commented 4 years ago

Right now, performance is really awful. There's an open PR for Bevy handling compute shaders that would be perfect here. https://github.com/bevyengine/bevy/pull/139

bzm3r commented 4 years ago

is https://github.com/bevyengine/bevy/pull/139 basically ready for flight? also, how do you imagine using compute shaders to help; more precisely why would z-buffers help for a 2D rendering problem of this sort?

also, might any of the ideas from raph levien's work be interesting? https://raphlinus.github.io/rust/graphics/gpu/2020/06/13/fast-2d-rendering.html?

mcpar-land commented 3 years ago

A z buffer seems like the best option to me because there's a lot of computations that need to be solved that involve 'layering' of different strings on top of each other (and in the future, not just the characters of the text itself, but also inheriting background colors of lower characters). A compute shader acting as a sort of fragment shader on each square of the terminal's grid, calculating which character/background color is on top, seems like the speediest option to me.

I will admit that I'm a novice at shaders and graphics programming. If there's a CPU-based way to do Z-buffering, or some other computation that solves the problem better, I'm all ears.