Open eliot-akira opened 3 weeks ago
Oh damn! I had to put a weird fudge factor in because it was doing something like that, and now it seems to be back! Maybe I need to adjust the amount of fudge. I never got to the bottom of why it required any fudge, perhaps that would be a better no-fudge solution.
Did it suddenly recently start doing that, do you think? Or could it have been doing it all along?
Which browser and platform is that on?
Thanks for the heads-up!
-Don
void main() {
// Calculate the screen tile coordinate.
vec2 screenTileColRow = floor(v_screenTile);
vec2 screenTilePosition = fract(v_screenTile);
int cellValue = 0;
vec2 cellUV;
// Check if the screen tile coordinate is out of the map bounds.
// u_mapSize is the map size in tiles in column-major order so x is rows and y is columns
if (screenTileColRow.x < 0.0 || screenTileColRow.y < 0.0 ||
screenTileColRow.x >= u_mapSize.y || screenTileColRow.y >= u_mapSize.x) {
//fragColor = color_brown;
//return;
} else {
// Calculate cell column and row
vec2 cellColRow = screenTileColRow;
vec2 cellRowCol = vec2(cellColRow.y, cellColRow.x);
cellUV = cellRowCol / u_mapSize;
// XXX: Mystery fudge factor to prevent sampling from adjacent cells every 6 rows!
cellUV.x = cellUV.x * 1.00001;
cellValue =
int(texture(u_map, cellUV).r);
}
On Jun 22, 2024, at 15:43, 3λiȯ+ @.***> wrote:
Just making a note of something I noticed. Here's an example from the city when pressing z, on the top left.
micropolis.city.z.top.left.-.duplicate.row.png (view on web) https://github.com/SimHacker/MicropolisCore/assets/5352434/d45e95a9-d321-4f23-ab2f-49249d087129 There are duplicated tiles on the top and left edges.
And the city when pressing a, on the top right.
micropolis.city.a.top.right.-.missing.row.png (view on web) https://github.com/SimHacker/MicropolisCore/assets/5352434/fb71326e-9b46-4b00-a8a9-d25d25da1489 Missing tiles on the right edge.
It looks like an off-by-one bug in the tile renderer.
— Reply to this email directly, view it on GitHub https://github.com/SimHacker/MicropolisCore/issues/5, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIDL3FZPSTCFFL6MBT5ZN3ZIV5QZAVCNFSM6AAAAABJXOQDV2VHI2DSMVQWIX3LMV43ASLTON2WKOZSGM3DOOBTGA3TEMQ. You are receiving this because you are subscribed to this thread.
I confirmed the issue on Firefox and Chromium on Linux, so it's probably not specific to the browser. I'm not sure when it started happening.
I plan to study the tile rendering logic deeper, both canvas API and WebGL, so maybe during the learning process I'll discover why it's happening.
So far, for me it's like the Micropolis codebase itself has become the game. I'm having fun digging around, taking it apart, learning how it all works. It's also teaching me C++, how to allocate and free memory for data structures being used, etc.
Just making a note of something I noticed. Here's an example from the city when pressing
z
, on the top left.There are duplicated tiles on the top and left edges.
And the city when pressing
a
, on the top right.Missing tiles on the right edge.
It looks like an off-by-one bug in the tile renderer.