Transparent box nodes

Hi!

I noticed that, occasionally, you need to group up GUI elements under a common transform and don’t necessarily have a “background box node” to parent everything to it. In these cases, it would be useful if Defold had some sort of “empty” non-renderable GUI node type (like a component-less game object) or some way to disable rendering for a certain node. In these cases, I just used a transparent box node, but it feels like that’s just a waste of draw calls.

I remember the lack of a grouping-only GUI node was pretty confusing at the beginning when I started working in Defold.

Another use case I had for transparent box nodes was for a case when I had these buttons where the button graphic didn’t coincide with their hitbox, so I had to make a transparent box node just to call gui.pick_node() on it (doing the picking math manually would have been really complicated in that scene). Again, a waste of a draw call and fill rate.

I’ve noticed that gui.pick_node() still works when the node is disabled, so that could solve the problem for the second use case, but for the first use case, it would be cool if we could disable just the rendering of a node (without affecting its children) or have an empty node-type.

Is this an isolated need of mine? Am I not approaching things right? Should this be a feature request?

7 Likes

You can use box nodes for groupping. Just set alpha of box node to 0 and clear “Inherit alpha” checkbox on child nodes.

2 Likes

Which is what I’m using, but even though they’re transparent, they still get rendered (I assume) and use up draw calls and fill budget.

I might be wrong but I believe I recall that gui nodes with alpha 0 is not being considered in the render process. Could someone just confirm this?

1 Like

A box node without texture does contribute to draw calls. EVEN if the alpha is 0 or the size of it is 0, 0, 0. They will also break batches.

What I do is I have an image that is 1px, I then add that image to basically all atlases. So when I use images from an atlas in my GUI scenes I make sure to set all “empty/group” nodes to this texture from an atlas that the gui scene is already using, I also set the size to 0, 0, 0. This makes it batch with everything else and hopefully makes close to 0 impact on rendering.

I have thought quite a bit of how to optimize art content for Defold, especially GUI stuff. I am by no means an expert but I can write a forum post about it later if there is any interest.

13 Likes

I usually do exactly like Mattias suggests and use a box node with 0-size and a 1px image from the same atlas as the rest of my GUI uses. It works well enough I think

4 Likes

I wrote together something while traveling today. Take a look!

3 Likes

It would be nice to use gui templates as groups(as nodes maybe). Using a 1 px sprite is not a quite nice solution for an engine like Defold. :disappointed_relieved:

2 Likes

What do you mean by gui templates as groups?

Templates “like” empty groups. But since they are not nodes(If I have understood correctly), we can’t use get_node directly on template itself and we can’t change their visibility or position etc. It would be nice to have something empty like templates on GUI(but as node), then we can get rid of those 1px images :slight_smile:

@selimanac That would be solved by a grouping-only node type that doesn’t render anything on its own. You can then parent the template to that and do whatever you wish with it. You can already do that now by using 0x0 boxes, in lack of a proper grouping node type.

But yeah, +1 for grouping GUI nodes. The current way of making group nodes (0x0 boxes) is quite convoluted, not immediately obvious to new users and has a draw call overhead.

2 Likes

I always group using 0 size box nodes with a texture and layer set so that I don’t break batching.

2 Likes

I would also like such a feature. What about just allowing the making of folders inside ‘Nodes’?

4 Likes