This page links to resources that will help you get started with programming your own shaders using the various pipelines available for Minecraft, with a focus on the Iris/OptiFine pipeline.
Background Knowledge
There are 3 general sets of background knowledge for shader development: linear algebra, GLSL, and the Iris/OptiFine rendering pipeline.
Linear algebra is useful for shader development because vector and matrix operations are very common in 3D graphics. 3Blue1Brown's YouTube series on the subject is a very good starting point.
GLSL is OpenGL's Shader Language. There are various different versions of the language. Minecraft 1.16 and earlier used #version 120
, but you are not restricted in which #version
you use - you can use anything your GPU/drivers support. Later versions will have more features available, and are recommended in most cases. The exception to this rule is macOS; it only supports version #version 120
on 1.16 and earlier, and up to #version 410
on 1.17 and later. A reasonable bet is that `#version 330` runs on almost all modern hardware.
Iris and Optifine both use the same pipeline, however Iris has significantly more features than Optifine. Most Optifine packs should run on Iris, however a pack compatible with Iris may not be compatible with Optifine.
Official Documentation
- The Iris Documentation is a good starting point, as it also contains a beginner tutorial, and is valid for both Iris and Optifine.
- Optifine's documentation is also available, however it is less comprehensive.
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
- Template packs for #version 120 , #version 150, and #version 330. These include most of the basic files without adding any extra effects, making them very easy to edit.
- Explanation and example code for shadows.
- Alternate version of OptiFine's documentation which looks nicer than the version on GitHub.
- Overview of OptiFine's pipeline, available programs and stages, varyings, and buffers.
- LearnOpenGL and LightHouse3D cover the basics of setting up rendering and lighting in OpenGL. Note that these tutorials are not specific to Minecraft, and any CPU side code or choice of uniform/buffer names is not relevant.
- Fragment Foundry is a hands-on tutorial that tests your skills as you read. It is also not specific to Minecraft.
- ShaderToy is a GLSL sandbox that works in your browser, and is kind of similar to a composite pass. It has a vast library of shaders developed by the community.
Vanilla Shaders
Vanilla shaders are created as part of a resource pack and do not require any mods to work, however they are much more limited than Iris/Optifine shaders.
Canvas
Canvas is a mod which allows custom shaders to be applied to different models in Minecraft. This functionality allows for the development of shaderpacks.