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

Standardise texture atlases #10

Closed
peppy opened this issue Aug 31, 2016 · 3 comments
Closed

Standardise texture atlases #10

peppy opened this issue Aug 31, 2016 · 3 comments
Labels

Comments

@peppy
Copy link
Sponsor Member

peppy commented Aug 31, 2016

Right now, we are generating texture atlases on-the-fly. While this works great in some cases (unicode fonts, for example, where we don't want to instantly load 2048x2048x18 pixels into video memory), we will likely want pre-processed atlases in the near future.

We are already using the BMFont format for fonts, but will likely want a slight variant of this format for arbitrary texture resources. These would likely be referred to by a string identifier rather than integer id.

Things to be done:

  • GlyphStore should be subclassed so we can support loading non-font atlases.
  • TextureAtlas needs more functionality so we can pre-populate it with data rather than adding textures one-by-one. May require moving current implementation to a subclass.
  • A new store (providing Textures) should be made which handles the loading of the full sprite-sheet texture(s) into GL memory and keeps one or more TextureAtlas local to itself.

So for fonts, we will (or rather, already) have:

TextureStore store = new TextureStore(new GlyphStore(Game.Resources, Font));

Texture = store.Get(@"F");
//TextureStore will request the texture from GlyphStore as it hasn't already been cached to the TextureStore atlas.


Texture = store.Get(@"F");
//TextureStore will return the already cached (and dynamically atlased texture).

For arbitrary textures, we need something like this:


AtlasTextureStore store = new AtlasTextureStore(Game.Resources.Get(@"Textures/main"));
//will load Textures/main.layout Textures/main_0.png ... Textures/main_n.png into many TextureAtlases (and thus GL memory) at load time.

Texture = store.Get(@"menu-osu");
//return Texture with TextureGlSub from the assigned atlas.

Open for feedback or implementations.

@peppy peppy added the proposal label Aug 31, 2016
@ghost
Copy link

ghost commented Sep 1, 2016

So what is main.layout? do the other files i.e. main_n.png ,etc... correspond to whole sprite sheets or individual textures?

Also make GlyphStore a subclass of what? It is already derived from IResourceStore. I'm not sure what you want the potential superclass of GlyphStore to provide, or precisely what else derives from it.

Are there any constraints on the size of the texture atlas? Your TextureStore makes atlases of size 2048x2048, why that size?

Just curious.

@peppy
Copy link
Sponsor Member Author

peppy commented Sep 1, 2016

  • main.layout would define the sprites in main_0 .. main_n.
  • a class other than GlyphStore will be required to do non-character-based lookups. Functionality can be moved there which is shared between GlyphStore and the new store.
  • 2048x2048 is chosen because all GPUs supporting our GL target version support it. In the future, it could potentially be set to the gl_max_texture_size where that becomes an optimisation.

@Tom94
Copy link
Collaborator

Tom94 commented Apr 8, 2017

No longer relevant

@Tom94 Tom94 closed this as completed Apr 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants