minetest / minetest

Minetest is an open source voxel game-creation platform with easy modding and game creation

Home Page:https://www.minetest.net/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wield images not colored correctly

TurkeyMcMac opened this issue · comments

Minetest version
5.6.0-dev
OS / Hardware

Not relevant, I don't think.

Summary

Wield images should be colored just like inventory images according to the set palette_index or color. They are not.

Steps to reproduce

Place and pick up a testnodes:color in devtest. The color of the wield image will not match that of the inventory image:
screenshot_20220428_222922

commented

I am pretty sure this works for wield items but it may not for wield nodes.

Apparently the bug is still there even when using wield_image:
screenshot_20220429_135622

I applied this patch to devtest to test the bug:

diff --git a/games/devtest/mods/testnodes/param2.lua b/games/devtest/mods/testnodes/param2.lua
index 5d64376fa..39d6e8b02 100644
--- a/games/devtest/mods/testnodes/param2.lua
+++ b/games/devtest/mods/testnodes/param2.lua
@@ -83,6 +83,8 @@ minetest.register_node("testnodes:color", {
 	tiles = {
 		"testnodes_node.png",
 	},
+	inventory_image = "testnodes_node.png",
+	wield_image = "testnodes_node.png",
 
 	groups = { dig_immediate = 3 },
 })
commented

Confirmed to be broken for both wield items and nodes, this worked in 5.5.

commented

bisected to 54dccc4

@x2048

The bug does not manifest when I disable shaders. The problem is surely with this code:

void WieldMeshSceneNode::setNodeLightColor(video::SColor color)
{
if (!m_meshnode)
return;
if (m_enable_shaders) {
for (u32 i = 0; i < m_meshnode->getMaterialCount(); ++i) {
video::SMaterial &material = m_meshnode->getMaterial(i);
material.EmissiveColor = color;
}
}
else {
setColor(color);
}
}

commented

Well not necessarily, the shader code probably just forgets to apply the color.

commented

Shaders apply the color correctly, but that's the ambient light color. Item color information should have been stored in the vertices, but it never happens with shaders, because I moved that setColor() call into an 'else' (line 519 in @TurkeyMcMac 's reference). I've now added calls to initialize the colors once when the mesh is created.

@x2048 Flat wield images are still not colored for me.

commented

@TurkeyMcMac can you open a new issue with a reproduction scenario?

@x2048 It seems the bug is now tracked by #12304. You can use the colored craftitems from that PR to reproduce the bug.

commented

I, alongside with TurkeyMcMac can still reproduce this issue. Reopening.

#12304 does NOT track this issue, it is a PR that just accidentally uncovered the bug again. :D

commented

@TurkeyMcMac The issue should be fixed in the master now, could you check? Thank you.

Thanks, it works now.