Generate complete mipmap chains for compressed DDS images #86360
+32
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adjusts the DDS image loader, to ensure that the mipmap chain of compressed images is complete. This aligns with expectations elsewhere throughout the engine, that images with mipmaps will be mipmapped all the way down to 1x1, and will not have partial mipmap chains that terminate at some higher level.
Some DDS exporters create images whose mipmap chains terminate above the 1x1 case (often 4x4 or 8x8). To create the missing mipmap levels, this PR repeatedly copies the first block of compressed data from the last mipmap level that exists in the DDS. This is not mathematically correct, however the hope is that it will create mipmaps with colors that are similar enough to correct, as to not be visually objectionable, given that these low mipmap levels will only be occupying a few pixels on the screen.
The "correct" solution would require decoding the image, resampling it, re-encoding into a compressed form, and copying the result back into the original image data. I felt it was best not to incur that performance & complexity overhead on image loading, unless and until complaints are received about last-level mipmaps of DDS textures looking wrong. The limited color palette available in DXT-compressed pixel blocks means that low-level mipmaps tend not to look much like the original image, anyways.
This PR does not adjust the handling of compressed images which did not have any mipmaps populated in the source file; those images will be left un-mipmapped, as I believe the remainder of the engine is prepared to accept them in that state.
This PR resolves #86330