Non-Pixel-Perfect Tilemap & Atlas Texture Rendering | Godot Dungeon Crawler Devlog 2

Описание к видео Non-Pixel-Perfect Tilemap & Atlas Texture Rendering | Godot Dungeon Crawler Devlog 2

Additional notes, links, and timestamps below.

As I touched on in the video, this solution is still a work in progress, but is in a pretty good state. It is unfortunately only available in C#, I haven't bothered to learn GDScript and I don't really intend to. This may limit how useful this is to some people and I apologize for that. However, if someone wants to rewrite it in GDScript and submit a pull request, I'd be glad to add it to the repo :)

I recorded so many takes of this because I just kept going into tangents on specifics and examples, even this final cut is incredibly trimmed down despite being 30 minutes. I'm finding it a rather difficult balance to both properly explain the challenges and motivations for why I did things so as to not just talk about code with no context, but also not over-explaining basic concepts that just bog down the video pace for those already familiar with them. If you have any feedback, I'd appreciate sharing it.

Another solution for this problem that I didn't mention in the video: you could calculate how much of a tilemap is visible on screen, taking care to note its transform and whether a tile is only half-visible when on the screen boundary. You could then render the visible tiles to a buffer at a 1:1 resolution, meaning each texel is written to exactly one pixel. After all tiles are written to the buffer, you could then take the texture from that buffer and draw that to your canvas, taking care to appropriately scale and transform it such that it aligns perfectly with the source tilemaps you used to create the texture with. Then simply apply a standard smooth pixel art filtering shader and you're good to go. This solution would actually perfectly render the tilemap with no artifacts and compromises to quality, tile size, number of sources, etc. However, it's both somewhat complicated to correctly map the transformation of your original tilemap to buffer space and then back into canvas space, and of course requires an entire additional drawing pass to create the buffered texture instead of just the one it takes to draw the tiles directly to the canvas.

---------
Links

The repository where the source code and example scenes are located:
https://github.com/operation404/Godot...

For my recommendation of a shader that fixes the common case of filtering on pixel art, I like this shader by CptPotato:
https://github.com/CptPotato/GodotThi...

The tileset I use for the examples in this video is a modified version of 0x72's Dungeon Tileset II:
https://0x72.itch.io/dungeontileset-ii

--------------------
Timestamps
0:00 Intro
0:35 Pixel-perfect rendering for pixel art
1:47 Limitations of pixel-perfect techniques
4:20 Analyzing the core problem: fragment-texel alignment
6:48 Tilemaps/atlas textures add further complications
8:49 How to solve the problem: data map and shader combo
10:07 New tilemap display nodes: mesh and canvas item
14:20 Shader that powers the display nodes
21:42 The challenge of using mipmaps with atlas textures
25:34 Creating and using atlas texture mipmaps
27:55 Wrapping up, shortcomings and future work
30:22 Conclusion

Комментарии

Информация по комментариям в разработке