-
Bug
-
Resolution: Unresolved
-
None
-
1.20.4
-
Confirmed
-
Performance, Textures and models
-
Normal
-
Gameplay
The bug
Fences are a particularly laggy block due to their often complex geometry (see also MC-123584). For fences where two opposite directions have a connection, it is possible to optimize the geometry such that the game needs to render fewer triangles for effectively the same visual result.
Currently in vanilla, fences use a multipart model consisting of a central post plus one to four outward connection pieces. These outward connections have up to ten faces each, although adjacent block culling often reduces this to eight. For fences which have both north and south connections and/or east and west connections, this adds up to 20 (often culled to 16) faces for the relevant axis. However, it's possible to reduce this to 12 (8) faces with a bit of resource pack magic.
We implement a third model file for each fence, titled [material]_fence_side_long, which defines the two bars stretching from one end of the block to the other via one cuboid per bar, rather than the standard approach which splits it into two elements. The blockstates file for each fence is edited as to not use the standard fence_side in cases where both north and south are true (or both east and west are true), and instead use this specific long side model. As such, with less faces needed for the game to render, we get a visually identical result with less rendering performance impact.
An implementation of this fix is attached in the form of a resource pack. Unless you use Spectator mode or otherwise find yourself intersecting fence blocks, there should be no visual difference from vanilla fences (aside from the fact that this resource pack fixes MC-109478). All fence types are affected by this fix with the exception of bamboo fences, as these use their own texturing system which would require rewriting to work with this fix.
How to reproduce
- Create a creative Superflat world with the following preset:
minecraft:barrier;minecraft:the_void
- Enter flying mode by double pressing the jump button
- Run the command
/tp @s 0 -20 0 0 90
- Run the command
/fill -30 -63 -30 30 -56 30 oak_fence
- Open the performance graphs via F3+2
- Switch between the default resources and the attached resource pack, comparing the performance
Expected results
Good framerates in vanilla.
Actual results
We can do far better.
How to fix
Simply implement the resources in the attached resource pack into vanilla. I give Mojang my full permission and encouragement to use these files to make vanilla Minecraft run better.
- relates to
-
MC-262427 Flower pots and potted objects have very poorly optimized models and strange texture mapping
- Open
-
MC-262452 Hopper models are unoptimized and cause rendering lag
- Open
-
MC-262461 Stair models are unoptimized and can cause rendering lag
- Open
-
MC-262470 Cauldron models are very unoptimized, causing render lag
- Open
-
MC-262527 Item frame models are quite unoptimized
- Open
-
MC-262641 Chorus flower models are incredibly unoptimized and cause serious rendering lag
- Open
-
MC-262689 Hanging mangrove propagule models are comically unoptimized
- Open
-
MC-262953 Fence gate models are very unoptimized, causing lag among other issues
- Open
-
MC-267127 Composter model is unoptimized, causing extra rendering lag
- Open
-
MC-260296 Pink petal block models are not optimized
- Resolved
-
MC-262652 Dragon egg's side texture is mapped strangely as of 1.8 (and the model is also unoptimized)
- Resolved
-
MC-267315 Rendering performance optimization for glass pane models
- Open
-
MC-267864 Two-tall plant model/rendering not optimized
- Open