I realized - it was perhaps a little early to celebrate - hence why no video yet. The ported polygon offset algorithm did have some bugs (or at least I thought, but nope - keep reading), it seems as shown:
Maybe better illustrated if the road itself is a random color:
So how do we debug this, and find the data set that represents the segment rendered wrong? Well, we can somehow render ids along the paths which might be a lot of work - OR - we can just use the random colors. Log a map of color -> line JSON to console and then pick the corresponding color from the screen.
Sadly I could not get this to work. I set the ambient lighting to “full white”:
environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 1, 1, 1, 1f));
And got the hex value for a clicked pixel:
int pixel = ScreenUtils.getFrameBufferPixmap(0,0, Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight()).getPixel(screenX, screenY);
Color color = new Color(pixel);
System.out.println(String.format("Clicked pixels %s", color.toString()));
But no luck.
So I wrote some code to generate textures as PNG files that I could then apply to the roads. The images had identifiers on them. However, they just render as black, for some reason.
So I resorted to the tried and true mechanism of rendering just one random segment and restarting the game until I got something funky. Finally I did, and it dawned to me what the actual problem is. See here:
This looks like one crazy road right? Wrong. It’s two roads, in the same feature in the same segment. I’m not sure why the data is provided to me this way, but if you look closely at the top and bottom you’ll see the center of the actual roads. The library I ported is happily joining the ends, but that’s not what we want. So we just have to pass the correct data. Here’s that more of that tile with everything broken, except this time I render lines between the end points the library sees to confirm the theory:
Then, let’s fix the data transformation. Much better!
Here’s the original area shown above:
…and finally some cities…
EDIT1: I took these screenshots with the debug lighting enabled and directional lighting disabled - so buildings may look a little funny.