Page 1 of 1

Depth-sorting fails for semi-transparent textures

PostPosted: Wed Jun 11, 2014 02:42
by Wuzzy
Okay, so I played around with semi-transparency in one of my mods. (viewtopic.php?f=9&t=9486)

And it seems to me that Minetest does not draw semi-transparent textures well.

Screenshot from 0.4.7:
Image
All blue cubes are textured semi-transparent PNGs with 80% opacity for every pixel. All blue cubes in the background have been placed first. When I view the cubes in the foreground from behind the blue cubes in the background, there is NO depth-sorting issue.

Screenshot from f70e0556fcf28b21b5a6717524caa29ccd49a516 (=pretty recent):
Image
Black was placed first, then came magenta, followed by cyan. But black is in the back, not in the front! Again, when viewed from the other side, everything is fine, still fine.


The nodedef I used for the semi-transparent cubes:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
{
      description = h.." abstract window block",
      tiles = { "colorcubes_window_"..c..".png" },
      groups = { dig_immediate = 2 },
      use_texture_alpha = true,
      drawtype = "glasslike",
      paramtype = "light",
   }

The variables h and c just include the color names.

So to reproduce, I guess you just try to create a mod with a node like this, with some semi-transparent PNG as texture and place two such nodes after each other. Then you view them from both sides.
You have reproduced the bug I report if depth-sorting messes up on one side, but not on the other.

Minetest version used: See screenshots.
Operating system: GNU/Linux, Linux 3.9.4
Used subgame: minetest_game
Used mods: colorcubes, This snapshot (download links available)

PS: I also discovered this bug long time ago with the bobblocks mod, but I thought this was a mod issue and eventually forgot it. Now I think this is a Mintest issue.

PPS: The debug.txt from a test run is over here: http://lpaste.net/raw/105425

Re: Depth-sorting fails for semi-transparent textures

PostPosted: Wed Jun 11, 2014 03:02
by HeroOfTheWinds
This is a known issue, and as far as I know, it has been around for a while.

From the dev wiki:
Use Texture Alpha Channel
Must be used with a drawtype that does not perform backface culling.
There are currently two known, difficult-to-solve issues with this feature.
With shaders enabled, the faces of other transparent nodes are sometimes not drawn, depending on viewing angle. This is most noticable when a liquid is behind a node that uses the texture's alpha channel.
With shaders disabled, transparent objects farther away from the camera that should be occluded will be drawn over the node with this attribute. This is caused by the lack of transparency sorting, and is also the cause of water being drawn in front of clouds.

PostPosted: Thu May 05, 2016 06:48
by Hybrid Dog
On your screenshot it looks like depth-sorting works but in the wrong direction (the furthest thing seems to be the nearest one and the other way round)