I am having an odd problem with sorting Sprite3D

Godot Version

4.4.stable

Context

So, I have just created a simple 3D test world using Terrain3D and I am doing some tests with 2D sprites in a 3D world. Everything was going alright so far, but then I started to experience some odd problem related to ordering:

My Character3D have Sprite3D node child. When they get close to each other, the rendering order is ok (i.e. render order between Character3Ds with Sprite3D as child).

Then I created some items, those are just Sprite3D, and for some reason the ordering is not ok between Sprite3D and the previously mentioned Character3Ds.
Depending on where my character is relattive to the Sprite3D, one will be drawn on top of the other in unexpected ways.
I have done all kind of tests with offsets and positions and they are all correct, I am sure.

Now, here is the odd most part… I have being using the Sprite3D transparent flag for both my characters and my items, because otherwise they will have a weird black background behind them - no idea why, the original sprites have alpha background. Looking in Godot engine they have all been imported as “DXT5 RGBA8”… I have no clue if that is the reason for the black background, couldn’t find any info on that. An additional note: all my images are PNGs generated from Inkscape.

If I unflag the “Transparent” for my Sprite3Ds, then the sorting works as expected but I am left with that black square background behind my sprites.

Question

What should I do here? I would ideally want one of the following solutions:

Is there a way to import the textures in a way that it will preserve the original transparent background without I am having to use the Transparent flag? Or is there a way to use the Transparent flag on Sprite3D without messing up with the render order?

Thanks in advance. :slight_smile:

The Transparent flag is needed if you want your sprites to have transparency. If you don’t enable it then the alpha channel won’t be read and will be treated as fully opaque which is why you see the black background.

The issue happens because Godot renders transparent objects as a separate pass. First it renders opaque objects, then transparent objects. You can check the transparency sorting section in the documentation for possible fixes.

1 Like

Oh, wow. Thank you, it worked!
I have used the Material Overlay property of the Sprite3D node under the GeometryInstance3D section and tweaked the values you mentioned and now its finally sorting correctly again.

Again, thank you sir! :grin: