-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Fix texture coords off by one error #16055
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
Conversation
This whole stuff is a mess. We're using world (or modulo 16?) coordinates and use them for texture coordinates. This completely breaks For testing: diff --git a/games/devtest/mods/stairs/init.lua b/games/devtest/mods/stairs/init.lua
index 267540e8d..59f64dec7 100644
--- a/games/devtest/mods/stairs/init.lua
+++ b/games/devtest/mods/stairs/init.lua
@@ -61,6 +61,6 @@ stairs.register_stair_and_slab("desert_stone", "basenodes:desert_stone",
stairs.register_stair_and_slab("cobble", "basenodes:cobble",
{cracky=3},
- {"default_cobble.png"},
+ {{name = "default_cobble.png", tileable_vertical = false}},
"Cobblestone Stair",
"Cobblestone Slab") Now this PR breaks for example allfaces nodes with |
I just tested this, for me, If I'm not wrong texture coordinates are mainly used for two things, luanti/src/client/content_mapblock.cpp Lines 183 to 196 in 0cf1c47
and for initial mirroring for each of the 6 faces. For reference, this is where the alligne_style gets applied to the texture coordinates luanti/src/client/meshgen/collector.cpp Lines 28 to 30 in 0cf1c47
|
Hm, tested again, and now it's broken iff
It controls what happens when the texture is sampled out-of bounds, if true, the texture is repeated, if false, it's clipped to edge.
If I understand it correctly, the mirroring is to get the right texture orientation, i.e. on the side you want to have upright textures (y up in 2d should be y up in 3d). |
Fair enough, so our initial mirroring preserves texture coord bounds, but later rotations don't, interesting. Is this another bug? From your response, I infer that we want to preserve the texture coord bounds after mirroring, so I adjusted it accordingly. |
I think someone needs to sit down and re-do the texture coordinate stuff. |
Well, our align style implementation needs texture coords at least in [0,16]. There are so many weird things going on. (This PR is only meant to fix the align style texture coords problem.) |
align_style
in general, and maybe other places where texture coordinates matterWhile investigating #12266 I noticed that
align_style
does not align properly, even in the most basic case. How did nobody complain about this so far. To be fair it took quite some time to find the cause.Anyway, if I'm not wrong, texture coordinates of all node tiles (except the bottom one) have an off by one error which this PR tries to fix.
(I hope I didn't misunderstand anything about the code, since this part worked fine for the past 8 years.)
To do
Ready for Review.
How to test
tiled:tiled
nodes and see that the world alignment is correct.