I have a world which is extremely laggy at a really far zoom level (~40k nodes visible at least). The map itself is not particularly dynamic so I realised at this type of level to resolve the lag I could actually just take a texture of the entire region and simply display a single sprite.
I am trying with SubViewport by setting its size and position, but the texture I am getting out of it is simply a glitchy rectangle with varying pixels in rgb pattern. It does not appear to actually be grabbing the texture of the region.
This is the texture it produces
func setupBaseView():
# create a viewport
var vp = SubViewport.new()
add_child(vp)
# Set the size of the viewport to the size of the map
vp.size = Vector2i(Tile.HTW * worldRes.worldSize * 2, Tile.HTW * worldRes.worldSize * 2)
# Get the texture out of the viewport and apply it to the world sprite
RenderingServer.force_draw()
var img = ImageTexture.create_from_image(vp.get_texture().get_image())
$WorldSprite.texture = img
I wouldn’t use viewports for this. MultiMeshInstance2D or a custom shader with the textures and map matrix could do the trick.
It’s unclear how you’re currently doing it. Individual Sprite2D nodes? Tilemap? What does the map even consist of? Just the terrain textures or other stuff too?
If you’re not using Forward+ renderer Godot should batch similar textures into a single draw call. This isn’t done on Forward+ but Vulkan can handle a lot more draw calls so it’s not as big of a problem.
Every tile in the map is an Area2d. The tiles are shaped approximately isometrically. The area2d draws itself and it’s boundaries with a textured polygon. Due to the angling of the view, it’s not as simple as just drawing the whole thing in a sprite. I’m not sure how to us a multimesh for this
So they can detect mouse entering and exiting. I tried having a single area2d and my collision shapes, even added to the physics server directly, and with minimal performance improvements. I am pretty sure it is due to draw calls, and yes the profiler only tells me the bottleneck is in process time
How many draw calls, how many primitives? If you render the map as one sprite Godot won’t be able to cull off-screen objects
I don’t think Area2Ds are a very scalable way of detecting mouse clicks. If your map is a grid you can just calculate which cell the mouse click is in and then act based on that.
Or if the map isn’t a grid you can store the objects in spatial hashes or something similar and then check all objects in just that partition for what’s clicked