Skip to content

MapImageModule: render through IMapTileTerrainRenderer, as stock does - #204

Open
azdesign-com wants to merge 1 commit into
OpenSim-NGC:developfrom
playsimgrid:upstream-maptile-renderer
Open

azdesign-com wants to merge 1 commit into
OpenSim-NGC:developfrom
playsimgrid:upstream-maptile-renderer

Conversation

@azdesign-com

Copy link
Copy Markdown

The world map renders grey relief regardless of configuration, and TextureOnMapTile has no effect. Verified in-world on a 16-region varregion grid before submitting — details below.

The defect

CreateMapTile assigns the renderer and then never uses it:

// Create terrain renderer based on scene settings
terrainRenderer = new TexturedMapTileRenderer();

That field is written once and read nowhere in the file. The tile is produced by a hand-rolled greyscale loop over GetFloatsSerialised() instead, and TextureOnMapTile is not read at all — so the setting is inert and the map is grey relief whatever the configuration says.

Neither Initialise() nor TerrainToBitmap() is ever called.

Both renderers are present in the tree, already ported to SKBitmap, with IMapTileTerrainRenderer intact and correct signatures. They were orphaned by the SkiaSharp rewrite — not removed, not left unfinished. Nothing calls them.

The fix

Restores the stock path: read TextureOnMapTile from [Map]/[Startup], select textured or shaded, Initialise, TerrainToBitmap. 21 insertions, 48 deletions — it removes more than it adds, because the replacement is the code that already exists.

Verified in-world, not only reasoned about

Deployed to two regions, then to all sixteen, on a 1024m varregion grid:

before after
sub-tiles uploaded per region 1 16
tile size 1144 B 5.7–7.6 KB
distinct colours in a tile 1 6098
greyscale pixels 100% (structural) 0.5%

The old loop emitted SKColor(shaded, shaded, shaded) for every pixel, so 100% greyscale was by construction; 0.5% is incidental JPEG overlap on colour data. Dominant colours after the fix are water, sand and green.

The full landmass now resolves as coloured terrain at every zoom level, where previously it was grey and black squares.

Note on the sub-tile count

The jump from 1 to 16 uploads is a second-order effect of the region-size fix in #201, surfaced by this change. MapImageServiceModule uploads a single tile when the map is exactly Constants.RegionSize and splits into sub-tiles otherwise. Before #201, every varregion returned 256x256 and took the single-tile path, leaving the region's other cells without imagery. That branch had never executed on our grid.

Relationship to #202

This supersedes my own PR #202 and I am closing that one. #202 added a NaN guard to the contrast stretch in this method, for the case where a perfectly flat region gives heightRange == 0 and (byte)(0f/0f) yields a pure black tile. That guard was correct for the hand-rolled loop — but this change removes the loop entirely, so the division it guarded no longer exists here.

The flat-region case is still handled: ShadedMapTileRenderer works from absolute height with its own NaN handling, and TexturedMapTileRenderer samples terrain textures. Neither divides by a height range. Confirmed on a flat region, which rendered pure black before and renders uniform terrain colour after.

Builds clean: OpenSim.Region.CoreModules, SDK 10.0.400, 0 errors, restored from public nuget only.

The world map renders grey relief regardless of configuration. TextureOnMapTile
has no effect because this module never reads it.

CreateMapTile assigns `terrainRenderer = new TexturedMapTileRenderer()` and then
never uses the field - written once, read nowhere in the file - and produces the
tile from a hand-rolled greyscale loop over GetFloatsSerialised() instead.
Neither Initialise() nor TerrainToBitmap() is ever called on it.

Both TexturedMapTileRenderer and ShadedMapTileRenderer are present in the tree,
already ported to SKBitmap, with IMapTileTerrainRenderer intact. They were
orphaned by the SkiaSharp rewrite, not removed or left unfinished. Nothing calls
them.

Restores the stock selection: read TextureOnMapTile from [Map]/[Startup], pick
the textured or shaded renderer accordingly, Initialise, TerrainToBitmap.

Verified in-world on a 16-region 1024m varregion grid before submitting:

  all 16 sub-tiles regenerated per region   previously 1 per region
  tile sizes 5.7-7.6 KB                     previously 1144 B
  distinct colours in a tile: 6098          previously 1
  greyscale pixels: 0.5%                    previously 100% by construction
  dominant colours: water, sand, green

The whole landmass now renders as coloured terrain at every zoom level. The
greyscale loop emitted SKColor(shaded, shaded, shaded) for every pixel, so 100%
greyscale was structural; 0.5% is incidental JPEG overlap on colour data.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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