Blending and tile sets

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • backwardsEric
    Knight
    • Aug 2019
    • 527

    Blending and tile sets

    I'm tidying up the tile rendering in the Cocoa front end and had some questions about how blending should be handled with the tile sets in Angband.

    1) How should the alphablend field in the graphics mode structure be interpreted? The comment about the alphablend field in the graphics mode structure says "Bool whether or not the tileset needs alpha blending". Based on how it's set for the current tile sets, it looks like it is zero if the alpha channel only has values of zero and 255 (i.e. either completely transparent or completely opaque) and nonzero if the alpha channel takes on values that are not zero and 255. Is that the correct interpretation? If so, why does the Gervais tile set have a value of zero for alphablend? From what I see (read in the PNG file in Python with PIL and examine the alpha channel with numpy), it has some values in the alpha channel that are not zero or 255.

    In terms of providing hints to the front ends, it may be useful to have something in the graphics mode structure (either more possible values for alphablend or a separate field) that says a tile set has no alpha channel. The front end could use a faster rendering path for those tile sets. Of the current tile sets, the Nomad tiles don't have an alpha channel (at least from what I see using Python with PIL to look at the PNG file).

    2) What's the appropriate rendering strategy for double-height tiles used as background or terrain? From what I see in the Windows front end, the top half of such a tile is blended with what's already been rendered for the cell in the previous row. So it can obscure both the foreground and background for that cell. An alternative would be to render the background parts first (first the background tile for this cell and then the top half of the double-height background tile from the next row if present) and then the foreground (first the foreground for this cell and then the top half of the double-height foreground tile from the next row if present).
  • Pete Mack
    Prophet
    • Apr 2007
    • 6883

    #2
    that is correct. Transparency allows the background tile to show thru, rather than just black. That is only use of alpha

    Comment

    • Nick
      Vanilla maintainer
      • Apr 2007
      • 9634

      #3
      For the second question, I thought the only double-height tiles were monsters, which I think means you don't have to worry - but I'm really not sure at all on this.
      One for the Dark Lord on his dark throne
      In the Land of Mordor where the Shadows lie.

      Comment

      • backwardsEric
        Knight
        • Aug 2019
        • 527

        #4
        Originally posted by Nick
        For the second question, I thought the only double-height tiles were monsters, which I think means you don't have to worry - but I'm really not sure at all on this.
        Yes, none of the features in graf-shb.prf map into the double-height rows. So how to order the rendering for the top half of a terrain tile doesn't matter at this point. I'll try to mimic what the front ends for Windows and SDL do for drawing double height terrain tiles.

        For the alphablend setting on David Gervais's tiles, I'll check how it renders on Windows (the only front end currently adjusting it's behavior for how alphablend is set) and submit a patch if setting alphablend to one for those tiles seems better.

        Comment

        Working...
        😀
        😂
        🥰
        😘
        🤢
        😎
        😞
        😡
        👍
        👎