Node boxes vs mesh memory?

Skulls
Member
 
Posts: 108
Joined: Thu Dec 21, 2017 17:41
In-game: Skulls

Node boxes vs mesh memory?

by Skulls » Fri Jan 12, 2018 18:21

As an experiment I replaced the 'default:stone' block with a cube mesh to add a little "pizzazz". There were about 26 or so vertices and I got some interesting behavior where my framerate plummeted (kind of expected) and the memory skyrocketed. Using a simple cube mesh (8 vertices) was much better but not nearly as good as the regular node box type blocks.

'Pizzazz' 26 vert mesh
20 fps
5+ Gb RAM

Simple cube mesh
58 fps
1.5 Gb RAM

Default node drawtype as in 'default' game
60 fps (capped)
200 Mb RAM

Are the regular node boxes handled differently than meshes?
 

User avatar
stu
Member
 
Posts: 923
Joined: Sat Feb 02, 2013 02:51
Location: United Kingdom
GitHub: stujones11

Re: Node boxes vs mesh memory?

by stu » Fri Jan 12, 2018 18:58

AFAIK, regular node-boxes are converted to meshes anyway. Do you mean just regular cubic nodes?

Interesting info all the same, though I guess some performance hit is to be expected if you replace default stone =)
 

Skulls
Member
 
Posts: 108
Joined: Thu Dec 21, 2017 17:41
In-game: Skulls

Re: Node boxes vs mesh memory?

by Skulls » Fri Jan 12, 2018 19:31

stu wrote:AFAIK, regular node-boxes are converted to meshes anyway.


That's what I thought too so I was surprised to see such a big memory change between the defaults and a blender supplied cube. Blender tossed in some extra things so maybe scaling that by a few hundred vs the default nodes makes up the memory difference.

Over a gigabyte of memory difference between the 'default:stone' generated mesh and the simple cube mesh:

Code: Select all
--minetest.register_node("default:stone", {
--   description = "Stone",
--   tiles = {"default_stone.png"},
--   groups = {cracky = 3, stone = 1},
--   drop = 'default:cobble',
--   legacy_mineral = true,
--   sounds = default.node_sound_stone_defaults(),
--})

-- simple cube mesh stone
minetest.register_node("default:stone", {
  description = "Test mesh stone",
  drawtype = "mesh",
  mesh = "test.obj",
  tiles = {"default_stone.png"},
  is_ground_content = false,
  drop = 'default:cobble',
  groups = {cracky = 3, stone = 1},
  sounds = default.node_sound_stone_defaults(),
})


Code: Select all
# Blender v2.79 (sub 0) OBJ File: 'Stone.blend'
# www.blender.org
mtllib test.mtl
o Cube.000_Cube.002
v -0.500000 -0.500000 0.500000
v -0.500000 0.500000 0.500000
v -0.500000 -0.500000 -0.500000
v -0.500000 0.500000 -0.500000
v 0.500000 -0.500000 0.500000
v 0.500000 0.500000 0.500000
v 0.500000 -0.500000 -0.500000
v 0.500000 0.500000 -0.500000
vt 0.000200 0.999800
vt 0.000200 0.666866
vt 0.333134 0.666866
vt 0.333134 0.999800
vt 0.666866 0.333134
vt 0.666866 0.000200
vt 0.999800 0.000200
vt 0.999800 0.333134
vt 0.333134 0.333533
vt 0.333134 0.666467
vt 0.000200 0.666467
vt 0.000200 0.333533
vt 0.666467 0.333533
vt 0.666467 0.666467
vt 0.333533 0.666467
vt 0.333533 0.333533
vt 0.666467 0.333134
vt 0.333533 0.333134
vt 0.333533 0.000200
vt 0.666467 0.000200
vt 0.333134 0.333134
vt 0.000200 0.333134
vt 0.000200 0.000200
vt 0.333134 0.000200
vn -1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 0.0000 1.0000
vn 0.0000 -1.0000 0.0000
vn 0.0000 1.0000 0.0000
usemtl None
s off
f 1/1/1 2/2/1 4/3/1 3/4/1
f 3/5/2 4/6/2 8/7/2 7/8/2
f 7/9/3 8/10/3 6/11/3 5/12/3
f 5/13/4 6/14/4 2/15/4 1/16/4
f 3/17/5 7/18/5 5/19/5 1/20/5
f 8/21/6 4/22/6 2/23/6 6/24/6
 

User avatar
stu
Member
 
Posts: 923
Joined: Sat Feb 02, 2013 02:51
Location: United Kingdom
GitHub: stujones11

Re: Node boxes vs mesh memory?

by stu » Fri Jan 12, 2018 19:52

I think you may be confusing the term nodebox (a node composed of many smaller boxes) and simple cubic nodes like dirt and stone, apologies if I am mistaken.

In simple terms, the map-block rendering is optimised for simple cubes, whereas complex meshes require more processing and memory, multiply that by the number of stone nodes in your average scene then this does not surprise me. Someone else may be able to provide a more detailed explanation.

