Mesh rendering problem

Post Reply
wheat8
Member
Posts: 51
Joined: Sat Jul 20, 2024 13:06
Location: France

Mesh rendering problem

by wheat8 » Post

Hi, I'm trying to create a mod that add littles menhirs to the world, that would be teleportation stones. But here is my problems:
  • the stone is not centered (pic1)
  • the texture is not applied (pic1)
  • when in hands, the texture rendering is way too big (pic2)
I'm a complete noob at modding (but you can guess it)
Also, is there a way to have the collision box fit the model ?

Code: Select all

minetest.register_node("magical_stone:house", {
    description = "Menhir magic",
    inventory_image = "magical_stone_inv.png",
    drawtype = "mesh",
    mesh = "magical_stone.obj",
    visual_scale = 0.05,
    groups = {cracky = 3},
    walkable = true,
    visual = "mesh",
    collision_box = {
        type = "regular",
        fixed = {
            {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}
        }
    }
})
problem1.png
problem1.png (584.35 KiB) Viewed 3387 times
problem2.png
problem2.png (97.21 KiB) Viewed 3387 times

User avatar
Slightly
Member
Posts: 146
Joined: Sun May 15, 2022 22:29
In-game: Slightly

Re: Mesh rendering problem

by Slightly » Post

I don't see a texture in your definition. The one for your inventory image is there, but not one for the mesh.
You need something like
tiles = {"flowers_tulip_red.png"},

but the fact that you are getting a dummy for the inventory would usually indicate you have a typo or are missing the texture that is mentioned in the notification.

Also, just as you did the inventory image you can do a wield image and you can scale it to fix the oversized issue.
eg.
wield_image = "flowers_tulip_red.png",
wield_scale = {x=1, y=1.5, z=1},

The mesh needs to be centered in Blender or whatever you used to make it.
Last edited by Slightly on Thu Jul 31, 2025 15:51, edited 1 time in total.

DragonWrangler1
Member
Posts: 175
Joined: Wed Jun 12, 2024 21:48
GitHub: DragonWrangler1
In-game: DragonWrangler1

Re: Mesh rendering problem

by DragonWrangler1 » Post

wheat8 wrote:
Wed Jul 30, 2025 16:27
Hi, I'm trying to create a mod that add littles menhirs to the world, that would be teleportation stones. But here is my problems:
  • the stone is not centered (pic1)
  • the texture is not applied (pic1)
  • when in hands, the texture rendering is way too big (pic2)
I'm a complete noob at modding (but you can guess it)
Also, is there a way to have the collision box fit the model ?

Code: Select all

minetest.register_node("magical_stone:house", {
    description = "Menhir magic",
    inventory_image = "magical_stone_inv.png",
    drawtype = "mesh",
    mesh = "magical_stone.obj",
    visual_scale = 0.05,
    groups = {cracky = 3},
    walkable = true,
    visual = "mesh",
    collision_box = {
        type = "regular",
        fixed = {
            {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}
        }
    }
})
problem1.png
problem2.png

You’ll probably need to use blockbench to center the model.


And making collision boxes fit the model is very complicated, I recommend just doing a rough shape.

User avatar
Skamiz Kazzarch
Member
Posts: 690
Joined: Fri Mar 09, 2018 20:34
GitHub: Skamiz
In-game: Skamiz
Location: la lojbaugag.

Re: Mesh rendering problem

by Skamiz Kazzarch » Post

The model is very large in hand because the model is very large in general. It only looks ok as a node, because you are using 'visual_scale = 0.05,'.
If you want a more reasonable size, that you don't need to adjust in code, you need to scale the model in your software of choice to a smaller size before exporting.

Similarly, the reason it's floating to the side is most likely that it's already to the side in the modeling software. You need to center it before export.

If you want specific, you need to tell us what modeling software you are using and maybe upload the model file.

The texture issue is, as Slightly already said, that the model doesn't have a texture defined. Only an image.
See relevant part of documentation: https://github.com/luanti-org/luanti/bl ... 1-L9410C93

Code: Select all

    textures = {},
    -- Number of required textures depends on visual:
    -- "cube" uses 6 textures just like a node, but all 6 must be defined.
    -- "sprite" uses 1 texture.
    -- "upright_sprite" uses 2 textures: {front, back}.
    -- "mesh" requires one texture for each mesh buffer/material (in order)
    -- Deprecated usage of "wielditem" expects 'textures = {itemname}' (see 'visual' above).
