Ever wondered how Optifine Shaders renders Minecraft? Want to know what all those gbuffers files do, and why they're different from the composite files? Need to figure out what exactly gbuffers_entities affects?
You've come to the right place. This page documents the Optifine Shaders pipeline, also known as Legacy Mode in Nova. Here we'll walk you through how Minecraft becomes an image on your screen.
The inspiration for this page, along with many of the images in it, came from the BSL Shaders Breakdown, which documents the BSL shaders.
Legacy Mode divides rendering into a few specific steps:
- Render the shadowmap
- Render opaque gbuffer shaders
- Render transparent gbuffer shaders
- Render composite shaders
- Render the final shaders
- Render the GUI
Let's explain them a little:
Above is the shadowmap, as rendered by BSL Shaders. A shadowmap tells you how far it is from the shadow casting light to the closest bit of geometry. You can see some variation in this shadowmap - the left side is darker than the right side, and a couple dark patches are present on the right side. In a shadowmap, lighter values mean that things are farther away from the light, while darker values mean that things are closer. The dark patches in this shadowmap are structures that were build to illustrate various effects (you'll see them in a little bit).
Legacy Mode implements a deferred rendering pipeline. The basics of deferred rendering is that you copy material parameters to an intermediate framebuffer when you draw geometry, then run a few shaders on the entire screen to calculate lighting. There's a lot more to it than that, so you should definitely ask Google about it, but that's the basics.
The intermediate framebuffer is often referred to as the Geometry Buffer, or gbuffer (GEE-buffer) for short. All the shaders that start with "gubffers_" will write to the gbuffer, and they're all run before any of the composite shaders
The composite passes are fullscreen passes rendered in numeric order. First is composite, then composite1, then composite2, etc. Legacy Mode supports up to 8 composite shaders. These are frequently used to render lighting, shadows, bloom, reflections, clouds, and other effects. In most shaders, the majority of the interesting work happens in the composite shaders (POM being a notable exception).