GPUOpen-Tools / compressonator

Tool suite for Texture and 3D Model Compression, Optimization and Analysis using CPUs, GPUs and APUs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Broken mipmaps on some textures

GlaireDaggers opened this issue · comments

Hello!
I've run into a bit of a strange issue with mipmaps on a particular set of textures. I have reproduced this on both Windows and Linux using the latest cli executable from the github releases page (4.5.52)

Here's the texture I'm trying to convert (from Kenney's placeholder textures), which is 1024x1024:

texture_01

And I convert it to DDS via this command:

compressonatorcli.exe -fd BC1 -mipsize 1 texture_01.png texture_01.dds

And that gives me this DDS file:

texture_01.zip

At runtime, I noticed that textures exhibited black striping at a distance. I then decided to look at the DDS in ddsview and I see that the 2x2 mip appears broken (fwiw the exact results aren't 100% consistent - on Linux at one point I was able to get a blue stripe instead of black, so maybe uninitialized memory?)

image

@GlaireDaggers Thank you for providing details and sample for the issue, it helps to determine the cause.

The sample when mip mapped down has these characteristics.
4x4 has grey color, 2x2 contains gray and black, and 1x1 contains gray.

image

As BC codec lowest block size is 4x4, for a 2x2 pixel size color gets filled from the top left corner and the remaining block is black (with alpha 0's depending on what image viewer you have, the sample screen capture views shown here uses green for RGBA:000 0). The gray color sample you have has RGB pixel values around (50,50,50)
It seem that the index colors for the lower half of the 2x2 is not set and remains black.

image

The 1x1 mip level is correct and set gray.

image

This issue of interpolating the correct colors using sample size 4x4 to 2x2 is under investigation.