Sodium

Sodium

44M Downloads

Add option to change the load distance function to a circle

cavallium opened this issue ยท 2 comments

commented

Is your feature request related to a problem? Please describe.
The default chunk load distance loads chunks in a square.
In this way the chunks in the corners are rendered farther from the player than other chunks that are along the x or z axis.
This can affect performance since chunks far from the player are rendered.

Describe the solution you'd like
Add an option to change the rectangular chunk load radius function with the circular radius function:
in me.jellysquid.mods.sodium.client.world.SodiumChunkManager, line 157:

if (((x - this.centerX) * (x - this.centerX)) + ((z - this.centerZ) * (z - this.centerZ)) <= this.radius * this.radius) {

A circular region means that fewer chunks will be loaded and rendered. This can affect performance, especially with Amplified maps or maps with a lot of complex blocks to render.

Another improvement is that chunks that are loaded and unloaded when a player moves will be better spreaded across time, since a square render distance loads a line of chunks (1 * render distance) at time, but a circular one loads less chunks at the same time.

Describe alternatives you've considered
An alternative is to always use the circular radius function, without adding an option, or leaving the chunk radius function as it is now.

Additional informations
This will also remove the two Math.abs calls from the function, removing two comparations and therefore speeding up the function.
I didn't use the Math.pow function since it's known to be much slower than simply multiplying the same value two times.

commented

There is no need to do that, since sodium already doesn't render chunks that are inside the (circular) fog AFAIK (although they are still loaded).

commented

I closed the issue because I noticed in when I tested the change.