-
Notifications
You must be signed in to change notification settings - Fork 33
Item Frame Culling
On this page, we will compare vanilla, sodium, and MoreCulling. To show how much MoreCulling can help with performance
3-face culling is a system I use to only render 3-sides of an item in item frames. This is only active when items in an item frame are not rotated on a 45-degree angle.
These test comparisons are using 7350 invisible item frames with a stone block in them.
Vanilla: ~35 fps
Sodium: ~45 fps
MoreCulling: ~45 fps
Sodium + MoreCulling: ~55 fps
As you can see, MoreCulling drastically improves vanilla and sodium when it comes to item frame rendering for blocks (and soon items) using 3-face culling
3-Face culling is exactly as it sounds, it only renders 3-faces. This means that instead of rendering 6 faces for each block, you only render 3 based on where the player's camera is located, the frame's rotation, and the rotation of the item.
Using those we are able to determine what faces the player is able to see, allowing us to remove the other faces from being rendered.
There's a bunch of other stuff happening behind the scenes, although I don't want to bore you. So if you are interested just go look at the code ;)
The reason that this only works when the item in the item frame is not on a 45-degree is pretty simple. That would be 4-faces and it's on the todo-list ;)
Back culling does as it says, it removes the back of items in item frames if it's impossible for you to see the back of the item frame.
This has a large impact since items in item frames consist of many boxes, each with 6 sides. Some items have 32+ of these boxes. So culling them saves you 32 render calls per item frame, this is much more visible when the items are enchanted since these calls are more expensive!
TODO
This is very simple to explain. When an item is in a visible item frame. The back of the item renders behind the item frames back, there's no reason to do this since you can't see it.
But wait, it also works when the item is invisible and for blocks!
When the item frame is invisible we check if the block behind the item frame has a solid face, if it does it allows us to remove the back of the item, whether it's a block item or not.
After a certain distance the game will only render the front face of an item, drastically reducing the amount of vertexes. Usually you will not notice it, although if you do and don't like it you can easily turn it off
More Info is required
Everyone knows just how bad maps in item frames are, the performance loss is terrible. Well not completely anymore? This optimization does not fix all performance issues with maps and does not cull them in all instances. It does however cull most of them, and just makes the game much smoother when you have maps all over the place!
I run a pretty beefy setup now, so usually I need insane amounts of entities just to give visible results... Not for maps, 100 maps lowers my fps by ~800. xD - GG Mojang
Map Layout: ~210 fps
Behind Maps without MoreCulling: ~210 fps
Behind Maps with MoreCulling: ~1040 fps
MoreCulling won't render the maps that are obviously not visible, saving you a ton of performance.
It couldn't be simpler honestly. If your position is anywhere behind the item frame, you can't see it so don't render it ;)