Hello! i am new to godot and i believe my issue to be fairly simple… or not… whatever.
The issue: i have a very very big 2d tilemap(layer) and i need it to be viewed both from afar and from close, but when i zoom out my GPU cries in agony because there are too many pixels fighting for a spot in the screen.
For gameplay reasons i really need the tilemap to be big and for it to be viewed from afar.
Need help: i need help in a way to resize the sprites used in the tilemap when the camera changes its scale, so that i no longer have issues with overwelming rendering calculations.
i read about sdf but i dont really know what it is.
do i need to change the texture of the tileset?
i read too about LOD but that seems to be 3d exclusive, idk
help please, i just need to reduce resolution of sprites at real-time
Hi,
I think you will want to use mipmaps for that (basically LOD but for textures). To enable them you have to select your tilemap texture in the file system. Then click on “Import” on the top left and enable generate mipmaps. Then click on reimport. This will generate lower resolution versions of your texture.
After that you just need to change the texture filter property of the tilemap layer to “Nearest Mipmap” or “Linear Mipmap” depending on your visual preference.
Your game should now automatically use the generated lower resolution versions of your texture depending on the camera distance.
hello!
thanks for your reply.
it DID help, but the fps is still low. i believe my aproach with tilemaplayers wasnt the best one.
if i change the tilemap to a set of poligon2ds with textures to repeat would it increase or decrease performance over a large tile array?
do you have any tips to reduce GPU usage with large tilemaps?
I sadly don’t have much experience with tilemaps so I can’t say if using Polygon2ds would help. You will have to try it. Do you need to have the entire Tilemap in view at once? If not you could try to devide it in chunks.
update on the situation: i have not yet finished the new map with the poligons, but i can see a big improvement in the GPU usage. drastically reduced the number of primitives drawn from ~9000 to ~200. i am also using the mipmap tip, thank you!
edit:
i forgot to mention that it is being a lot more time consuming to set up the environment when compared to the tilemap.
Also it is visually a lot better, since i am not doing pixel art
edit2:
yeah, its a LOT better. higly recommend changing tilemaps to polygons if you need to see shit from afar
this helped a bit in making the terrain chunks by copying the polygon2d:
@tool
extends StaticBody2D
#recieve the shape of the terrain
@export var shape: PackedVector2Array
@export var texture:Texture
#WARNING it is expected:
#-CollisionPolygon2D
#-Polygon2D
#-LightOccluder2D
func _ready() -> void:
#gets my kids
var collision_kid:CollisionPolygon2D=$CollisionPolygon2D
var image_kid:Polygon2D=$Polygon2D
var shadow_kid:LightOccluder2D=$LightOccluder2D
collision_kid.polygon=shape
image_kid.polygon=shape
shadow_kid.occluder= OccluderPolygon2D.new()
shadow_kid.occluder.polygon=shape
shadow_kid.modulate=Color(1,1,1,0)
image_kid.texture=texture
image_kid.texture_repeat=2