Shader packs: define MC_NORMAL_MAP and MC_SPECULAR_MAP

OptiFine defines both when its normal and specular map options are on (its
default), and Iris 1.11.7 defines both too (observed with a probe pack of our
own: its final pass paints one stripe per macro). Horizon defined neither, so
packs took their no-normal-map branches; Bliss declares FlatNormals only in
the other branch and its terrain, block and entity programs failed with
"Unknown variable: FlatNormals".

Fixes #6811

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Arslan ArmanulyandClaude Opus 5.5 committed 2026-11-02 11:45:50 +05:00
1 parent 5197790e58
commit 4b4db8c36d
1 file changed
+30
+30
View File
@@ -99,6 +99,10 @@ impl Macros {
m.define("MC_SHADOW_QUALITY", "1.0");
m.define("MC_HAND_DEPTH", "0.125");
m.define("MAX_COLOR_BUFFERS", "16");
// The normal and specular maps are on (OptiFine's shaders.txt, H: their options, on by
// default; Iris 1.11.7 defines both too, with or without a resource pack's maps).
m.define("MC_NORMAL_MAP", "");
m.define("MC_SPECULAR_MAP", "");
// Packs take Iris's extensions (compute programs, images, custom textures) where this
// is defined.
m.define("IS_IRIS", "");
@@ -329,6 +333,32 @@ pub(crate) fn is_ident(c: char) -> bool {
mod tests {
use super::*;
/// Packs take their normal- and specular-map branches, as they do with the maps on: a
/// declaration made only there is seen.
#[test]
fn programs_take_the_normal_and_specular_map_branches() {
let fsh = "#version 330\nout vec4 c;\n\
#ifdef MC_NORMAL_MAP\nconst float bump = 1.0;\n#endif\n\
#ifdef MC_SPECULAR_MAP\nconst float shine = 2.0;\n#endif\n\
void main() { c = vec4(bump, shine, 0.0, 1.0); }\n";
let vsh = "#version 330\nvoid main() { gl_Position = vec4(0.0); }\n";
let pack = crate::Pack::from_zip_bytes(
"P.zip",
crate::pack::tests::zip(&[
("shaders/composite.vsh", vsh),
("shaders/composite.fsh", fsh),
]),
)
.unwrap();
let m = Macros::standard();
let program = crate::translate_composite(
&crate::preprocess(&pack, "composite.vsh", &m),
&crate::preprocess(&pack, "composite.fsh", &m),
crate::Target::Buffers,
);
assert!(program.is_ok(), "{:?}", program.err());
}
#[test]
fn iris_features_are_defined_or_noted() {
let properties = crate::Properties::parse(