Repository navigation
Bundle 2/6: terrain, water, borders, roads - #146
Merged
Merged
Conversation
Measured in BtS 3.19 (Wine) with CyCamera at 19 zoom levels and the plot grid at two window sizes: - Tilt: about CAMERA_LOWER_PITCH + 1.8 (29.8 degrees) up to 1.3 x CAMERA_MIN_DISTANCE, then quadratic with the distance to straight down at 0.86 x CAMERA_SMALLEST_MAX_DISTANCE (within 0.15 degrees). At the start distance that is 33.6 degrees, where the straight line gave 42.8. - FIELD_OF_VIEW is across the screen's diagonal: plots 206 px apart at 1600x900 and 170 at 1200x900 at the same camera; it was taken as the horizontal angle (168 px). - What the camera looks at is drawn 56.9% of the way up the window (CyCamera().GetDefaultViewPortCenter() = (0.5, 0.569)), not in the middle. Camera::projection shifts the perspective so the renderer and picking agree. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The city bar is drawn from the game's CityBar.nif layout and textures: the banner (CityBar_Base) with the growth and production bars in its halves, the capital's star or the circle in the population's colour, the production symbol (what the city builds, else the cancel button, cut round by ProductionIconMask under ProductionIconBevel) for the active team's cities, the name and what it builds in the banner's halves, and buildCityBillboardIconString's icons above it. It is placed and sized as the original's CITYBILLBOARD faders (CIV4DetailManager) place it, measured in the original at camera distances of 12 to 102 plots: out from the city towards the bottom of the screen and raised, its size levelling off at 0.67. It is no longer hidden beyond 45 plots, and a click on it is a click on its city (the city screen opens), over any unit figure under it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…LLBOARD_RADIUS The size came from a fit to zooms from the start view out, which grew without end closer in. It is now the star's width as measured in the original at 5 to 102 plots (1.39 points a model unit up close to 0.69 far out). The bar's top sits on the ground south of the city by CITYBILLBOARD_RADIUS (90 units up close, no closer than 70), as the original's plot grid shows, not twice that and raised. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…onIcon The host may call only the game core's exports on Windows: the order queue and GC's info getters are not, so the Windows build did not link. getCityBillboardProductionIcon is the engine's own call for the symbol: the player's button for a unit, and INTERFACE_BUTTONS_NOPRODUCTION when nothing is built (as the original shows), not the cancel button. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The original rounds its borders' corners, outwards and inwards; ours were sharp, and along rivers the line had steps a texel long. - In the plots along a border each texel of the border texture takes the owner of most of the ground within 0.11 plot of it: a straight edge stays where it is, a corner is cut round. Not along a river between owners, where the ground is the bank's. - The texel's distance to the edge is worked out to less than a texel (from how much of the ground around it is another owner's), and the shader takes the pixel's owner from the distances blended between the four texels round it instead of the nearest texel's owner, so the edge runs smoothly between the texels. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The border along a river sat a little inside the bank, cut the river's bends short and was faint there; the original's hugs the near bank through every bend, and between two owners the water is neither's. - The border texture is 32 texels a plot side (was 16: a river's bends are a texel or two at that), two 8-bit channels (a new RG8 texture format) instead of four 16-bit ones, so it takes the same memory. - It is worked out in the plots along the borders only (the others are their plot's owner's, far from an edge): about 70 ms for a 150x104 map with 17 cities, where the whole map at this size took 450 ms. - The river is far to cross for an unowned plot's ground too, and its water and bed between two grounds are nobody's: each side's ground ends at its own bank, round the bends. - By a river the corners are not rounded, so the bends stay. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The original adds the terrain's detail texture and light to the blended tiles instead of multiplying them, so flat land keeps its tiles' own colour: grassland measures as bright as GrassBlend.dds in the original (RGB 129,144,74 against the texture's 128,139,63), where OpenCiv4 was about 11% darker (115,126,61) and greener. - Detail added round its grey, repeated every 2 plots (the landscape's 4 plots a cell at texture scale 2) instead of 3 times a plot: the detail's yellow and dark patches and cracks now have the original's size. - Slopes lighter or darker by how much more or less they face the sun than flat land, from the south-east as the original's hills show (slopes facing the camera lit, the far side of a ridge dark); flat land a little lighter and bluer, as measured. - No relief on flat land: lit, it made large dark cloud-like patches that the original does not have. Measured on a 1600x900 view (Wine vs this): grassland 129,144,74 vs 130,142,74; plains 189,169,109 vs 186,167,110; plains hills 168,156,121 vs 168,155,123. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With the resource layer on, each resource is shown as the original's plot picker draws it: the resource's button cut to a circle in a black disc with a light bevelled rim, on a pale pin whose tip is the plot. The bubble keeps its size at every zoom and stands up and away from the middle of the screen (left of its plot on the left half, right of it on the right half), so it moves to the other side as the view passes over it. Farther bubbles are drawn first, and the layer shows at every camera height, as in the original; the yield and unit icon layers keep their distance limit. Measured against Beyond the Sword under Wine at 1600x900: disc 51 px, pin tip 29 px across and 31 px down from the disc's centre. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The original draws the grid (CONTROL_GRID) by swapping each terrain's blend atlas for its grid texture (<Grid> in CIV4ArtDefines_Terrain.xml, e.g. GrassGrids.dds): the same tiles with a line painted through their middles, where the plot edges run. So the grid lies in the ground: over hills, down to the sea floor, under water, rivers, forests and improvements, and it fades out far away as the atlas mips average the line away. Measured from the textures: on land the ground under the line goes half way to black, 1/128 of a plot wide; on coast half way and on ocean 30% to white, 2/128 wide (so lines over water are light, not dark). The terrain shader now does the same: each terrain's line (grey, amount, width) is measured from its grid texture against its blend texture when the atlas is built, blended through the tile's layers as their colours are, and drawn on the plot edges before detail and light. Its width is in plots (it widens up close) and it spreads and fades with the pixel's footprint as a mipmapped texel would. Before, it was a fixed one-pixel darkening by 35% over everything, water included. Metal/SPIR-V translations regenerated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The grid textures' mips are drawn by hand: down to 16 texels a plot each draws the line again, as many texels wide and as dark as the full texture (so the original's grid stays a crisp pixel or two wide and half dark at every middle zoom), and the smaller mips have none. Measured in Wine at nine zooms (views-grid-zoom.txt). The line was fading with distance as an averaged mip would; now it is drawn per mip as the original's are. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The original draws water as its own plane over the ground (Shaders/FX/Water.fx, CIV4WaterPlaneInfos.xml), unlit: Water.dds twice, scrolling apart, half and half, their alphas multiplied added as sparkles, laid over the sea floor (the coast and ocean terrains' own tiles) at the plane's material alpha (0.5), faded out at the shore, darkened by the fog of war. OpenCiv4 tinted the sea floor a dark blue and added a sun glint instead. - New water pass (kWaterHlsl: VSWater/PSWater) after the terrain: a flat grid at the water's level over every tile with water at a corner, blended, writing depth. The plane's texture, scale, scroll rates and alpha come from the game's CvWaterPlaneInfo (MapCapture). - Scroll rates are per frame at 30 a second; the second layer scrolls the other way (measured from a Wine film: two patterns drifting east and west at about 0.0048 texture units a second each). - The shore: the water ends where the land/water levels blended between plot centres are 0.042 of a plot deep, a little in or out by smooth noise: on a straight coast about a quarter of a plot inside the water plot, a one-plot lake about 0.56 of a plot across, as in the original. - The terrain shader's tint and glint are gone; the sea floor is the terrain's. Measured against the original (Wine, same views): coast 57,121,156 vs 49,121,156, ocean 40,102,143 vs 32,103,143. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The original draws most improvements from CIV4PlotLSystem.xml, not from CIV4ArtDefines_Improvement.xml's single model; only farms were laid out that way. Now: - Mine, quarry, pasture, windmill, fort and whaling boats take their goal art from Leaf_LandImprovement_4x4 / Leaf_Water_Improvement_4x4 by era (modern mine, quarry, pasture, windmill; the three forts; modern whaling boats), turned by the goal's fTwist; a goal without a NIF (an early pasture) keeps the art define's model. - Cottage, hamlet, village and town are houses of the owner's era and art style (art:building on the BLeaf leaves) over the goal's iCropArea cells (5, 10, 15, 25) round a lot near the plot's middle, turned 45 degrees; the goal itself (bPlace:0) draws nothing. Before, each was one small model of thatched huts in every era. - Plantations and the winery: their goal by era and resource on a leaf near the middle, the goal's szExtra and its crops round it. - An unowned plot is drawn in the era and art style of the player looking at it (the game's era is the average of all players, which drew an industrial player's improvements as classical ones). House pieces of the city files stand on the ground (PlotPiece::standing) as the city's own houses do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The plot LSystem marks crops, extras and some goals bCutTrees (the trees on their leaf go) and gives cottages, towns and forts an fCenterCut (a clearing round the goal, in world units). OpenCiv4 cut trees only at the models' own TreeCut nodes, so a plantation's crops, racks and grinders stood hidden in the jungle the original clears for them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The fort goals' fTwist (-45 degrees) turned the fort to a diamond; the original draws it square to the plot in every era (Wine, Ancient, Classical and Industrial test maps). fTwist turns a layout's lots, and a goal the plot root places straight has none. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Checked against Wine's Ancient, Classical and Industrial forts: seen corner-on, the tower on the left corner and the gate front right. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
OpenCiv4's river beds dip below the water's level at the coast, and the water plane drawn over them hid the deltas past the shore: a hard edge across every river mouth. The plane no longer writes depth; the deltas draw over it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A delta's water lay on the sea's as a darker patch past every river mouth: blended pieces are drawn at the end of the frame, after the water. The pieces laid on the ground (rivers' water, roads) are now drawn before the water (Renderer::drawGroundBlended), so a delta's water out at sea is seen through the sea's; and in a river bed the sea's water fades in over a longer stretch, so there is no line across the river where the sea begins. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The original lights units with their own light, Art/Terrain/Lights/UnitLight.nif (art define LIGHTING_UNITS): a directional light from the south, a little east and low (its node at (21529, -50212, 15940), aimed at the origin), diffuse (1, 1, 0.863) at dimmer 0.8, and an ambient light (0.431, 0.431, 0.353). OpenCiv4 lit them with the scene's light from the north-east, so the side of a unit the camera sees (from the south) was in shade and units looked darker than in the original. The renderer now keeps the units' light in the frame constants next to the scene's; MapView sets it for each unit figure (Renderer::setUnitLight), and a mesh drawn with it carries flag bit 14 (also when it is blended and drawn later). MSL and SPIR-V regenerated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The original turns its camera a little east of south, more the closer it is: 4.17 degrees x s^2, s the share of the way from 0.86 x CAMERA_SMALLEST_MAX_DISTANCE in to 1.3 x CAMERA_MIN_DISTANCE (2.3 degrees at the start distance), measured with CyCamera().GetCurrentPosition at 13 zooms and a fit of the camera to the plot grid in its picture (turned towards the target, not moved aside). Ctrl+Left/Right (CONTROL_ISOMETRIC_CAMERA_LEFT/RIGHT -> MoveBaseTurnLeft/Right) turn the view 45 degrees each way, no further than CAMERA_MIN/MAX_YAW, on top of the zoom's turn; Alt+F (CONTROL_TOP_DOWN_CAMERA -> SetSatelliteMode) looks straight down, north up, with the original's message. The camera glides there as the original's (the rest left shrinks by e^-5.2 a second). CyCamera's Get/SetBaseTurn, MoveBaseTurnLeft/Right and Get/SetBasePitch (tilts the view up) work. Ctrl+arrows no longer pan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eft turns the camera) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The original darkens the far part of the view: Direct3D's linear fog towards the landscape's fog colour (CIV4TerrainSettings: iFogR/G/B 0, black), on the ground, the water and the models alike. OpenCiv4 had none, so the top of a tilted view was as bright as the bottom. Measured on Wine pictures over open sea (the start zoom and a close one, 906 samples): no fog up to 1.2 times the camera's distance from the point it looks at, black at 1.8 times, by the distance from the eye (the top corners darken most). It scales with the zoom: looking straight down nothing is that far, as in the original's far views. Now every map shader multiplies by it (the frame's fogDistance; 0 in other views: leaders). At the start zoom the darkening by screen row and column matches Wine's within 2/255. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The water came out 8/255 too red everywhere (open sea 40,102,143 against Wine's 32,103,143; coast 57 against 49), with green and blue right. Its sparkles are as white in Wine as here, so the plane isn't tinted as a whole; at the plane's 0.5 alpha that is the water's colour 14/255 less red than Water.dds gives (or the floor under it: the same picture). Not the texture's mipmaps (all about 60 red) nor the detail textures (grey). The water's red is now lowered by that much; cause not found. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The original's border tiles (art/terrain/routes/rivers/noriverborder*.dds) wash the owner's colour in at alpha 0.48 beside the line, falling evenly to nothing 0.48 of a plot in, on land and water alike. OpenCiv4's faded out by about 0.3 of a plot. No noise in it: the mottle seen on land is the ground showing through. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # src/render/MslShaders.inc # src/render/SpirvShaders.inc
The water plane (fix/water-look) was drawn over the ground, borders and all, so over water the line and the wash were dimmed to the water's alpha. The original draws its borders as their own layer after the water (CultureBorderShader.fx: blended, no depth writes), at full strength over sea and lakes. Now the borders are their own pass too: the ground's mesh again after the water, at the water's level where the ground is under it (a hair above the ground, so it is never behind it), not lit, darkened by the fog of war and the distance fog. The terrain shader no longer draws them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The original draws the resource bubbles in the plots' order, south to north and west to east, so where bubbles crowd (seen from far away) the farther and the more easterly one covers its neighbour, its pin included. It doesn't push them aside: they overlap at every zoom. bssth#69's first commit drew nearer bubbles over farther ones; now the order is the original's. Checked against Beyond the Sword under Wine at seven zooms (0.25 to 0.85) on a row, a column, a 3x3 block, a 2x2 and pairs of wheat. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The original plays an improvement's KFM state by CvPlot::getVisibleImprovementState, as it does a resource's: On (eventcode 3) on a worked plot, NotWorked (2) on one that is not. A worked mine has its cart out, its chimney's smoke and fire, its sound; a worked farm's farmhouse window is lit. OpenCiv4 drew every improvement in its bind pose. The state goes into the map snapshot (PlotView::improvementState) and to the improvement's model and its plot-layout pieces; a plot's look is redrawn when its worked state changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A model's parts marked "ContourGeometry" (or "...UseZ"), on the part or a node over it, are drawn by the original with ContourShader.fx, which adds the ground's height under each vertex to its height: a mine's ground patch lies on the terrain, a resource's piles follow it. OpenCiv4 drew them at the model's base like the rest. A mine's "Ground Plane" then sat over the ground in front of the mine and covered its wooden deck, leaving only the ends of the deck's legs below it (the user's "ground floating over the posts"). Now a standing model's contour parts are drawn in a second pass, heights over the ground (as roads are), the rest as before. Models laid on the ground already (land resources) are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 21, 2026
Closed
…the bundle's sources Generated with tools/shaders/gen_msl.py and gen_spirv.py: where two PRs' generated files conflicted, one side was taken and both regenerated from the merged sources. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MortenLyhr
force-pushed
the
train/2-terrain-borders
branch
from
November 21, 2026 17:07
a9ee32f to
d3acb7a
Compare
As the original (checked in Wine, BtS 3.19; the rules are the game core's CvPlot::getVisibleBonusState/getVisibleImprovementState and the display form of calculateYield): - A resource shows only with the tech that reveals it, in anyone's land; an improvement on it shows anyway (a mine on flat land, a pasture). - Under the fog the owner, improvement and road are the ones last seen (getRevealedOwner/ImprovementType/RouteType): the host drew the plot's real owner and road. - The yield symbols are the display yields (CvPlot::calculateYield(y, true), read through Python where they can differ from getYield, cached): under the fog the last seen improvement's; on an unowned plot by the player's techs. - In the WorldBuilder (and the debug mode) every resource, improvement, road and border is shown as it is, hidden techs or not. CvImprovementInfo::isImprovementBonusTrade (an improved resource's look) is read once through Python: it is not exported. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MortenLyhr
added a commit
to MortenLyhr/openciv4
that referenced
this pull request
Nov 21, 2026
…h#146) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A resource's bubble stands left of its plot on the left half of the screen and right of it on the right half. A plot at the very middle of the screen (the camera centred on it, as when it glides into or out of a city's screen on that city) is within a thousandth of a pixel of the middle in every frame, on either side by rounding: its bubble jumped from side to side with each frame of the glide (84 times in one test run: Roma with stone, its screen opened and closed). Each plot's bubble now keeps the side it stands on from frame to frame and goes over only when its plot is clearly past the middle: 2% of the screen's width (32 px at 1600). Elsewhere the bubbles stand as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Did you verify that no other change in your various PRs broke the contribution rules? I was thinking about incorporating some of your changes into my personal dev build but without knowing their origins i have concens. |
The two lines and where and how long they show were checked in the original under Wine (2026-11-22): Alt+F pressed on and off, filmed; the line is an event message at the top for about 10 s (EVENT_MESSAGE_TIME). No TXT_KEY in the game's text has it. The code was right; its comment named the wrong source. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ing game Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Merge after bundle 1, #145 (this branch holds it; once it is merged, this PR shows only its own changes).
This PR replaces 10 open PRs, merged here one by one with their own commits (each description stays on its PR, which links here once closed); the conflicts between them are resolved as on the branch we play daily. Merging it closes nothing automatically: each replaced PR will be closed with a link here.
#79 is no longer part of this bundle (2026-11-21): its hill height-map commit was taken out for clean-room reasons (see CONTRIBUTING, "Clean room"), and the branch was rebuilt without it. Bundles 3–6 (#147–#150) were rebuilt on top. Hills are drawn as on master until a clean redo.
Commits of this bundle's own (on top of the merges):
Checks: macOS build (Release), ctest 13/13 passed; sync checksums
--turns 100 --map Fractal --size STANDARD --seed 7at turn 100 equal master's (D7D43800). Windows: this PR's CI.Plots as the player knows them; the World Builder shows everything
The map showed some of a plot as it really is, where the original shows it as the player knows it. The rules are the game core's own (
CvPlot::getVisibleBonusState,getVisibleImprovementState,getRevealedOwner/ImprovementType/RouteType,calculateYield(y, true)), checked in Wine on a foreign field with iron, copper and horses, bare and with mines and a pasture:calculateYield(y, true): the last seen improvement, the owner's knowledgegetYield: the real onescalculateYield(y, true)calculateYieldandCvImprovementInfo::isImprovementBonusTradeare not exported, so they are read through Python: the trade table once, the yields only for plots where they can differ fromgetYield(under the fog, unowned with something on them, an unseen city), cached until what they come from changes.Checked after this commit: each bundle 2–6 builds, ctest passes (13, 14, 19, 21, 22 tests) and the checksum at turn 100 is
D7D43800.🤖 Generated with Claude Code