mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:00:52 +01:00
[PR #2084] dds_png: pick the BC4/BC5 SNORM ramp from the stored endpoints (DDS-PNG-SNORM-MODE) #2090
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#2090
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/2084
Author: @syfyra
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/dds-png-bc4-snorm-mode📝 Commits (1)
9797ec6dds_png: pick the BC4/BC5 SNORM ramp from the stored endpoints (DDS-PNG-SNORM-MODE)📊 Changes
2 files changed (+24 additions, -8 deletions)
View changed files
📝
tests/test_dds_png.py(+15 -0)📝
tools/dds_png.py(+9 -8)📄 Description
Claimed in the coordination issue as: DDS-PNG-SNORM-MODE (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7172770290)
What and why
tools/dds_png.py_bc_interp_lut_snormclamped a -128 endpoint to -127 before choosing between the eight- and six-value ramps. D3D's BC4_SNORM rule compares the stored int8 endpoints (red_0 > red_1) and reads -128 as -127 only once it becomes a value; DirectXTex and Pillow decode it the same way.So the endpoint pair
0x81, 0x80(-127 > -128) is an eight-value block whose entries are all -1.0. The clamp made the two endpoints equal, the six-value ramp was taken, and index 7 decoded to its constant +1.0: 255 instead of 0 in the PNG, for BC4_SNORM and both channels of BC5_SNORM (DXGI 81/84 and theBC4S/BC5SFourCCs). The ramp is now chosen from the stored values and only the values are clamped. Of the 65,536 endpoint pairs this changes the ramp of exactly that one.Tested
Windows 11, Python 3.14.7, synthetic blocks only:
python -I tests/test_dds_png.py: the newBc4Tests.test_snorm_ramp_is_chosen_by_the_raw_endpoints(BC4S and BC5S, both endpoint orders) fails onmainwith255 != 0and passes with the fix; 101 tests OK.dds_pngand by Pillow 12.3: onmainone mismatch (0x81, 0x80, index 7: 255 vs 0); with the fix the largest difference is 1 (rounding).test_dds_png_dx10,test_dds_subresources,test_gallery,test_world_build,test_batch_glb;python -m compileall;scripts/check_no_game_data.pyon both files. Not run:tests/test_tex_export.py(pytest and numpy).GPUs tested: n/a (CPU-only decoder)
AI-assisted: yes (Claude Code, Claude Opus 5.5)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.