Skip to content

Performance: merge prerendered layers #216

Closed

Description

@parasyte

I can see this being a pretty big win for large maps with lots of layers. Most of the time, a map is entirely static... There might be a few parallax layers, and maybe an object layer sandwiched between two tile layers, etc. But there are cases where we could (and should!) merge static tile layers when pre-rendering is enabled.

One of the reasons for moving to the "dynamic rendering" method in 0.9.4 was to reduce memory cost. Pre-rendered layers have very high memory consumption with a large map, but memory usage is doubled when there are two layers in the map, and _quadrupled_ with four layers, etc. If we could determine at parse-time which layers can be merged into a single canvas, then we can benefit from the improved speed offered by the pre-render feature, as well as reducing the memory footprint AND overall drawing time.

Activity

  1. obiot commented on May 9, 2013

    @obiot
    Member

    That's for sure a good point, and could easily be achieve by looping through the layers and merge them until we reach a non tiledLayer. Only thing I would say against it, is that this is achievable today in Tiled, so why bother ?

    Now, that makes me think back about what I had in mind in terms of object management. Today Object Group is purely a view on Tiled side, and completely un-used if I can say on melonJS side. I don't know if it makes sense, and it's kind of a rough idea, but as an improvement we could really have a specific Object Layer (with a canvas of the size of the viewport, on which we would draw the entities). This will bring other small advantages like being able to add special effects to objects (like my previous attempt to color blending), ease with global viewport zooming, etc...

  2. parasyte commented on May 9, 2013

    @parasyte
    CollaboratorAuthor

    Does Tiled have a "bake" function that I'm unaware of? I know there's a separate script available for doing exactly this, because I went looking for such a thing when I was developing Neverwell Moor. https://github.com/falanxia/tileset_baker/wiki

  3. obiot commented on May 9, 2013

    @obiot
    Member

    yes, there is a "merge down layer" option available through the contextual menu.

  4. parasyte commented on May 9, 2013

    @parasyte
    CollaboratorAuthor

    Oh, yeah! It doesn't actually do what I need, though. It just replaces the tiles in the lower layer. A proper merge would actually draw the tile overtop, so the lower tile could still be seen where the upper tile had transparent pixels. That's what the tileset baker actually does (see the example images on the wiki page), and what I'm proposing for this ticket.

  5. obiot commented on Feb 21, 2017

    @obiot
    Member

    interestingly the next Tiled version will have a group layer features, which means that we now have a proper "standard" way to merge layers from the same group.

    mapeditor/tiled#1038

  6. obiot commented on Aug 31, 2017

    @obiot
    Member

    with #876 being done, this one should be one step easier to be done.

  7. locked and limited conversation to collaborators on Sep 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions