I'm developing a 2D grand strategy game in the style of Age of History and Paradox games using Godot v4. My current map creation method involves creating a background PNG image of the world map with superimposed textures and colors for each country. On top of this, I layer each country individually as transparent vector svg files within the engine.
The problem is that to maintain clarity and prevent pixelation when zooming in, I need an extremely large map size - over 16000x11000px. Even Godot struggles to handle such a massive image. With a smaller resolution, everything becomes blurry when the camera zooms in. [zoom in game
Is there a way to create a clear and detailed map without relying on such a huge image size? Perhaps my approach is fundamentally flawed, and there's a better solution?
2 Answers 2
The approach I would recommend is, instead of having one big sprite, we slice it and make a grid of smaller sprites.
I don't know exactly how you structured the scene, but the generic steps to follow are:
- Load the original map using
Image.load_from_file()
. - Calculate the number of slices you need.
- Cut slices (not greater than 4096x4096, I suggest 512x512) calling
Image.get_region(my_slice_coordinates)
on the original image. - For each slice image generate a mipmap calling
Image.generate_mipmaps()
. - For each slice image generate a slice texture calling
ImageTexture.create_from_image(my_slice_image)
. - For each slice texture create a sprite node setting the correct coordinates in the scene.
-
\$\begingroup\$ "Yes, it worked, but I have another question. When a player looks at the map from a distance, one general texture is visible, but when approaching certain areas of the map, the texture changes to a more detailed one. Accordingly, for a more detailed map, I will have, for example, 9 textures created by the method you described. The question is how to make Godot load only the texture that the player is looking at. Basically, I need to create LOD (Level of Detail) for texture. \$\endgroup\$Арсен Исаченко– Арсен Исаченко2024年09月19日 13:51:19 +00:00Commented Sep 19, 2024 at 13:51
-
\$\begingroup\$ Mipmaps are the LOD of textures. If you need to access then in a shader, you use functions like
textureLod()
. \$\endgroup\$Marcos Zolnowski– Marcos Zolnowski2024年09月20日 19:16:50 +00:00Commented Sep 20, 2024 at 19:16 -
\$\begingroup\$ If you generated the mipmaps, the texture has LOD, and you are good to go, the engine will handle it for you automatically. Also, if the answer is correct, don't forget to mark it as accepted. \$\endgroup\$Marcos Zolnowski– Marcos Zolnowski2024年09月20日 23:25:59 +00:00Commented Sep 20, 2024 at 23:25
-
1\$\begingroup\$ Thank you) It is working just fine) \$\endgroup\$Арсен Исаченко– Арсен Исаченко2024年09月21日 15:20:16 +00:00Commented Sep 21, 2024 at 15:20
The maximum image size is determined by the video card capabilities and software interface/drivers.
You must replace the textures at certain zoom levels.
The question is how portable does your game need to be?
A 4k texture is the maximum size for almost all modern video cards/platforms.
-
\$\begingroup\$ This is a PC game. So, I need to create one texture for the overall map when the camera is zoomed out, and several textures, for example, 4, for each individual section of the map that the player will see when zoomed in. The remaining question is how to implement this in Godot)) \$\endgroup\$Арсен Исаченко– Арсен Исаченко2024年09月17日 09:30:36 +00:00Commented Sep 17, 2024 at 9:30
-
\$\begingroup\$ This was posted as an answer, but it reads like more of a comment. \$\endgroup\$Pikalek– Pikalek2024年09月17日 15:07:08 +00:00Commented Sep 17, 2024 at 15:07
-
\$\begingroup\$ @АрсенИсаченко Yes, 4k should work for current PC platforms. For implementation you will need to edit your question and provide the texture load and zoom code. \$\endgroup\$agone– agone2024年09月17日 23:05:29 +00:00Commented Sep 17, 2024 at 23:05
-
\$\begingroup\$ @Pikalek OP asked a conceptual question and got a conceptual answer. The question in my answer is mostly rhetorical(4k max but leaves the option for 2k open if needed). My answer describes the underlying reason for the problem, presents a solution(the optimal transition levels would need to be worked out based on the final size) and suggests an optimal maximum size. The only element that is missing is code, but if there is no code in the question, then no code in the answer. If expansion is needed, the OP can ask, as they have done here. I look at all questions as broader than needs of OP. \$\endgroup\$agone– agone2024年09月17日 23:41:52 +00:00Commented Sep 17, 2024 at 23:41