Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-59868

Alpha support for atlassed/compressed textures

    XMLWordPrintable

Details

    • Task
    • Resolution: Won't Do
    • P2: Important
    • None
    • 5.10
    • Quick: SceneGraph
    • None

    Description

      When atlassing output file format may or may not need alpha, depending on the images stored in each atlas image. (It's a per-atlas-image decision). Might also be wise to allow to specify the output format e.g. masks can use a single channel format.

      The specific texture compression format to use changes whether alpha is required or not. When atlassing, this information needs to be passed to the compressor per each image.

      If alpha is used with a compressed format then we need to premultiply it because that's what QQ2 expects when it samples from textures with alpha. Since noone of the compressors I've found actually premultiplies alpha (because, I think, OpenGL lacks a premultiplied alpha format), then we must do it as a preprocessing step, before feeding images to texture compressors.

      (Note that if we are atlassing AND compressing, this "preprocessing" could be done by the atlassing tool itself).

      Writing such a preprocessor is not possible using QtGui facilities at the moment, because none of the Qt image writes can write premulitplied alpha:

      • the PNG format does not support premultiplied alpha. Qt correctly saves PNG with non-premultiplied alpha.
      • BMP supports it, but Qt doesn't save BMPs with alpha
      • TIFF might support it, but anyhow Qt doesn't save TIFFs with alpha
      • ...

      The only workaround to this problem that I've found is saving to PNG, then resorting to imagemagick and premultiply alpha manually, saving the result in BMP. Handy command line:

      for i in *png; do 
          convert "$i" \( +clone -alpha Extract \) -channel RGB -compose Multiply -composite "$(basename "$i" .png).bmp"
      done
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            janichol Andy Nichols
            peppe Giuseppe D'Angelo
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes