Search Results for

    Show / Hide Table of Contents

    Quality, Performance and Debugging

    Tessera uses Wave Function Collapse as its core algorithm, though with many custom enhancements. This is a constraint solving based approach to generation, and it is very powerful, but it comes with some limitations. The algorithm searches through the space of possible tile choices to find one that fits all the constraints and adjacency rules required.

    If there's no possible solution, Tessera will fail, reporting a contradiction. And if there's only a few possible solutions there are, the more Tessera will struggle to find one. Tile adjacency is Turing complete, so there are inputs that will just take forever to generate.

    This page gives some advice on how to get the most out of Tessera.

    Backtracking

    Backtracking is a critical feature of most constraint solvers, though normally WFC doesn't feature it. With backtracking off, the generator will give up the moment it encounters any difficulty. With it on, it will instead undo the last tile generated, and try again with a different option.

    Enabling backtracking can therefore make the solver work much harder at finding a solution. The downside is that it can run forever looking for a solution, and can sometimes get stuck exploring possibilities that will never work.

    To get the best of both worlds, you can introduce a Step Limit. This will allow some backtracking to occur, but after a fixed amount of computation it will automatically retry with a fresh generation.

    Errors and contradictions

    Not all setups for the generator have a solution at all. When the generator fails to find a solution, it'll log a warning detailing what has gone wrong.

    To enable more diagnostics, set Failure Mode to Last, and add prefabs to Uncertainty Tile / Contradiction Tile. This will cause the generator to output a clearer picture of the problem.

    The above picture shows a failed generation, with white tiles indicating what has yet to be generated, and the red tile indicating where the contradiction occured. You will have to infer what the specific problem is. In the above case, the generator wasn't set up with a dead end tile, so there's no way for the path to complete.

    Here are some other tips to help determine what is going wrong:

    • You can use a fixed seed to make any issues reproducible.
    • You can select uncertainty tiles in the Inspector, they have some additional information attached.
    • Try disabling the constraints (both initial constraints and generator constraints) until things start working.
    • If you have no constraints, try removing tiles that are difficult to fit in, such as Big Tiles.
    • Conversely, sometimes adding tiles can help. You can try adding a tile without any faces painted and with very low weight, which means it can be placed anywhere in the generator as a last resort.
    • (Pro only) Use AnimatedGenerator to display the generation in realtime. This can be useful when backtracking is on, highlighting areas that cannot be successfully completed.

    Performance Tips

    If you have very large levels, or a particularly hard to generate setup, then you may find Tessera's performance starts to become a problem. Here are some suggests to combat that.

    If all else fails, ask on Discord. I'm making performance enhancements all the time.

    Disable "Record Undo"

    This option is on by default, and affects TesseraGenerator when you run it by clicking the "Generate" button in the Inspector panel. Recording undo information is painfully slow in Unity, and will cause the Editor to freeze temporarily while creating all the generator tiles. This setting has no effect at runtime.

    Change generation algorithm.

    Tessera's default constraint resolution algorithm is called "AC4", which resolves all constraints every step. You can instead try "OneStep", which only resolves nearby constraints. It can be faster in some circumstances, but also has less lookahead so is more likely to fail or backtrack.

    Reduce the number of tiles

    Doubling the number of tiles makes Tessera approximately 4x as slow, so it's worthwhile minimizing tiles. The easiest way of doing so is enabling the symmetric setting and avoiding similar/duplicate tiles.

    Path constraints

    The Path constraint is very expensive compared with the rest of Tessera. Avoid if it possible, for example, by pre-generating your path and using pins to make Tessera use it.

    The path constraint does come with two experimental settings, prioritize and parity that improve search quality, so you may want to try enabling those.

    In this article
    Back to top Generated by DocFX