Clarification on how to do a great job importing textures

Does the “2 bits” or “4 bits”, in the PVRTC import settings, refer to bits per channel, pixel, or what? Is it an average of something?

If a grayscale image looks good enough with the compression, which is better: PVRTC 4 bits or Alpha 8 bit?

Is “RGB Compressed PVRTC 2 bits” the best import setting available for a 1-bit image?

Is there a benefit to using a complete RGBA image, as a “2D” property in ShaderLab, as opposed to two grayscale ones? (That is, does ShaderLab allocate resources for a complete RGBA image for every “2D” property, or does it only allocate resources for a single channel, if that is what your image has?)

I’ve learned today that, apparently, if you choose “Alpha 8 bit”, then you are really only saving the “A” channel, as an “A” channel. The concept of a grayscale image doesn’t seem to exist in Unity. So PVRTC is the way to go in this case.

Given what I learned, this is entirely dependent on the answer to my first question. If “PVRTC 2 bits” means two bits per channel, as I suspect, and you’re using the 1-bit image as an alpha channel, then no, “Alpha 8 bit” is better.

I’m still quite interested in the answers to my first and last questions, although, for the latter, I bet it only matters when you need a really clean alpha channel, but can live with artifacts in the RGB component.

pvrtc are bpp (bits per pixel)

pvrtc 2bpp compresses all color informations into 2 bits per pixel, instead of 16 / 32 bits

As for A: thats a standard texture format, nothing unity specific. Alpha textures and luminosity textures are textures intend for special usages. Don’t know thought if A8 is supported on the iphone at all as it has only fixed function pipeline, where A8 makes pretty no sense, as FFP is opted for 32bit, not variable bit length. anything that has no 32bit block sizes requires virtual offsetting etc

I don’t see any difference on an RGB image between RGB and RGBA PVRTC, so I think it has to be “per pixel, per channel”. (On the other hand, when I go from RGBA 16 bit to RGBA 32 bit, or even RGB 24 to RGB 16 on some images, I notice a difference. Also, 2 bpp for a 4-channel image just doesn’t sound like enough to get much useful data out of.) Which is what I meant above by “per channel”. Is this what you are saying also? It doesn’t seem so from your statement, but it doesn’t make intuitive sense to me otherwise.

…after further testing…

okay, the “Memory” number indeed reflects what you said. 2 or 4 bits per pixel. Given that, I can’t believe how well the results turn out. Is there a place to learn about how PVRTC works? It seems like magic to me at this point.

I don’t see how A is any different than R, G, or B. They’re all just grayscale images. It seems weird to me that we can’t just import a grayscale image into Unity and have it serve as whatever channel we like, a la Photoshop.

A is different because in a fixed function pipeline especially the iphone one, A decides where a pixel goes during the handling.
The iphone has very strong early out hardware logic for occluded pixels so overdraw is reduced. With alpha in the texture, thats not possible.

As for how pvrtc works: potentially at the imagination tech page. Generally it works like DXT / S3TC (which is bpp 4 - bpp 8 for 32bit textures on pc / mac )

PVRTC is a block based compression format, using 64 bits for blocks of 4x4 (4 bits per pixel) or 8x4 (2bpp) pixels. The high compression ratio is achieved by only storing two colours per block and interpolating the rest.

The 2bpp mode uses dithering thus it’s probably not that suitable for 1-bit images, but 4bpp should work fine.

Texture sampling itself is a fixed function block that can deal with various different texture formats, including (on the iPhone) formats with 2, 4, 8, 16, and 32 bits per pixel. An A8 texture simply gets expanded to the RGBA vector (0, 0, 0, A).

An alpha texture does not have to represent transparency. You can set up combiners/shaders to multiply colours with the alpha channel or use the alpha value as an interpolation factor, for example.

If I only need an alpha channel, but am using a compressed format, how do I optimize its appearance?

  • Make the RGB channels black
  • Make each channel the same thing
  • Some other option?

Using black should give the best results.

Actually, you won’t have to change RGB at all :

Even if it’s monochrome, it is still a R(value) G(value) B(value).
Black would be R(0) G(0) B(0), which would not make much difference with R(28) G(255) B(140) :wink:

What you could do to optimize treatments, especially if it’s a compressed format, is to visually make your RGB channels a whole unique color block, so that compression will lead to a minimal size.

Such as, say, black? :wink:

I’m not sure what you what you were talking about in that post…

Difference to what?

Oops sorry, I understood that “black” was just the color, not the picture :wink:

In short, any uniform color block would fit ^^