Skip to content

move from materials-per-map to global, hash validated materials folder with per-map fallback - #76

Open
SurfSam wants to merge 14 commits into
Metapyziks:masterfrom
SurfSam:feat/global-materials
Open

SurfSam wants to merge 14 commits into
Metapyziks:masterfrom
SurfSam:feat/global-materials

Conversation

@SurfSam

@SurfSam SurfSam commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Verified with a sample of ~50 maps partially sharing textures.

Additions:

  • TextureSource generates material paths like \materials\<map_name>\<texture>.vtf\<hash>\mip0.png to deduplicate exact shared materials

Fixes:

  • .toLower() at Texture.cs:67 supposedly breaks for some languages, not sure if those were covered by Source in the first place tho
  • GameLump.cs:115 [i + 1] was calling out of bounds exception

SurfSam and others added 14 commits September 17, 2026 09:50
Maps compiled before the Orange Box store one bare ambient cube per leaf and
write no index lump, so reading the lump through the index gave every leaf zero
samples and left props and the world unlit. The layout has to be recognised by
size, because those maps write the lump length into its version field.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A prop whose origin lands inside a solid brush resolves to a leaf with no
samples. Using it anyway asked for an ambient cube that never arrives, so the
prop stayed unlit forever.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Returning null writes no response body at all, which drops the connection and
has the exporter record the file as failed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Named lights get their own switchable style, and VRAD writes their samples in
pages after style 0 rather than into it. Only the first page was being read, so
every named light was missing from the exported lightmap. Styles are summed in
linear space, and a style is left out when every light using it starts dark.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
StaticPropV10Bsp20 declared ColorModulation at byte 64, but in that layout those
bytes are a widened copy of the flags field. The exporter wrote the value out as
albedoModulation and the shader multiplies prop albedo by it, so 0x100 decoded
to R=0, G=1, B=0 and rendered every prop black.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Both threw from the size and conversion switches. A8 widens to white with the
stored alpha, BGRA4444 widens each 4 bit channel so 0xf becomes 0xff.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Some maps pack unrelated files under .vhv names, so a header's mesh and vertex
counts can point far outside the file. Placeholder files holding no meshes at
all are treated as having no vertex lighting, and a model packed without its
.vvd or .vtx is skipped with a warning instead of throwing.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Plenty of maps name an hdrcompressedtexture without packing it, and skies built
from an environment cubemap have no base texture either. Each candidate now has
to resolve before it is used, and a sky with nothing to draw with is dropped.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Material pages kept rewriting texture urls into per-map indices, which pulled
every frame and mip level of a shared texture into each map that used it. Urls
into the hash addressed materials folder are now left alone, so a texture is
fetched and exported once. Hash addressed urls also skip the timestamp query
and, once exported, are not requested again: they cannot go stale while their
file exists, and neither can anything below them.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Re-exporting a map meant re-exporting every texture it touches, and picking up a
change to how textures are converted meant re-exporting every map. The content
hash of a source .vtf cannot see a change in the converter, so overwriting
materials stays a deliberate choice. --overwrite still implies both, and static
viewer files are always replaced.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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