Class ShaderModification

java.lang.Object
com.hbm_m.client.render.shader.modification.ShaderModification

public final class ShaderModification extends Object
Lightweight GLSL source modifier inspired by Veil's ShaderModification system, but reimplemented from scratch (no glslprocessor dependency).

Supports:

  • Injection of #define KEY [VALUE] directives right after the #version line.
  • Insertion of arbitrary GLSL text before/after a regex marker.
  • Replacement of a regex match.

This class is intentionally small and synchronous; it is meant to be used at shader registration / load time, not during rendering. It also serves as a foundation for future Iris TransformPatcher integration (Variant B).

  • Method Details

    • builder

      public static ShaderModification builder()
    • define

      public ShaderModification define(String key, String value)
      Adds a #define KEY VALUE directive to be injected after the #version line. If value is null or empty, only #define KEY is emitted.
    • define

      public ShaderModification define(String key)
      Convenience: emit #define KEY.
    • insertAfter

      public ShaderModification insertAfter(String markerRegex, String inject)
      Inserts arbitrary text after the first match of markerRegex. If the marker is not found the source is returned unchanged (a debug log is emitted).
    • insertBefore

      public ShaderModification insertBefore(String markerRegex, String inject)
      Inserts arbitrary text before the first match of markerRegex.
    • replace

      public ShaderModification replace(String regex, String replacement)
      Replaces every match of regex with replacement.
    • apply

      public String apply(String source)
      Applies all steps to source and returns the modified text.