**Gadolinium** keeps [Nothirium](https://github.com/Meldexun/Nothirium)'s GL 4.3 terrain renderer working with OptiFine shader packs on **Cleanroom** (Minecraft 1.12.2, Java 25), and adds terrain culling on the GPU. It was called Nothirium Shaders before its first release.
Without it, turning on a shader pack makes Nothirium fall back to its slow GL 1.5 path. With it, Nothirium keeps its GL 4.3 renderer with shaders on, shadow pass included.
It is made only of mixins that coexist with other mods. It does not change or redistribute any other mod's jar.
## Features
- **Shader mode:** the shader pack's programs get what they need from Nothirium's renderer, so shaders and Nothirium work together.
- **GPU culling** (on): the GPU decides which terrain sections to draw, with and without shaders.
- frustum culling of the terrain and of the shadow pass (against the light);
- per-direction face culling for opaque layers (faces turned away are not drawn);
- entities and tile entities only drawn when a section they touch was reached;
- two-pass Hi-Z occlusion culling (experimental, off): it only pays off in dense scenes such as forests, cities and caves, and `measureGpuTime` shows whether it does on your pack. An automatic mode turns it on only while the GPU is the bottleneck.
- **Shadow pass limited** to the shadow distance the pack asks for.
- **Lower frame rate while the window has no focus** (15 FPS, configurable).
- **Compatibility fixes** that make Nothirium and OptiRefine work together, and a limit on Nothirium's chunk compile buffers so a big pack with shaders does not run out of direct memory.
In the test pack (Ryzen 7 7800X3D, RTX 5060, no shader pack), at the same spot: about **750 FPS with GPU culling, 630 without**.
## Safety
- **Code locks:** every part checks a fingerprint of the exact code it depends on. If a mod or the game has different code there, only that part turns off, and the log says why.
- **Visible warnings:** an option that is on but did not start is shown once in the chat and listed in F3.
- **Fallbacks:** without compute shaders or `glMultiDrawArraysIndirectCount`, the terrain goes through Nothirium's own GL 4.3 path; an OpenGL error turns off only the part that caused it.
- **Validation mode** (`validationMode=true`) compares the optimized path with the original and logs any difference.
## Requirements
- Cleanroom 0.7.14-alpha or newer (Java 25)
- Nothirium 1.12.2-0.4.9-beta and RenderLib 1.12.2-1.4.5
- OptiFine 1.12.2 HD_U_G5 (from optifine.net)
- [OptiRefine](https://github.com/Ecdcaeb/OptiRefine) built from commit `78ff8ce`: download `OptiRefine-78ff8ce.jar` from the [v1.0.0 release](https://github.com/snwxMR/gadolinium-gambiarra/releases/tag/v1.0.0) of Gadolinium's repository (OptiRefine's own code, MIT license, by Hileb). Its v0.1.0-alpha release is **not compatible with Nothirium yet** (see the known limitations). With any other build the shader part turns itself off and says so in the log
- Recommended: **Gambiarra** (fixes for other mods; with OptiRefine 78ff8ce it works around its zoom key and Custom Colors crashes)
Remove OptiNotFine: it cannot be installed together with OptiRefine. Client only; a server does not need it.
## GPU compatibility
Tested on an NVIDIA GeForce RTX 5060. Other GPUs fall back step by step, without a config change; the log names the GPU and the path in use. Reports from AMD and Intel are very welcome: details in the repository (`docs/gpu-compatibility.md`).
## Known issues
- **Without Gambiarra, restart the game after turning a shader pack off.** With OptiRefine 78ff8ce, turning a shader pack on and then off in the same session leaves the terrain black (with holes) and the item in the hand invisible until the game restarts. The cause is OptiRefine's (it swaps the data array of the dynamic textures made before shaders, such as the lightmap, and the game keeps writing the old one); Gambiarra 1.0.0 fixes it.
## Known limitations
- **OptiRefine v0.1.0-alpha is not compatible with Nothirium yet:** two new injectors of that release target methods Nothirium (`BufferBuilder.sortVertexData`) and VintageFix (`DefaultResourcePack.resourceExists`) replace, and the game stops at start, with or without Gadolinium. Reported to OptiRefine: https://github.com/Ecdcaeb/OptiRefine/issues/8. Use the `78ff8ce` build attached to Gadolinium's v1.0.0 release.
- Only acts with the exact versions above; otherwise it turns itself off and says so in the log.
- Tested with the shader packs Mellow v3.4.1 and Sildur's Vibrant v2.02 Extreme. A program that cannot be adapted is drawn chunk by chunk.
- Anisotropic filtering above 1 makes water blue and opaque with Nothirium (with or without this mod).
- Only tested on Cleanroom, never on plain Forge.
## Configuration
`config/gadolinium.cfg`. Every part has its own option. If something looks wrong, turn that part off and send `logs/latest.log` and `logs/gadolinium-diagnostics.txt`.
## License and credits
By Dragonborne. LGPL-3.0. The per-direction face culling is derived from [Aetherium Backport](https://github.com/entitybrian69-bit/aetherium) (LGPL-3.0); the entity rendering mixin adapts [OptiRefine](https://github.com/Ecdcaeb/OptiRefine)'s (MIT). [Embeddium](https://github.com/FiniteReality/embeddium) was read as a reference; no code was taken. Full notices in the jar's `NOTICE`.
Source code and issues: https://github.com/snwxMR/gadolinium-gambiarra