MZ [solved]Mobile device tilemap seams

There are seams sometimes, it happens to MV and MZ games all the same.
1738817210714.png

I wonder if this is a fix for this?
I tried changing PIXI's resolution to the device's pixel ratio but it doesn't fix anything.

Edit*
1. This only happens in WebGL mode. MV's canvas renderer works flawlessly.
2. The seams (at least on my phone) only appears on auto-tiles, normal tiles like A5 doesn't have this problem.
This is usually caused if the screen size is not a multiple of the tilesize.

On a PC the solution would be simple - just go to a screen size that is slightly smaller but a true multiple of 48

Unfortunately if I remember correctly the screen size for mobile deployment is somewhat automated to fit the device. In such a case you would have to go through the code looking for that part, and change it mathematically there.
and I have no idea where to even start with that
This is a webgl specific problem.
MV's canvas renderer works pretty much flawlessly.
I know basically nothing about troubleshooting mobile devices, but here are some thoughts~
  1. Is your device's graphics driver up-to-date? What are your device's technical specs?

  2. Is this an issue with games deployed as native mobile apps, or are you testing with web-deployed games through a standard browser? Do you see this problem on multiple different devices/sites/etc?

  3. A long shot: maybe the device's GPU defaults to lowp shader precision? Autotiles are split into smaller pieces than other tiles, so maybe that's incurring an off-by-one error somewhere. You might try adding this line to the start of the vertex & fragment shaders generated by the createShader method of Tilemap.Renderer in rmmz_core.js:
    Code:
    precision mediump float;
    As far as I know, all WebGL-capable devices should support mediump precision. You could try highp as well in case that makes any difference. (I think PIXI defaults to highp for vertex shaders, as well as for fragment shaders on mobile Apple devices.)
Thank you for the reply.
Yeah I think it is a device specific problem. I tested on another phone and it seemed OK.
:hswt:

Edit*
I found a "plugin setting" solution for MV.
It seems, changing useSquareShader to true fixes my problem.
I wonder why it doesn't use square shader in the first place for it is much simpler (maybe some devices only allows triangles?)

JavaScript:
ShaderTilemap.prototype._createLayers = function() {
    var width = this._width;
    var height = this._height;
    var margin = this._margin;
    var tileCols = Math.ceil(width / this._tileWidth) + 1;
    var tileRows = Math.ceil(height / this._tileHeight) + 1;
    var layerWidth = this._layerWidth = tileCols * this._tileWidth;
    var layerHeight = this._layerHeight = tileRows * this._tileHeight;
    this._needsRepaint = true;
    if (!this.lowerZLayer) {
        //@hackerham: create layers only in initialization. Doesn't depend on width/height
        this.addChild(this.lowerZLayer = new PIXI.tilemap.ZLayer(this, 0));
        this.addChild(this.upperZLayer = new PIXI.tilemap.ZLayer(this, 4));
        var parameters = PluginManager.parameters('ShaderTilemap');
        var useSquareShader = Number(parameters.hasOwnProperty('squareShader') ? parameters['squareShader'] : 0);
        this.lowerZLayer.addChild(this.lowerLayer = new PIXI.tilemap.CompositeRectTileLayer(0, [], useSquareShader));
        this.lowerLayer.shadowColor = new Float32Array([0.0, 0.0, 0.0, 0.5]);
        this.upperZLayer.addChild(this.upperLayer = new PIXI.tilemap.CompositeRectTileLayer(4, [], useSquareShader));
    }
};

Edit*2

A long shot: maybe the device's GPU defaults to lowp shader precision? Autotiles are split into smaller pieces than other tiles, so maybe that's incurring an off-by-one error somewhere. You might try adding this line to the start of the vertex & fragment shaders generated by the createShader method of Tilemap.Renderer in rmmz_core.js:
Code:
precision mediump float;
As far as I know, all WebGL-capable devices should support mediump precision. You could try highp as well in case that makes any difference. (I think PIXI defaults to highp for vertex shaders, as well as for fragment shaders on mobile Apple devices.)
Oh I tried on MV (in pixi-tilemap.js), highp fixed the problem, mediump didn't.
I can't believe it. 👋

Edit* 3
Maybe change it from PIXI.settings is better.
static PRECISION_FRAGMENT: PIXI.PRECISION = PIXI.PRECISION.MEDIUM

Default specify float precision in fragment shader. iOS is best set at highp due to https://github.com/pixijs/pixi.js/issues/3742

PIXI.settings.PRECISION_FRAGMENT = PIXI.PRECISION.HIGH;
At the shader level, WebGL only supports drawing points, lines, and triangles in various configurations.
You can make any polygon (e.g. square) with triangles, but imagine trying to approximate a curve with only right angles. Triangles are much more versatile!

Yeah I think it is a device specific problem. I tested on another phone and it seemed OK.
Depending on how new/popular the device is, that might be a good or a bad thing. 😅

Oh I tried on MV (in pixi-tilemap.js), highp fixed the problem, mediump didn't.
I can't believe it. 👋
It actually worked? Nice. 😤
Ah, thank you. I think I'm not ready to learn the whole shader language. :hswt2:
Anyway, mz dropped the 'square shader' thing.

I think this topic can be closed now. Unless there are more issues in the future.
This thread is closed due to being indicated as solved. Make sure to report the next one so we can see it! If you need this one reopened, report it to let us know. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/solved-mobile-device-tilemap-seams.175192/