GameMaker-Bugs icon indicating copy to clipboard operation
GameMaker-Bugs copied to clipboard

Ability to create tilesets programatically

Open peardox opened this issue 1 month ago • 4 comments

Is your feature request related to a problem?

While it is a simple enough task to write a struct and its functions that do the same as a tileset the performance is far worse than using a tileset asset. Experimentation shows that using the VM is about 25% the speed while YYC is about 66% the performance.

Describe the solution you would like to see

create_tileset and associated functions that create a new GM TileSet Asset

Describe alternatives you have considered

Wrote a constructor with draw method to test performance which results in sub-par speed

Additional context

No response

peardox avatar Nov 22 '25 00:11 peardox

I've written a very basic test project - https://github.com/PeardoxGMSDev/TileTest Using [Space] switches how tiles are drawn and [Esc] quits Note the FPSReal figure - when drawing dynamic tileset the numbers are abysmal

This repo shows far worse performance than initial tests as I've forced everything full screen to maximize the effects of the problem with VM being 8% and YYC being 30%

Things would be even worse with smaller tiles than the 64x64 versions used in the test

peardox avatar Nov 22 '25 12:11 peardox

not sure if this counts as a duplicate of requests like #2947 or #4174, and probably a few more. but i did want to mention that its possible to create a custom tilemap system similar to gm's that runs at almost the exact same speed as gamemaker's and its not super complicated. but for folks that want something before this kind of feature can come to gmrt (since current runtime is feature frozen) u basically just need an array of integers that are bitfields of tile data, and a vertex buffer for the actual tilemap, and youre in business.

attic-stuff avatar Nov 22 '25 16:11 attic-stuff

Looking at the above referenced issues it's odd and disconcerting that there's absolutely no response from GM Staff

@attic-stuff Not sure how your vertex buffer idea works out. Kindly check out my demo repo above, modify to suit + PR it

OK - found some references - gonna give it a go myself (tomorrow)

peardox avatar Nov 22 '25 19:11 peardox

yeah not pr'ing that to show a proof on concept, lol. but the reason there hasnt been much movement from gm staff is because the way tilesets get kissed by the asset compiler is a lot more complex than a simple sprite or animation, there is a lot more involved with padding and placement. wouldn't hold out for anything like this coming to current gamemaker, but it would nice for yyg to flag this and the duplicate features with a gmrt tag.

attic-stuff avatar Nov 22 '25 22:11 attic-stuff

Well, looks like the request is more complex than it looked at first sight

When a tileset is created GM re-writes the sprite into a 7x7 grid with a 2px transparent border and each subtile has it's own 2px (default - can alter) border that repeats the edge pixels. This is notable in my test repo as that uses a normal sprite for the tiles which has an artefact that shows up when not drawn with the remapped set - there are the occassional transparent pixels in my first attempt when drawing with draw_sprite_part... that presumably happen owing to rounding errors on edges.

This does, however, not mean that there's anything wrong with the ask to get access to the TileSet Asset - just that there would be pitfalls the unaware (like me) should be aware of...

peardox avatar Nov 26 '25 01:11 peardox

yep, that is what i meant by:

because the way tilesets get kissed by the asset compiler is a lot more complex than a simple sprite or animation

the tilemap mesh requires padding on the texture so that the precision of the texture sample doesnt show up as those transparent lines you noticed. it can become a built in feature done at runtime, with the right implementation, but probably not in the current runtime.

could we get a gmrt tag on this, yyg?

attic-stuff avatar Nov 26 '25 14:11 attic-stuff

Yeah, I wrote a Delphi App that makes 47 tilesets ready for autotiling. I can see I'm going to have to alter that to handle the padding.

Then again, as you say, it makes ssense to be able to convert a sprite to a tileset sprite inside GM and it's easy enough to do but there's no way to set the texture used by the tileset so it loops back to DIY tileset handling with vertex buffers (which I still need to write....)

The latest versions of GM allow things like room creation etc - why still no tileset creation mystifies me (although I do see the issues now)

It'd also be cool if we could read the automap indices (they only appear in the .YY as far as I can see)

peardox avatar Nov 26 '25 15:11 peardox