PERFORMANCE gain with using one texture for multiple items

User avatar
maikerumine
Member
 
Posts: 1350
Joined: Mon Aug 04, 2014 14:27
GitHub: maikerumine
In-game: maikerumine

PERFORMANCE gain with using one texture for multiple items

by maikerumine » Wed Jan 27, 2016 14:58

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",
   
})
[/code]

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:
[url]https://www.colorcodehex.com/online-color-mixer.html[/url]

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]
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!!!
Attachments
screenshot_20160127_095750.png
(241.32 KiB) Not downloaded yet
 

User avatar
jp
Member
 
Posts: 762
Joined: Wed Dec 18, 2013 09:03
Location: France
GitHub: kilbith

Re: PERFORMANCE gain with using one texture for multiple ite

by jp » Wed Jan 27, 2016 15:07

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.
 

User avatar
maikerumine
Member
 
Posts: 1350
Joined: Mon Aug 04, 2014 14:27
GitHub: maikerumine
In-game: maikerumine

Re: PERFORMANCE gain with using one texture for multiple ite

by maikerumine » Wed Jan 27, 2016 15:57

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?
 

User avatar
jp
Member
 
Posts: 762
Joined: Wed Dec 18, 2013 09:03
Location: France
GitHub: kilbith
 

Dragonop
Member
 
Posts: 1178
Joined: Tue Oct 23, 2012 12:59
Location: Argentina
GitHub: Dragonop
IRC: Dragonop
In-game: Dragonop

Re: PERFORMANCE gain with using one texture for multiple ite

by Dragonop » Wed Jan 27, 2016 16:29

I don't think so, since you still need to download the new texture.
 

User avatar
rubenwardy
Moderator
 
Posts: 5887
Joined: Tue Jun 12, 2012 18:11
Location: United Kingdom
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
 

User avatar
maikerumine
Member
 
Posts: 1350
Joined: Mon Aug 04, 2014 14:27
GitHub: maikerumine
In-game: maikerumine

Re: PERFORMANCE gain with using one texture for multiple ite

by maikerumine » Wed Jan 27, 2016 18:32

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?
 

User avatar
Calinou
Moderator
 
Posts: 3157
Joined: Mon Aug 01, 2011 14:26
Location: Troyes, France
GitHub: Calinou
IRC: Calinou
In-game: Calinou

Re: PERFORMANCE gain with using one texture for multiple ite

by Calinou » Wed Jan 27, 2016 18:39

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.
 

User avatar
maikerumine
Member
 
Posts: 1350
Joined: Mon Aug 04, 2014 14:27
GitHub: maikerumine
In-game: maikerumine

Re: PERFORMANCE gain with using one texture for multiple ite

by maikerumine » Wed Jan 27, 2016 18:40

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.
 

User avatar
Calinou
Moderator
 
Posts: 3157
Joined: Mon Aug 01, 2011 14:26
Location: Troyes, France
GitHub: Calinou
IRC: Calinou
In-game: Calinou

Re: PERFORMANCE gain with using one texture for multiple ite

by Calinou » Wed Jan 27, 2016 18:45

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.
 

KCoombes
Member
 
Posts: 412
Joined: Thu Jun 11, 2015 23:19
Location: SW Florida, USA
In-game: Knatt

Re: PERFORMANCE gain with using one texture for multiple ite

by KCoombes » Thu Jan 28, 2016 00:36

+1000

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


Return to Modding Discussion



Who is online

Users browsing this forum: No registered users and 2 guests