Interface ShaderPreProcessor.Context

Enclosing interface:
ShaderPreProcessor

public static interface ShaderPreProcessor.Context
Context for modifying source code and shader behavior.
  • Method Details

    • modify

      String modify(@Nullable @Nullable net.minecraft.resources.ResourceLocation name, String source) throws IOException
      Runs the specified source through the entire processing list.
      Parameters:
      name - The name of the shader file to modify or null if the source is a raw string
      source - The shader source code to modify
      Returns:
      The modified source
      Throws:
      IOException - If any error occurs while editing the source
    • addUniformBinding

      void addUniformBinding(String name, int binding)
      Sets the uniform binding for a shader.
      Parameters:
      name - The name of the uniform
      binding - The binding to set it to
    • addDefinitionDependency

      void addDefinitionDependency(String name)
      Marks this shader as dependent on the specified pre-definition. When definitions change, only shaders marked as dependent on that definition will be recompiled.
      Parameters:
      name - The name of the definition to depend on
    • getName

      @Nullable @Nullable net.minecraft.resources.ResourceLocation getName()
      Returns:
      The id of the shader being compiled or null if the shader is compiled from a raw string
    • getInput

      String getInput()
      Returns:
      The input source code. This is GLSL
    • getType

      int getType()
      Returns:
      The OpenGL type of the shader being compiled
    • getConverter

      net.minecraft.resources.FileToIdConverter getConverter()
      Returns:
      The file to id converter for the loading shader file type
    • getTypeName

      default String getTypeName()
      Returns:
      The readable name of the loading shader file type
    • isSourceFile

      boolean isSourceFile()
      Returns:
      Whether the processor is being run for a source file and not an include file
    • getDefinition

      @Nullable @Nullable ProgramDefinition getDefinition()
      Returns:
      The definition of the program this is being compiled for or null if the shader is standalone
    • getPreDefinitions

      ShaderPreDefinitions getPreDefinitions()
      Returns:
      The set of pre-definitions for shaders