However, I you do mean a single cube 'nodebox' is more efficient than a simple mesh cube then that does suggests nodeboxes are handled differently.
Last edited by stu on Fri Jan 12, 2018 20:05, edited 2 times in total.
 

Skulls
Member
 
Posts: 108
Joined: Thu Dec 21, 2017 17:41
In-game: Skulls

Re: Node boxes vs mesh memory?

by Skulls » Fri Jan 12, 2018 20:04

Yup, I couldn't find a term for the meshes that are generated so I just called them 'node boxes'. Whatever the landscape nodes are called.

stu wrote:.. a single cube 'nodebox' is more efficient than a simple mesh cube then that does suggests nodeboxes are handled differently.


Correct! Either the way that the generated simple mesh cubes are handled vs a cube.obj is different or (more likely) I'm doing something weird.
 

User avatar
stu
Member
 
Posts: 923
Joined: Sat Feb 02, 2013 02:51
Location: United Kingdom
GitHub: stujones11

Re: Node boxes vs mesh memory?

by stu » Fri Jan 12, 2018 20:08

Suggestion: Try using the wireframe mode to see the differences between nodes, nodeboxes, and meshes, maybe it can provide some clues :)
 

Skulls
Member
 
Posts: 108
Joined: Thu Dec 21, 2017 17:41
In-game: Skulls

Re: Node boxes vs mesh memory?

by Skulls » Fri Jan 12, 2018 20:32

Well, there we go then. It seems to be drawing *all* the obj meshes, even ones behind others.

Default generated map nodes:
Image
mesh_stone0.png
(374.7 KiB) Not downloaded yet


Simple blender cube mesh map node:
Image
mesh_stone1.png
(322.64 KiB) Not downloaded yet
 

User avatar
stu
Member
 
Posts: 923
Joined: Sat Feb 02, 2013 02:51
Location: United Kingdom
GitHub: stujones11

Re: Node boxes vs mesh memory?

by stu » Fri Jan 12, 2018 20:54

Seems pretty conclusive, though I am not sure you have discovered anything that is not already known but again, I could be mistaken, it does seem a bit silly.

Certainly a good reason to not use meshnodes or nodeboxes for map generation :)
 

Skulls
Member
 
Posts: 108
Joined: Thu Dec 21, 2017 17:41
In-game: Skulls

Re: Node boxes vs mesh memory?

by Skulls » Fri Jan 12, 2018 20:57

stu wrote:Seems pretty conclusive, though I am not sure you have discovered anything that is not already known but again, I could be mistaken, it does seem a bit silly.

Certainly a good reason to not use meshnodes or nodeboxes for map generation :)


Very true. So seems as if backface culling is only on the generated meshes?
 

User avatar
stu
Member
 
Posts: 923
Joined: Sat Feb 02, 2013 02:51
Location: United Kingdom
GitHub: stujones11

Re: Node boxes vs mesh memory?

by stu » Fri Jan 12, 2018 21:38

Skulls wrote:
stu wrote:Seems pretty conclusive, though I am not sure you have discovered anything that is not already known but again, I could be mistaken, it does seem a bit silly.

Certainly a good reason to not use meshnodes or nodeboxes for map generation :)


Very true. So seems as if backface culling is only on the generated meshes?


I think the term is occlusion culling but yeah, maybe that too :)
 

Skulls
Member
 
Posts: 108
Joined: Thu Dec 21, 2017 17:41
In-game: Skulls

Re: Node boxes vs mesh memory?

by Skulls » Fri Jan 12, 2018 23:04

Look at this crazy! Generated nodes on the left, blender mesh on the right with a tail and a floating on each side.

Image

The surfaces are actually merged per node type. Now that is some clever optimization. Very nice!
Attachments
mesh_stone3.png
(756.06 KiB) Not downloaded yet
 

User avatar
Drachenbauer32
Member
 
Posts: 98
Joined: Wed Aug 28, 2019 18:11

Re: Node boxes vs mesh memory?

by Drachenbauer32 » Fri Oct 25, 2019 18:40

you should not go only for memory.
There are more differences:
with meshes, you have more freedom for designing your stuff:
-you can add slopes and curves to the shape (not only horizontal and vertical rectangle surfaces)
-you can create more detailed texturing (sample: a fireplace can have a ceramic-tiled outside and a dark inside with wooden logs as fuel in there and also animated flames, all in a single node)
 

sirrobzeroone
Member
 
Posts: 123
Joined: Mon Jul 16, 2018 07:56

Re: Node boxes vs mesh memory?

by sirrobzeroone » Fri Nov 08, 2019 03:24

I asked a similar question a few months back and Krock gave some awesome info:

http://forum.minetest.net/viewtopic.php?f=47&t=23262
 


Return to Modding Discussion



Who is online

Users browsing this forum: MSN [Bot] and 4 guests