And as DragonWrangler said, making a matching collision box is not easy. It's not difficult as such, but exactly matching such a detailed model as you have with collision node boxes is tedious and I know of no tool that could automate the process.

wheat8
Member
Posts: 51
Joined: Sat Jul 20, 2024 13:06
Location: France

Re: Mesh rendering problem

by wheat8 » Post

Thank you guys for replying.

I was using Goxel, but it seems that it's not the most appropriate software for Luanti, so I changed and tried Blockbench as DragonWrangler suggest. I've done a model that fit the size I actually want in game (the model and textures are ugly, but let's do it functional before aesthetic). I added wield_image & inventory_image, those textures are shame but at least they're rendering :)

Code: Select all

minetest.register_node("magical_stone:house", {
    description = "Menhir magique",
    inventory_image = "inv_magic_stone.png",
    tiles = {"magical_stone3_texture.png"},
    wield_image = "magical_stone3_texture.png",
    drawtype = "mesh",
    mesh = "magical_stone.obj",
    groups = {cracky = 3},
    walkable = true,
    collision_box = {
        type = "fixed",
        fixed = {
            {-0.5, -0.5, -0.5, 0.5, 0, 0.5}
        }
    },
    selection_box = {
        type = "fixed",
        fixed = {
            {-0.5, -0.5, -0.5, 0.5, 0, 0.5}
        }
    }
})
The selection box and collision box are good, but the texture is still rendering above those two. I've centered the pivot in blockbench. Any idea why the texture is not displaying well ?

Capture du 2025-08-02 09-11-02.png
Capture du 2025-08-02 09-11-02.png (751.62 KiB) Viewed 3234 times

User avatar
Blockhead
Moderator
Posts: 2840
Joined: Wed Jul 17, 2019 10:14
GitHub: Montandalar
IRC: Blockhead256
In-game: Blockhead Blockhead256
Location: Land Down Under
Contact:

Re: Mesh rendering problem

by Blockhead » Post

wheat8 wrote:
Sat Aug 02, 2025 07:50

Code: Select all

minetest.register_node("magical_stone:house", {
    
    tiles = {"magical_stone3_texture.png"},
    ...
The selection box and collision box are good, but the texture is still rendering above those two. I've centered the pivot in blockbench. Any idea why the texture is not displaying well ?
It looks like you have two objects inside your model file but only one entry in the tiles table. In that case, the bottom one occupies the second material slot, so even if you want the same texture, so you another table entry:

Code: Select all

    tiles = {"magical_stone3_texture.png", "magical_stone3_texture.png"},
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂

User avatar
Slightly
Member
Posts: 146
Joined: Sun May 15, 2022 22:29
In-game: Slightly

Re: Mesh rendering problem

by Slightly » Post

Meshes have a UV map. I use Blender so only know how it's done there, but the way your texture displays is determined by that mapping that also has to be done in the model software. Then, as mentioned, you need as many textures as you do parts(groups) in the mesh.

wheat8
Member
Posts: 51
Joined: Sat Jul 20, 2024 13:06
Location: France

Re: Mesh rendering problem

by wheat8 » Post

It looks like you have two objects inside your model file but only one entry in the tiles table. In that case, the bottom one occupies the second material slot, so even if you want the same texture, so you another table entry:
It seems that there is only one object.. at least I see only one on blockbench, and I've created only one. About this, I've created a very simple mesh to minimize error I can do. So it's simply a little block with only one texture for all faces.
Meshes have a UV map. I use Blender so only know how it's done there, but the way your texture displays is determined by that mapping that also has to be done in the model software. Then, as mentioned, you need as many textures as you do parts(groups) in the mesh.
Obvioulsy I've done something wrong with model or UV, because painting the model to create the texture was really a mess.. I need a better understanding of the software.

User avatar
Slightly
Member
Posts: 146
Joined: Sun May 15, 2022 22:29
In-game: Slightly

Re: Mesh rendering problem

by Slightly » Post

wheat8 wrote:
Sat Aug 02, 2025 16:37
Obvioulsy I've done something wrong with model or UV, because painting the model to create the texture was really a mess.. I need a better understanding of the software.
If you want to upload the model/mod, I can take a look.

wheat8
Member
Posts: 51
Joined: Sat Jul 20, 2024 13:06
Location: France

Re: Mesh rendering problem

by wheat8 » Post

I've created another mesh, same problem.

Capture du 2025-08-03 10-23-32.png
Capture du 2025-08-03 10-23-32.png (893.7 KiB) Viewed 2974 times



Here is the "mod":
magical_stone.tar.gz
(1.6 KiB) Downloaded 159 times
And here are the model files:
magical_stone3.tar.gz
(2.04 KiB) Downloaded 153 times

User avatar
Blockhead
Moderator
Posts: 2840
Joined: Wed Jul 17, 2019 10:14
GitHub: Montandalar
IRC: Blockhead256
In-game: Blockhead Blockhead256
Location: Land Down Under
Contact:

Re: Mesh rendering problem

by Blockhead » Post

wheat8 wrote:
Sun Aug 03, 2025 08:42
I've created another mesh, same problem.


Capture du 2025-08-03 10-23-32.png




Here is the "mod":
magical_stone.tar.gz

And here are the model files:
magical_stone3.tar.gz
Oh I see, I had thought there was supposed to be more than one box in the model.

About the texturing: The UV map is not matched well to the texture provided. Since this is not a perfect cube, you will actually need two parts in your texture: One for the top and bottom, and another for the sides. The pixel dimensions of those parts will be different, matched up to the size of each face. Also, since your box is nearly 16x16 on just the top face alone, you will need to use a 32x32 texture to fit these two separate parts. You will then have to match up the top and bottom UVs, then the side UVs inside of Blockbench. I recommend this tutorial.

About the position: For whatever reason, models seem to come out upside down out of blockbench. I flipped the Y in the model, exported it, and it was right-side-up in Luanti.
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂

User avatar
Slightly
Member
Posts: 146
Joined: Sun May 15, 2022 22:29
In-game: Slightly

Re: Mesh rendering problem

by Slightly » Post

wheat8 wrote:
Sat Aug 02, 2025 07:50

The selection box and collision box are good, but the texture is still rendering above those two. I've centered the pivot in blockbench. Any idea why the texture is not displaying well ?

Capture du 2025-08-02 09-11-02.png
Image

I looked at your actual model. The texture is applied to your model. It's just that your model is a half size cube hovering off the "ground," at least it is when I import it into Blender. The shape on the bottom here is where the ground is in Minetest. I use it as a base for all my models so I can position them. Your model is above it. What you are highlighting in the picture is the selection box you have set for that space, but your model is above that and that's what the texture is on as expected.

Screenshot 2025-08-03 064518.png
Screenshot 2025-08-03 064518.png (299.01 KiB) Viewed 2907 times

This is your UV map. Since I don't know what you want it to look like I can't say how it should be, but this is going to give you gaps in your texture. UV maps don't have to be nearly as complicated as many people make them especially for our blocky world where we usually want cubes of a single color or a simple pattern. This could just be all faces stacked on top of a 16x16 texture.
If this is the actual final shape, you'd more likely want a nodebox rather than a mesh, but I think this is just a mock up?
Attachments
Screenshot 2025-08-03 064931.png
Screenshot 2025-08-03 064931.png (314.59 KiB) Viewed 2907 times

wheat8
Member
Posts: 51
Joined: Sat Jul 20, 2024 13:06
Location: France

Re: Mesh rendering problem

by wheat8 » Post

About the texturing: The UV map is not matched well to the texture provided.
Yes I need to work on UV map, thank you for the link.
The texture is applied to your model. It's just that your model is a half size cube hovering off the "ground," at least it is when I import it into Blender.
I'm surpised, because in Blockbench it look like that:
rendumag3.PNG
rendumag3.PNG (117.89 KiB) Viewed 2869 times
And the position on the Y axis is set to 0. The pivot is centered into the model.

I tried to lower the model so the pivot is set to 0 on the Y axis.
In Blockbench it give this:
test.PNG
test.PNG (81.4 KiB) Viewed 2869 times
And it give this in game:
après modif.png
après modif.png (659.59 KiB) Viewed 2869 times

wheat8
Member
Posts: 51
Joined: Sat Jul 20, 2024 13:06
Location: France

Re: Mesh rendering problem

by wheat8 » Post

Okay so I just find out that if I set the pivot in blockbench at -4 on the Y axis, the mesh is well rendering in game.
But it's not intuitive to set the model like that in the software:
test2.PNG
test2.PNG (95.79 KiB) Viewed 2868 times

So it's very likely that I've done something else wrong before.

User avatar
Slightly
Member
Posts: 146
Joined: Sun May 15, 2022 22:29
In-game: Slightly

Re: Mesh rendering problem

by Slightly » Post

wheat8 wrote:
Sun Aug 03, 2025 17:58
Okay so I just find out that if I set the pivot in blockbench at -4 on the Y axis, the mesh is well rendering in game.
But it's not intuitive to set the model like that in the software:
The nodes in game have the origin 0,0,0 at their center, so if you think of that way, this kind of makes sense. You have a half node, so to put it on the bottom of the node space, that 0,0,0 origin is right there on top of it in Blockbench, where the center would be if it were a full sized node. I guess. I don't use Blockbench.

wheat8
Member
Posts: 51
Joined: Sat Jul 20, 2024 13:06
Location: France

Re: Mesh rendering problem

by wheat8 » Post

The nodes in game have the origin 0,0,0 at their center, so if you think of that way, this kind of makes sense. You have a half node, so to put it on the bottom of the node space, that 0,0,0 origin is right there on top of it in Blockbench, where the center would be if it were a full sized node. I guess. I don't use Blockbench.
Yes, I assume it's something like that.

I've practiced a little bit, and now it's more how I want it to look. Also I'm happy because collision box and selection box nearly fit the model.
pic1.png
pic1.png (1009.46 KiB) Viewed 2638 times

But I've still a problem: the north face of the upper part of the stone is not rendering at all. I don't know why, because the UV map seems to fit the model..

pic2.png
pic2.png (888.88 KiB) Viewed 2638 times
Mod:
magical_stone.rar
(5.35 KiB) Downloaded 153 times

User avatar
Nathan.S
Member
Posts: 1170
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
Contact:

Re: Mesh rendering problem

by Nathan.S » Post

I don't use block bench, but I wonder if that black section isn't an inverted normal.
I record Luanti videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

User avatar
Slightly
Member
Posts: 146
Joined: Sun May 15, 2022 22:29
In-game: Slightly

Re: Mesh rendering problem

by Slightly » Post

Your normals on your model are fine. I can never get my pics in the right places, but you can see it in blender below.

Image

The problem is that you have exported your model without any material groups so while you think you are using three textures on a model that has three groups, the game is actually only applying the first one to all three parts. That means that even though your UV fits your bot, mid, and top textures, you are only using the bot one, and the UV for that top piece doesn't fit that bot texture so you are seeing part of the transparent or black part of that texture on the top of the model.


It's hard to see this in your game because you are using 3 textures that look a lot alike. If you switch those to obvious textures (I use different wool colors for my tests) you'll see immediately what's really going on. See the all blue pic below which is what the game shows with your model and this code:

Code: Select all

minetest.register_node("magical_stone:house", {
    description = "Menhir magique",
    inventory_image = "inv_magic_stone.png",
    tiles = {
		"wool_blue.png", 
		"wool_green.png", 
		"wool_red.png"
	},  -- Ajout des accolades pour un tableau
    wield_image = "magical_stone3_texture.png",
    drawtype = "mesh",
    mesh = "magical_stone5.obj",  -- Assurez-vous d'ajouter le fichier de mesh...

Image


This is your model with the material groups exported with it and all three colors showing and no holes in model. This test also helps you see the order you'd need to put the textures in your definition. In this case, the last one is on top, etc.

Image
Attachments
correct export with groups.png
correct export with groups.png (53.01 KiB) Viewed 2580 times
only first texture applied.png
only first texture applied.png (79.78 KiB) Viewed 2580 times
normals_map_fine.png
normals_map_fine.png (102.3 KiB) Viewed 2580 times
Last edited by Slightly on Wed Aug 06, 2025 23:54, edited 1 time in total.

wheat8
Member
Posts: 51
Joined: Sat Jul 20, 2024 13:06
Location: France

Re: Mesh rendering problem

by wheat8 » Post

Okay, so I need to learn how those materials work.

By the way, thank you very much Slightly for reviewing this, your explanations are very helpful !

Post Reply

Who is online

Users browsing this forum: jara25 and 0 guests