Getting Started

From shaderLABS

This page will link to resources that will help you get started with programming your own shaders using the various pipelines currently in use in Minecraft, with a focus on the Optifine pipeline.

Background Knowledge

There are 3 general sets of background knowledge for shader development: linear algebra, GLSL, and OptiFine's rendering pipeline.

Linear algebra is useful for shader development because vector and matrix operations are very common in shaders (and 3D graphics in general). 3blue1brown on YouTube has a decent series on this here.

GLSL is OpenGL's Shader Language. There are quite a few tutorials for this on the internet, but Minecraft in particular uses an old OpenGL version, so it might be useful to try to find an equally old GLSL tutorial. Anything that says #version 120 will be best. Minecraft 1.17 will use #version 150, but you are not restricted to just these specific #version's. You can use any #version that your GPU/drivers support.

OptiFine's rendering pipeline has a bit of documentation the doc folder. In particular, look at shaders.txt and shaders.properties. This documentation can also be found inside the OptiFine.jar file you downloaded.

Once you have all that down, there are 2 common ways to start putting your skills into practice: edit someone else's pack, or make your own from scratch. You will learn different skills from both of these practices, so it is recommended to try both of them at least once, but start with whichever one you're more comfortable with.

3rd-party tutorials and useful resources for shader development

Alternate version of OptiFine's doc folder which looks nicer than the version on github.

Overview of OptiFine's pipeline, available programs and stages, varyings, and buffers.

Overview of how Minecraft renders things, buffers, and some example effects (with code, pictures, and explanations).

Explanation and example code for shadows.

Template pack which includes most of the basic files, but none of them actually do anything. This makes it very easy to edit.

Information1 on vanilla2 shaders3 (not OptiFine).4

Information on canvas shaders (also not OptiFine).

These1 two2 tutorials include OpenGL code too, but you do not need to learn OpenGL for shaders. Just GLSL. They are also not specifically about Minecraft.

Hands-on tutorial that tests your skills as you read. Still not specifically about Minecraft.

GLSL sandbox that works in your browser. Kind of similar to a composite pass. Contains example code from MANY people.