🎨 Distance-Based Mob Texture LOD (Minecraft 26.1.2)
Rendering full 1024x1024 or high-resolution textures on distant mobs that occupy only 4x4 pixels on the player's screen wastes significant GPU VRAM bandwidth and texture sampler cache lines.
Camera Culling includes a decoupled, 3-tier OpenGL Texture LOD Biasing Engine that dynamically adjusts texture mipmap sampling based on entity distance.
📋 Distance Texture LOD Infobox
| Property | Value |
|---|---|
| Pipeline Hook | LivingEntityRenderer.submit(...) @At("HEAD") & @At("RETURN") |
| OpenGL Parameter | GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, bias) |
| Near Threshold | $< 16.0$ blocks $\implies 0.0\text{f}$ Bias (Full Resolution) |
| Medium Threshold | $16.0 - 32.0$ blocks $\implies 1.0\text{f}$ Bias (Half Resolution) |
| Far Threshold | $> 32.0$ blocks $\implies 2.5\text{f}$ Bias (Quarter Resolution / Mipmap) |
| Exemptions | Glowing entities, local player, Bosses & Mini-Bosses, Blacklisted mobs |
🔬 Mathematical Distance LOD Biasing
Camera
│
├── [ 0m to 16m ] ──► Bias 0.0f (100% Native Full-Res Texture)
│
├── [ 16m to 32m ] ──► Bias 1.0f (50% Half-Res Mipmap Sampling)
│
└── [ > 32m ] ──────► Bias 2.5f (25% Low-Res Mipmap Sampling)The LOD bias $B$ is calculated purely from distance squared: $$B(d) = \begin{cases} 0.0\text{f} & \text{if } d^2 < \text{startDist}^2 \ (16.0^2) \ 1.0\text{f} & \text{if } \text{startDist}^2 \le d^2 < \text{farDist}^2 \ (32.0^2) \ 2.5\text{f} & \text{if } d^2 \ge \text{farDist}^2 \end{cases}$$
OpenGL State Isolation
When rendering a living entity, LivingEntityRendererMixin injects at submit:HEAD to apply the calculated bias, and immediately resets it to 0.0f at submit:RETURN. This guarantees that block models, items, and UI elements are never affected.
