sp614x / optifine

1.81k stars 416 forks source link

[Optimization] Potential ideas for LOD #7567

Open ZenithRogue opened 1 year ago

ZenithRogue commented 1 year ago

Description

This issue suggests a few areas where an implementation of LOD could be useful

1. Alt Models for Blocks at Different Distances

To optimize rendering performance, we can introduce alternative models for blocks that vary in complexity based on their distance from the camera. These alternative models can be organized into folders for easy management, and controlled by an lod.properties file, defining rules for distances/models/etc. This would allow resource packs to add complexity to nearby blocks, without needing

Examples:

2. Flat Rendering for "builtin/generated" Items at a Distance

When items using template "builtin/generated" are far away from the camera, they could be rendered as flat sprites

3. Disable Entity Animations When Too Far

Entities at a certain distance from the camera could have their animations disabled

4. Disable CTM When Too Far

Blocks at a certain distance could skip checking for CTM connections

5. Disable Transparency When Too Far

Blocks at a certain distance could render as a solid color, rather than transparent

6. LOD Sliders and Toggle in Options

To give players more control over LOD settings, could add LOD sliders and a toggle in the game's options menu

Potential issues

Some of these recommendation should be taken with a grain of salt (block rendering in particular), as I am not familiar with the internal construction of world geometry

IMS212 commented 1 year ago

3: Entities are always reconstructed per model part per frame, as the model view matrix is stored in the position data. This would generally have a very minor impact. 5: Transparency is done with built in blending hardware. Having more transparent objects is generally the same performance as having one.

IMS212 commented 1 year ago

1: This would likely hurt performance in the long run, as it means chunks must be remeshed as you move. This is equivalent to reloading the chunk, and would likely offset the performance of it.

Overall, LOD is really only useful for having more render distance, not saving performance. I don't think it's good in OptiFine.

ZenithRogue commented 1 year ago

Thanks @IMS212. As originally noted, I was unsure of how practical some of these optimizations were, especially optimizations involving block geometry.

Would it be beneficial/practical to load some models such as grass to a separate mesh that can be unloaded separately?

IMS212 commented 1 year ago

Maybe on really low end computers, but probably not. You'd have to be quite vertex/fragment limited to achieve any major improvement.

gadyushnik commented 1 year ago

mojang should have done this 10 years ago, great idea