-
Notifications
You must be signed in to change notification settings - Fork 580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Foliage using allfaces_optional becomes too dark with distance (most leaf texture transparent pixels need improved colouring) #2801
Comments
Isn't this an engine issue? |
I'm not sure tbh, but I believe mipmapping is a fairly low level hardware functionality these days. I wouldn't expect there to be that much control over how it'done. We should ask somebody well versed in modern OpenGL. One possible engine issue is that I couldn't get MT to correctly apply the color of transparent pixels of png texture in indexed mode (it seems to always pick a specific pallete entry number regardless the actual color of transparent pixels). But RGB is fine and most MTG leaf textures are RGB anyways. But there's also the 'opaque leaves' mode, and leaves engraved in pitch black blocks don't look good either, so fixing textures is probably the easiest and correct solution. |
This is an engine issue, maybe an engine issue should be opened for this specific problem?
So i disagree with making the transparent pixels similar to 'surface leaf' colour as in your fix.
Yes this is known. 'allfaces optional' textures are documented as needing to be RGBA for this reason. All MTG 'allfaces optional' leaves have RGBA textures. |
It is the easiest, but it is not the 'correct' solution. Fixing this in the engine would be the ideal solution so that transparent pixel colours and opaque leaf appearance do not have to be compromised. First we should find out if an engine solution is possible. If not, as seems likely, then changing the MTG textures can be considered (and i think can count as 'essential maintenence').
|
|
Did you?
Wait, I haven't mentioned any specific colors, so there's nothing for you to disagree with yet. While we're at it, the color should be close to the average of all opaque pixels, otherwise with mipmapping on, the transition is abrupt, especially jarring when player is in motion. And between 'fancy' and opaque leaves, you have to favor the former, because opaque mode is for performance, not looks, and it looks kinda bad whatever you do.
Yeah, that's unlikely to happen, meanwhile the textures in question were last edited 4 years ago. It's not only allfaces, for example go to the savanna biome and watch how half the dry grass fades to black, while the other half to white (they're indexed) |
Sorry, i was fairly sure the transparent pixels for tree leaves had been well coloured. But i checked and apple, aspen and jungle leaves all have black pixels, which is unacceptable. Acacia has dark green pixels, all of one colour, which is odd because i seem to remember adding layers of darkened leaves behind the surface leaves (perhaps i started this task then gave up or decided against it). Pine needles are fine and have necessarily dark pixels (because the surface needles are already quite dark) of varying colours. This texture does not need changing. Apple, aspen and jungle leaves have black pixels and so need improvement. They have large gaps so the pixels need colour variation. Blueberry bush leaves have dark grey pixels, which should at least be dark green instead. ////////////////////////////////////////////// To be clear, the suggested changes above are only to improve the opaque mode appearance. I disapprove of compromising the opaque mode appearance to alter the way leaves become darker with distance. As this issue reports, with fancy mode leaves and mip-mapping on, distant leaves have an appearance determined by all their pixel colours, so have the colouring of opaque mode leaves. The opaque mode colouring is valid. The appearance of leaves changes from fancy mode colouring to opaque mode colouring at a distance. Both colourings are equally valid, there is no invalid colouring. So this change of colouring with distance is not really a problem. Ideally of course, in fancy mode the engine would give distant leaves fancy mode colouring. But if this is not possible as we suspect, i think it is not justified to compromise the opaque mode appearance. Luckily, improving the textures as described above will result in less dark transparent pixels, which will have the side effect of slightly reducing the darkening with distance. |
What happens if you run |
Ran a win32 version of pngcrush on my copy of default_leaves.png - 62% size reduction, background color still intact.
Yes, mip levels can be supplied directly, but that feels so 20th century, and offloading GPU work to CPU might not be a good idea for MT. |
Forgot to add, pngcrush did not convert it to indexed, it's still RGB |
TheTermos: I know your pain, trust me. And don't worry capable people (probably me at some point) will tackle the mipmap issue eventually. As for compression, I have a compression commit pending that fully respects RGBA textures: #2808 that is likely to be accepted. This uses optipng, which does the same as pngcrush and about 20 other png compression utilities. The resulting differences in size between going to RBGA indexed (which pngcrush does by default, and indexed still means RGBA, it's just a lookup table value, long story) and RGBA no-index results in only about ~11.2 KB in savings after my commit is applied. While I'd love to squeeze another 11.2KB out, the safe compression commit squeezes out 93KB of the original ~242KB, which is most of the possible savings. Long story short, there are much better ways to create savings for media sizes in minetest, including but not limited to: helping us get opus support. Helping get .webp support (which saves another 30 KB or so). Helping to make .obj's compressed with gzip by default. Helping us to have zstandard as our compression library, adding fluidsynth or other midi-style music support, etc. You get the idea, there's bigger fish to fry. |
ExeVirus, the topic of compression sure is fascinating, but it's not particularly relevant to this issue. Anyway, this looks like another 30min easy fix that turns into a lifelong endeavor. |
To add to what TheTermos pointed out already, this patch suggests that OptiPNG keeps them intact. A post in that thread suggests that While the root cause for this indeed is an engine issue, I believe we may temporarily fix this in the way @TheTermos has described until it's fixed on the engine side of things. This issue stems from GL not weighing (or MT/Irrlicht not instructing it to?) pixels by alpha when filtering for mipmapping, and there might even be some graphic cards not even supporting such weighted filtering, possibly making it necessary to change the textures.
Agreed. Should this be automatized (e.g. floodfill + avg from opaque colors)? |
The engine already does this luanti-org/luanti#11145 |
This is the effect of transparent pixels' color being neglected and left at default black, which gets mixed in whenever a texture gets downscaled.
The fix is as easy as changing the color of transparent pixels to one that fits the context.
This affects tree leaves the most, I could edit the textures as I'm working on another project involving textures,
just please let me know somebody if it's going to get any attention given the whole situation with MTG.
left is now, right is fixed:
![fade2black](https://user-images.githubusercontent.com/55103816/103415746-d6b64300-4b83-11eb-9f78-2a2d996e1276.jpg)
The text was updated successfully, but these errors were encountered: