Skip to content

feat(csg): -texchart, what each texture costs the bsp - #2

Merged
metita merged 1 commit into
mainfrom
feat/texture-cost-report
Aug 2, 2026
Merged

metita merged 1 commit into
mainfrom
feat/texture-cost-report

Conversation

@metita

@metita metita commented Aug 2, 2026

Copy link
Copy Markdown
Owner

Why

Measured both of the maps in Documents/Mapping, compiled with their real flags:

lump zm_azteca zm_eichen
texdata 2.263.180 B — 82,8% 1.842.804 B — 69,9%
lightdata 236.490 B — 8,7% 405.981 B — 15,4%
visdata 15.210 B — 0,6% 12.444 B — 0,5%
entdata 9.700 B — 0,4% 17.617 B — 0,7%
total 2.732.216 B 2.637.540 B

Textures are the map. -chart prints one texdata total and stops, so there is no way to tell which textures that is or whether the resolution is doing any work.

This also kills two ideas that looked reasonable before measuring: lightmap deduplication targets 9-15% of the file and would recover a fraction of that, and duplicate textures are essentially absent (0.1% on eichen, 0 on azteca). Neither is worth building.

What it does

-texchart, off by default, after WriteMiptex:

     bytes  share   size       painted    oversampled  texture
    174892   7.7%   512x256        83520        0.5x  zg2026jun3
     87852   3.9%   256x256      2683422        0.0x  BT_wall04
     87852   3.9%   256x256        38776        1.5x  BT_door01
  • bytes come from the gaps between consecutive lump entries, so padding is included rather than recomputed from the WAD3 layout.
  • painted is the world surface area the texture ends up on, accumulated per texinfo in WriteFace for hull 0 only.
  • oversampled is texture pixels over pixels actually displayed. The texture axes are scaled by texels-per-unit, so their lengths turn world area into displayed pixels exactly. Above 4x, halving each axis still leaves a pixel per pixel on screen.
  • Textures with byte-identical first mips are flagged.

Why the area cross-reference matters

A naive "halve every texture 256px and up" projection claimed 70% off zm_azteca. With the area accounted for, the real answer is that nothing on azteca is oversampled — those textures tile across very large surfaces, and downscaling would only look worse. The naive number was measuring nothing.

Actual results:

  • zm_azteca: 32 textures, 2.269.304 B, nothing carrying 4x more pixels than it displays.
  • zm_eichen: 90 textures, 1.941.720 B, 3 worth halving (118.326 B, 6.1%), one duplicated pair (black/white, 32x32, 2.172 B).

The duplicate figure cross-checks against an independent Python parse of the same bsp.

Safety

Off by default, and AccumulateTextureArea returns immediately when it is off. It only reads back the lump CSG has already written, so it cannot change compiler output. All five tools build clean; with the flag absent CSG prints nothing extra.

On a map compiled with -nowadtextures the texture lump is most of the
file: measured 82.8% of zm_azteca and 69.9% of zm_eichen, against 8.7%
and 15.4% for lighting. -chart reports a single texdata total and stops
there, which is where the question actually starts.

The report lists textures by bytes, flags any whose pixels are byte for
byte identical, and crosses each against the surface area it paints.
The texture axes carry the texels-per-unit scale, so the number of
pixels a texture ever displays is computable rather than a guess: with
4x more pixels than it displays, a texture can lose half its resolution
in each axis and still have a pixel per pixel on screen.

That distinction is the point. A naive "halve everything 256px and up"
projection claimed 70% off zm_azteca; the real answer there is that
nothing is oversampled, because those textures tile across very large
surfaces and downscaling would just look worse. zm_eichen has 3
textures worth halving (6.1%) and one duplicated pair.

Off by default. Only reads back the lump CSG has already written, so it
cannot affect the output.
@metita
metita marked this pull request as ready for review August 2, 2026 04:58
@metita
metita merged commit aa3a9ea into main Aug 2, 2026
4 checks passed
@metita
metita deleted the feat/texture-cost-report branch August 2, 2026 05:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant