Mesh node with multiple textures not working

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

Mesh node with multiple textures not working

by Blockhead » Post

Hi! I am trying to create a custom signal set for advtrains based on the Victorian 3-position speed signalling system. These signals have 2 lamps, one atop the other:

Image

I have copied the general idea of the ks signal set, which has one mesh but multiple textures applied. This works fine for the ks main signal, but I can't figure out how to make it work for mine!

The textures are applied correctly in Blender and UV-unwrapped. Important note: I am using Blender 2.8. There are 3 materials: one for each light, and currently they are three different meshes. I have tried them as one mesh with three materials and as three meshes with one material each. The settings are similar for each:

Image

Screenshot blender UV wrapping and material setup

I then export to .obj which I understand minetest (i.e. irrlicht) is supposed to support, but I find that the same texture is applied to all three components. Is a custom export plugin required? I had tried the b3d exporter python script for 2.79 (yes, with 2.79 installed) but it didn't appear in the export menu - regardless, obj should work.

In lua, the textures are defined as a table of 3 textures as property 'tiles' (code excerpt):

Code: Select all

	...
	RY = {
		asp = {
			main = {free = true, speed = 40},
			dst = {free = false},
			shunt = {free = false}
		},
		tex = {"vss_3pos-texture.png", "vss_lampred.png", "vss_lampyellow.png"}
	}
}) do
	minetest.register_node("vss:home_"..signalType --[[.."_"..rot--]], {
		description = "Victorian Home Signal ("..signalType..")",
		drawtype = "mesh",
		mesh = "threepos-home.obj",
		tiles = siginf.tex,
	...
This does not work for some reason that I do not understand - because the ks signal set uses the same property 'tiles' and it works just fine! Instead the same texture is applied to the 3 meshes:
Image

Can someone with more expertise please let me know what I'm doing wrong?
Attachments
Screenshot blender UV wrapping and material setup
Screenshot blender UV wrapping and material setup
uvwrap.jpg (199.04 KiB) Viewed 365 times
vss.zip
Mod source tree - blend file inside in models directory
(589.99 KiB) Downloaded 30 times
Signal in game - same texture in 3 places!
Signal in game - same texture in 3 places!
screenshot_20190806_145559.png (308.91 KiB) Viewed 365 times
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂

User avatar
GreenXenith
Member
Posts: 1356
Joined: Wed Oct 28, 2015 01:26
GitHub: GreenXenith
Location: UTC-8:00
Contact:

Re: Mesh node with multiple textures not working

by GreenXenith » Post

Without looking at the files (I don't have time at the moment), it looks like you need to export material groups.
Your .obj export settings should look like this:
Image
Default values with Write Materials unchecked (because it just generates a usually useless file) and Material Groups checked. This should use all the material slots.

Once this is done, you may need to swap around the textures in the table to get them in the right spot - they don't like to follow the list order.
YouTube | Mods | Patreon | Minetest Discord @greenxenith

You should not be able to read this message.

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

Re: Mesh node with multiple textures not working

by Blockhead » Post

Thank you very much! I hadn't seen the export options. They are in the bottom left of the file save dialogue in Blender 2.8. After checking the box the textures applied in a funny order; I simply had to re-arrange their orders and everything worked perfectly (ok, except for a minor UV unwrapping issue which was easy).

Image

Edit: If someone can please add this to the developer wiki page (so I don't have to register there) - it's not mentioned anywhere but it's very important.
Attachments
4 signals arranged in order from full speed to stop, working as intended after exporting materials
4 signals arranged in order from full speed to stop, working as intended after exporting materials
screenshot_20190806_170310.png (457.98 KiB) Viewed 365 times
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂

Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests