Skip to content

Civilization banner: the flag cloth's shader on Metal/Vulkan, the banner's framing and fringe as the original's - #74

Closed
MortenLyhr wants to merge 13 commits into
bssth:masterfrom
MortenLyhr:fix/civ-banner
Closed

MortenLyhr wants to merge 13 commits into
bssth:masterfrom
MortenLyhr:fix/civ-banner

Conversation

@MortenLyhr

@MortenLyhr MortenLyhr commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Builds on #73 (which builds on #56): this branch contains #73 (merged in, up to its Windows link fix) and adds three commits on top (4d9fe88, b835acc, b9721e2). Please merge #56 and #73 first.

What it changes

The banner by the minimap (addFlagWidgetGFC) and the flag cloth, compared with the original (Beyond the Sword under Wine, the same scenario, 1600×900):

  • Flat flags on macOS and Vulkan. Render animated civilization unit flags #56 added the flag cloth's shader path (colours × the cloth's base map, flags bit 4096) to the HLSL only. MslShaders.inc and SpirvShaders.inc still laid the composed decal over the cloth, so every flag there, on the map and by the minimap, was one flat colour, without the base map's folds and cut edge. Regenerated with tools/shaders/gen_msl.py and gen_spirv.py (--check was failing). The banner's cloth now measures 166,73,215 against the original's 166,67,214. Civilization flags as the original's: unlit cloth, medallions, health bars, the minimap's banner (builds on #56) #73 has since regenerated them too (be25b12); after Civilization flags as the original's: unlit cloth, medallions, health bars, the minimap's banner (builds on #56) #73 is merged this commit adds nothing of its own.
  • Size and place. The widget is 68×250 at (xRes − 288, yRes − 138). Fitted to the model's box, the banner came out about 4 % small, 4 px high and 5 px left of the original's. It is now seen from the front with the pole in the middle, 1.06 × the model's height filling the picture, centred 0.53 of it up (ModelView::frameAsFlag). That puts it within 1 px of the original in size and place.
  • Fringe. The modern flag's trim (Medieval_Flag_Trim.dds, alpha about 0.5, SrcAlpha/InvSrcAlpha) shows faint over the panel in the original: colour × ~0.2 + panel × ~0.72. That fits a widget drawn into a target whose alpha is blended too (a²) and then laid down by that alpha again (colour × a³ + panel × (1 − a²)). OpenCiv4 composited it correctly, so the fringe was bright gold. Renderer::beginView takes alphaTwice (flags bit 8192) for the banner only.
  • Mips. The composed cloth (the civilization's decal in the player's colours) had one level; the original's decals are DDS files with all their mips (FlagDECAL_Laurels.dds: 128×128, 8 mips), sampled trilinearly. Now Renderer::createMipmapped, for the map's flags and the banner.

Unchanged, because they already match: the animation is the flag KFM's only clip (*_MD_Idle.kf, 3.33 s, looped); the original's banner repeats every ~3.4 s in 0.263 s bursts. Hover shows parseFlagHelp (civilization, leader, traits); a click runs CONTROL_SELECTCAPITAL.

Banner at 2×: original, #73, this branch
Waving: the original every 0.263 s (top), this branch (bottom)
Original left, this branch right

ctest passes 14/14 and the 100-turn checksums (--turns 100 --map Fractal --size STANDARD --seed 7) equal master's.

Not done: the original's emblem still looks a little bolder, probably its texture detail setting dropping the top mip.

🤖 Generated with Claude Code

go140point6 and others added 13 commits November 16, 2026 18:17
# Conflicts:
#	apps/oc4core/MapCapture.cpp
#	apps/oc4core/MapCapture.h
TFlagShader takes no light: the player's colours times the cloth's base map.
Lit, the flags came out about a quarter darker and bluer than the original's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A ship's damage atlas moves along U by +0.5 to its lightly damaged left half
(unchanged); a flag's medallions move along V by -0.2 a row, up their strip
from its empty bottom row, which only works with V flipped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Over each flag, a medallion for each unit on the plot (Art/Units/Flag/
  Medallions.kfm, up to 7): white, green/yellow/red for selected units by how
  they can move. The promotion coin in the same model stays hidden.
- Health bars as the original's billboards: HEALTH_BAR_WIDTH over the
  UNIT_HEALTH_BILLBOARD_SCALE fader long, behind the unit and above the ground
  (..._RADIUS, ..._Z), drawn in the scene so the figures hide part of it.
- The flag by the minimap is the player's era flag model, waving, its cloth
  in the player's two colours, instead of a flat picture.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Measured in the original with hurt units (Swordsmen at 100 % to 10 %, units
from Strength 2 to 40): the bar's length is what the engine gets from the DLL,
the unit's current strength times CvUnit::getHealthBarModifier
(HEALTH_BAR_WIDTH over twice the best land unit's strength), so units without
strength have none. Green from two thirds of the hit points, yellow from a
third, red below; as thick at every length. It is a billboard: the _Z fader
moves it up the screen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The flag cloth's colours times its base map (flags bit 4096, from bssth#56) was only
in the HLSL; Metal and Vulkan still laid the composed decal over the cloth, so
every flag there was one flat colour, without the cloth's folds and its cut
edge. Regenerated with tools/shaders/gen_msl.py and gen_spirv.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The main interface's flag is seen from the front with its pole in the middle,
1.06 of the model's height filling the 250 px picture, centred 0.53 of it up
(was fitted to the model's box: some 4% smaller, 4 px higher and 5 px left of
the original's at 1600x900). Its blended parts cover the panel with their
alpha counted twice, as the original's widget pictures do: the fringe comes
out faint over the panel instead of bright gold.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A flag's cloth (the civilization's decal in the player's colours) was one
level only, so a small flag sampled its 128 px emblem texel by texel; the
original's decals are DDS files with all their mips, sampled trilinearly
(Civ4FlagDecal.fx). Both the map's flags and the banner by the minimap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The model shader's flag branch (from bssth#56) was not yet in the generated
shaders: tools/shaders/gen_msl.py and gen_spirv.py (glslang 16.6.0,
SPIRV-Tools v2026.4, as CI's).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CvGame::getBestLandUnitCombat is not exported from the Windows DLL. The
exported CvUnit::getHealthBarModifier already divides by it: a modifier that
is not finite means there is no best land unit yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	src/render/MslShaders.inc
#	src/render/SpirvShaders.inc
@MortenLyhr

MortenLyhr commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Included in bundle 3/6, #147, merged there with its own commits and with its conflicts with the other open PRs resolved (the bundle PR lists them). Closing in favour of #147.

@MortenLyhr MortenLyhr closed this Nov 21, 2026
bssth pushed a commit that referenced this pull request Nov 23, 2026
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.

2 participants