Limit of gui nodes

Why gui nodes is limited by 1024?
I need more nodes :confused:

That is honestly an absurd number to have at one time. Are you deleting the nodes and recreating them as needed?

I am trying to make game like in led screen. The gui nodes is the best way to emulate one led

Could you use a tile map instead?

1 Like

I am not using tilemap before. Can I change tile color in runtime? Looks like I can’t. GUI is the best, because tinting, not break a batch.

I haven’t used tilemaps either and as you say it looks like you can’t change the color, at least not on individual parts. But you could maybe solve it with a tilemap anyway, if you are only having a set amount of colors you could have them on the tilemap and change the ones you want to “light up” with tilemap.set_tile to one of the colored tiles.

Another approach is to simply divide your gui scene into more than one gui scene.

5 Likes

No tilemap, not my choice. Yes dividing will help me. But I am interested why 1024 is limit? All other limits, go, sprites and etc. Can be changed, but this not.

Here’s an issue for this https://github.com/defold/editor2-issues/issues/1423

2 Likes

In a tilemap, you can switch tile with tilemap.set_tile(). So if you have a bunch of differently colored tiles, that might work.

2 Likes

The limit of 1024 gui nodes is there for performance optimisation reasons. Internally, a mixed key with the node index and other attributes are combined for efficient sorting of nodes.
This has nothing to do with the editor, the value can’t just simply be exposed as a variable.

The gui can of course be used to build games, but bear in mind it’s not intended to.
In your case, you should be using sprites or a tilemaps or sprites. As long as your atlas is containing all the variations you need (and it should be able to with good margin), you won’t break batching.

tilemap.set_tile() or changing the texture animation frame (using an atlas) is two good approaches in your case.

2 Likes

thank you for your explain. I think about sprites , but gui looks better for my idea. Because i don’t know how much colors i need. So changing color is what i need.

1 Like

You can tint sprites too, but it will break batching. This could be fixed by setting the Z of your coloured sprites. E.g. Setting sprite.z = (color.r+color.g+color.b)*0.1 or something like it.

3 Likes

So if I set same z value for same colors, it will not break batching? Sprites my favorite now :grinning:

Another approach is to have a single sprite, and overwrite its texture, as show in the example code for resource.set_texture()

Note that changing all pixels one by one in a large texture (e.g. full screen texture) from Lua is demanding, so you have to determine if it’s feasible for your project. AN alternative is to fill the pixels from a native extension.

3 Likes

Yes, if your tinted sprites have exactly the same tint they will batch together, but if they are only a tiny bit off they will not batch. So a color of (0.5, 0.5, 0.5, 1) and (0.51, 0.5, 0.5, 1) will NOT batch. They have to be identical. Remember that each unique tint will get its own batch, if you have 10 different tints you will get 10 batches. If you have 100 you will get 100 batches.

You can read some more about draw calls and batching in the post draw calls and defold.

4 Likes

I want to remind you again on what I am saying in my previous post: Using tilemaps, changing a tile with tilemap.set_tile() or using sprites changing animation frame from atlas using sprite atlas animation with a single, non-looping frame Sprite reference (animation) will NOT break batching. They only change the UV-coordinates which are sent with the sprite or tilemap vertices.

These two ways of doing what you want it by measures the cheapest way to achieve what you want to do.

2 Likes

I don’t need texture, while I only need to change color. I not sure how much color I will have. Because if I want to make a transition, from one color, to other, it will be a lot of different colors.

In the case of transition, I’d suggest you do textures of the colors you need and use what Mattias suggested with changing the z-value which you can act on in the shader.
Otherwise, using the gui is of course fine, but you’re stuck on 1024 nodes.

2 Likes

This is a very good suggestion. I would probably do it this way if I were to try and recreate a LED matrix like in your screenshot. I’d also back it by a native extension and only pass a Lua table with the LED matrix state and let the extension generate the actual pixels.

2 Likes

Yes, this is the best way. It have some question, how to draw one led. Is I need one size texture for all phones, or use screen size texture. Also it is take a time to write such native extension I am now prototyping, so I will use gui, because it is easy. But for production, changing one texture sounds very good.