Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modern 2d rendering for games #3

Open
nical opened this issue Oct 15, 2018 · 6 comments
Open

Modern 2d rendering for games #3

nical opened this issue Oct 15, 2018 · 6 comments

Comments

@nical
Copy link

nical commented Oct 15, 2018

Let's talk about the technical aspects of rendering complex vector graphics in interactive applications like games.
To me this topic is very different from making UIs. I'll elaborate on that when I have a bit of time before me.

@derekdreery
Copy link
Member

derekdreery commented Oct 16, 2018

It sounds like for games, the difficulty is getting the balance between full GPU control, and some scene graph retained state. We want to

  1. abstract away the parts of GPU programming that aren't interesting to 2D games developers (if there are any),
  2. provide utility/helper functionality for common 2D tasks, like tessellating paths, standard effects (blur et. al.),
  3. either allow or force the library consumer to decide some of the implementation details for their program, for example when to transfer memory between CPU/GPU, batching strategies, memory locality on the GPU etc.
  4. Probably more

I suspect it may be worth having 2 crates, a gfx-2d or equivalent, that provides full control over the GPU for 2d applications, but is as simple as possible, and then a drawing library that abstracts a bit and provides the utility functionality. Should there be some sort of scene graph? Or should that be the consumer/higher level library's responsibility.

I think it's important to have a stack, so consumers can choose the level of abstraction that is easiest to use while still giving the access to performance they need.

@derekdreery
Copy link
Member

It might be worth reaching out to the Chucklefish developers, since they are doing commercial work, and at least Starbound was 2D (not sure about their future work). A games library should be low-level enough for professional game development, even if it stays as an experiment.

@derekdreery
Copy link
Member

Can I ask what operations are important for 2D gaming? Is the following list accurate:

  1. Blitting images (or sprites, I'm not sure I understand the distinction) onto a framebuffer
  2. Lighting/shadows/blur/other blend effects

In particular none of the layout stuff from UI where you calculate position and size. Also no shape primitives - everything is a rectange of pixels.

Are there other possibilities? Would people use vector graphics to describe their assets, and want them to scale? What other ways to use 2D graphics are there? Also, would you want all the UI stuff anyway since you usually have a UI in-game?

@derekdreery
Copy link
Member

Possibly interesting article: https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch25.html

@nical
Copy link
Author

nical commented Oct 29, 2018

I wrote some stuff here: https://nical.github.io/posts/rust-2d-graphics-02.html about memory management and modern graphics APIs.

@nical
Copy link
Author

nical commented Oct 29, 2018

Sorry I thought I had answered that a while back:

Can I ask what operations are important for 2D gaming? Is the following list accurate:

1. Blitting images (or sprites, I'm not sure I understand the distinction) onto a framebuffer

2. Lighting/shadows/blur/other blend effects

If all you need is blitting sprites, ggez already provides the functionality along with a lot of useful stuff. Effects are certainly nice. What I'm personally interested in is general purpose vector graphics (as in, arbitrary paths) because it's a hard problem (and an interesting one), and it doesn't have a lot of known libraries that are adapted to complex interactive scenes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants