Rules for engine rendering of unit images (Feature Request)


  • Admin

    The engine's rendering of unit images on maps have always had an annoying flaw, as it is often seen that one unit image overlaps another when the territory or the original standard placement seize is a bit too small. Or if the specific unit is just larger than the average unit of the map.

    Example: (and NO, the Ogre is not wearing a house as a hat!)
    2.png

    Here we se an example of a bad rendering order. The Ogre should stand in front of the house. The issue is especially annoying on maps that make use of a 3D-like visuals and unit pictures of various sizes. To me it also seems kind of random which picture gets to overlap the other.

    I would suggest a graphical rule that would improve the quality of the visuals on may maps: The top unit picture should always be the one with the higher X or Y placement value. This way the illusion of 3D can at least be supported. Mapmakers and players also know what to expect graphically, when larger units mingle among smaller units.

    Is this doable?


  • Admin

    @Frostion I agree with the idea. Essentially unit images that are lower on the screen appear on top. I guess secondarily then units further to the right appear on top in case of horizontal overlap. I'm not sure how its determined at the moment. Do you think its random or maybe based on placement ordering? I haven't tested this much or looked at the code.


  • Moderators Admin

    @redrum and @Frostion Would be a very welcome graphical improvement.
    !


  • Moderators

    @Frostion I think it should be map settable if to prioritize higher or lower Y. If not set, then I guess keep it random like now. Same for X.

    And, yes, this would be cool to support maps made in projection, likely axonometric.
    https://en.wikipedia.org/wiki/Axonometric_projection

    However, if making a map based on simulating objects resting on a surface underneath them, then also drawing them from the top left corner would come into question, but they should be rather drawn from centre bottom, if prioritizing higher Y and not prioritizing any X, for example.


  • Admin

    @redrum said in Rules for engine rendering of unit images (Feature Request):

    Do you think its random or maybe based on placement ordering?

    I have tried to investigate the behavior. To me it seems pretty random, but with some tendencies in regards to when the position is affected. I have tried to start up a map several times and look at the the same territory with units that sometimes end up in the foreground and sometimes in the background, even though it is clear what position has the higher XY coordinates.

    The three units are placed at Thunder Bluff from game start. A "Horde-Capital", "Flag" and "Footmen". This is just after map loading (here with the Footmen ending up in the back ... tip of sword is behind Horde-Capital.
    1GameLoadUp.png

    I removed Flag. Still ends up behind Horde-Capital.
    2RemovedFlag.png

    Placed Flag again and Footmen ends up in front.
    3AddedFlagAgain.png

    Then I try to reload the map. This time the Footmen are starting in front:
    4GameLoadUp.png

    I remove the flag ... like before it ends in the back:
    5RemovedFlag.png

    During the placement it goes to front:
    6DuringPlaceFlag.png

    But after placement it is in back:
    7AddedFlagAgain.png

    So it seems pretty random. But the most notable find is, that when units are placed, even outside territory during game loading ("setupRandomStartDelegate") it can (sometimes) affect units to go front to back or back to front, sometimes several times. When altering units in territory, it also affects the position.

    Note that during my test it might not be the Footman only that changes position. I guess that it might instead be the Horde-Capital or maybe both (all units)?

    Question: Du we have a dev who is into these graphics and mechanics of the visuals? I have the impression that this aspect of TripleA is seldom addressed. I hope we do 😉


  • Moderators Admin

    @Frostion It does seem totally random. I have run some of the same tests and found no discernible pattern. It also changes when you toy around with the zoom function.


  • Admin

    @Frostion To answer your question, not really. Most of the tile and unit drawing code hasn't been changed much in a very long time. The only somewhat related updates have been to add the unit flags and unit icons for technologies used in TWW. I would need to spend some time reading through the unit drawing code to figure out exactly how it works and if a change like this is possible to make.


  • Admin

    So I glanced at this and the simplest answer is to try and draw unit images in the order you want them to appear back to front. The 2 challenges are as follows:

    1. The map screen rendering is divided into tiles which are essentially 256 x 256 pixel squares that as a grid represent the entire map. A territory can span multiple tiles so in order to have the units drawn in a certain order, you'd have to consider the order in which the tiles are drawn. And if you redraw the bottom tile for say territory A last then it could create a cascading effect where then it overlaps the top of Territory B which now needs another tile under it to be redrawn, etc.
    2. Need to ensure units in a territory within a tile are rendered in a certain order. Right now there doesn't appear to be any ordering and its essentially random. It may sometimes follow the placement ordering but this doesn't appear to be guaranteed. This could be addressed.

    So with that approach the short answer is they could be drawn a certain order within a tile but a territory could span multiple tiles which without redrawing some/all tiles below and to the right of the territory, I don't think it would be possible to guarantee order.

    Another I think related problem is unit overflow drawing which I again believe is essentially random. Sometimes the overflow bar/units are on top and other times they are on the bottom.


  • Admin

    @redrum Drawing the units within the 256x256 areas in an orderly fashion would probably guarantee like that most (75%?) of the units look good.

    From what you say I imagine that, for example, when one 256x256 area is drawing its units as a result of an updated situation (or just when the player interacts with a territory, like when I clicked a territory to add a flag and the units rearranged themselves), then often other adjacent 256x256 areas, to the top, buttom, left of right, simultaneously do their own updates of unit pictures in their own speed. An therefore even if the single areas are ordered nicely, we may still see strange overlaping where the "border" units meet and overlap each other.

    I think it would be a good start to have orderly drawing within just areas. @Hepps don't you think so?


  • Admin

    @Frostion Exactly. And so if say those adjacent areas redraw after the initial one then if they have overlapping unit images they would appear on top. Plus those adjacent redrawn areas then could impact other territories.


  • Moderators Admin

    @redrum Seems like a good place to start. Very interesting... I had always wondered what impact the 256 x 256 had other than when the map itself was being rendered. I hadn't realized it affected unit placement as well.


Log in to reply