Page 1 of 1

PERFORMANCE gain with using one texture for multiple items

Posted: Wed Jan 27, 2016 14:58
by maikerumine
Hello!

I have been working on merging textures from other mods to point to default mods to have less media for the server, and then it hit me: what id we were to simplify the default textures too? Maybe use one texture for multiple textures by adding colour...

So This is what I have been working on, and it works.
Image
Example of using 5 textures for ALL the tools in MT:

Code: Select all

minetest.register_tool("default:pick_diamond", {
	description = "Diamond Pickaxe",
	inventory_image = "default_handle_long.png^(default_steelpick.png^[colorize:#33FFFF:152)",
	tool_capabilities = {
		full_punch_interval = 0.9,
		max_drop_level=3,
		groupcaps={
			cracky = {times={[1]=2.0, [2]=1.0, [3]=0.50}, uses=30, maxlevel=3},
		},
		damage_groups = {fleshy=5},
	},
})
We us only the top part of steel pick for All picks by adding colour. :-)
The tools use a handle image and a tool image overlaid to get this effect.
This means one handle can be used with ALL tools.

BLOCKS:

Code: Select all

minetest.register_node("default:sandstonebrick", {
	description = "Sandstone Brick",
	--tiles = {"default_sandstone_brick.png"},
	tiles = {"default_stone_brick.png^[colorize:#CCCC99:152"},
	is_ground_content = false,
	groups = {cracky = 2},
	sounds = default.node_sound_stone_defaults(),
})

By using one texture for generic stone brick pattern, we colourise it to make more, therefore we can remove more textures from folder.

Ingots and lumps:
[code]
minetest.register_craftitem("default:iron_lump", {
	description = "Iron Lump",
	--inventory_image = "default_iron_lump.png",
	inventory_image = "default_clay_lump.png^[colorize:#9C0503:152",
})

minetest.register_craftitem("default:copper_ingot", {
	description = "Copper Ingot",
	--inventory_image = "default_copper_ingot.png",
	inventory_image = "default_steel_ingot.png^[colorize:#FF6600:152",
	
})
You get the idea, this frees up space on textures for less of an upload / download for public servers, thus speeds things up just a teeny bit.

Reference to a decent color picker is here:
https://www.colorcodehex.com/online-color-mixer.html

You may need to tune colours just right if colourising an already coloured texture, this is why I chose the steel textures as my base texture to modify.

You can visit the ESM City server to see this in action.


NOTE:

you MUST change the corresponding stairs to match too:

Code: Select all

stairs.register_stair_and_slab("bronzeblock", "default:bronzeblock",
		{cracky = 1, level = 2},
		{"default_steel_block.png^[colorize:#996600:152"},
		"Bronze Block Stair",
		"Bronze Block Slab",
		default.node_sound_stone_defaults())
Moreblocks also if you need.

Happy coding!!!

Re: PERFORMANCE gain with using one texture for multiple ite

Posted: Wed Jan 27, 2016 15:07
by jp
Using texture modifiers does not free up space. The resulting images are stored on your RAM instead of your HDD.

And it has nothing to do with performances. I'd say it's even slower since the engine have to generate these combined images at start-up time.

Re: PERFORMANCE gain with using one texture for multiple ite

Posted: Wed Jan 27, 2016 15:57
by maikerumine
jp wrote:Using texture modifiers does not free up space. The resulting images are stored on your RAM instead of your HDD.

And it has nothing to do with performances. I'd say it's even slower since the engine have to generate these combined images at start-up time.
Oh no! Really?

What about server and client download / upload, wouldn't this save clients from loading textures?

Re: PERFORMANCE gain with using one texture for multiple ite

Posted: Wed Jan 27, 2016 16:12
by jp
No idea.

Re: PERFORMANCE gain with using one texture for multiple ite

Posted: Wed Jan 27, 2016 16:29
by Dragonop
I don't think so, since you still need to download the new texture.

Re: PERFORMANCE gain with using one texture for multiple ite

Posted: Wed Jan 27, 2016 17:08
by rubenwardy
Using remote media servers speeds media loading up greatly.

Re: PERFORMANCE gain with using one texture for multiple ite

Posted: Wed Jan 27, 2016 18:32
by maikerumine
rubenwardy wrote:Using remote media servers speeds media loading up greatly.
I would like tutorial on how to do this with minetest. Are there any specifically for this purpose?

is this correct?
http://minetest.wjake.com/wiki/dev:remote-media

https://gist.github.com/sfan5/6351560 <--code looks like linux, can this work with windows?

Re: PERFORMANCE gain with using one texture for multiple ite

Posted: Wed Jan 27, 2016 18:39
by Calinou
1. Set up an Apache or nginx server accessible from the Web.
2. Run this script at the root of a Minetest installation.
3. Move the generated "media" folder to your Apache/nginx installation, and rename it to "minetest" (the name can be anything, it's just for convenience purposes).
4. Stop your Minetest server before editing minetest.conf.
5. Modify your minetest.conf and add a like like this (it must have a trailing slash):

Code: Select all

remote_media = http://my-domain.com/minetest/
6. Restart the Minetest server.
7. It should work now. You can try it by deleting the cache/ folder on your client Minetest installation then joining the server.

Re: PERFORMANCE gain with using one texture for multiple ite

Posted: Wed Jan 27, 2016 18:40
by maikerumine
Calinou wrote:1. Set up an Apache or nginx server accessible from the Web.
2. Run this script at the root of a Minetest installation.
3. Move the generated "media" folder to your Apache/nginx installation, and rename it to "minetest" (the name can be anything, it's just for convenience purposes).
4. Stop your Minetest server before editing minetest.conf.
5. Modify your minetest.conf and add a like like this (it must have a trailing slash):

Code: Select all

remote_media = http://my-domain.com/minetest/
6. Restart the Minetest server.
7. It should work now. You can try it by deleting the cache/ folder on your client Minetest installation then joining the server.
Thank you!

I'll see if I can get this to work on windows.

Re: PERFORMANCE gain with using one texture for multiple ite

Posted: Wed Jan 27, 2016 18:45
by Calinou
maikerumine wrote:Thank you!

I'll see if I can get this to work on windows.
You will need Cygwin to run collectstatic.sh. I recommend Babun to get it working quickly on Windows (along with nice zsh goodies). Note that some additional packages may be required; if they aren't present, you can use the "pact install" command to install them.

WampServer should be fine for using Apache on Windows.

You may also benefit from a domain or a subdomain (rather than pointing to an IP address) as well. Check out nsupdate.info for free subdomains.

Re: PERFORMANCE gain with using one texture for multiple ite

Posted: Thu Jan 28, 2016 00:36
by KCoombes
+1000

Just imagine... diamond fences... gold item frames... the possibilities are staggering!