Class ShaderPreDefinitions

java.lang.Object
foundry.veil.api.client.render.shader.definition.ShaderPreDefinitions

public class ShaderPreDefinitions extends Object

Manages pre-defined variables and data in java that can be applied to shaders.

Regular definitions are added with set(String) and set(String, String). These schedule a shader recompilation every time they are set so shaders can remain up-to-date.

  • Constructor Details

    • ShaderPreDefinitions

      public ShaderPreDefinitions()
      Creates a new set of predefinitions.
  • Method Details

    • addListener

      public void addListener(Consumer<String> definitionCallback)
      Adds a listener for when a change happens.
      Parameters:
      definitionCallback - The callback for when definitions change or null to ignore changes
    • set

      public void set(String name)
      Sets the value of a definition pair. If the value has changed, all shaders depending on it will recompile.
      Parameters:
      name - The name of the definition to set
    • set

      public void set(String name, String value)
      Sets the value of a definition pair. If the value has changed, all shaders depending on it will recompile.
      Parameters:
      name - The name of the definition to set
      value - The value to associate with it
    • setStatic

      public void setStatic(String name)
      Sets a definition added to all shaders. These should be treated as static final variables.
      Parameters:
      name - The name of the definition to set
    • setStatic

      public void setStatic(String name, @Nullable @Nullable String value)
      Sets a definition added to all shaders. These should be treated as static final variables.
      Parameters:
      name - The name of the definition to set
      value - The value to associate with it
    • remove

      public void remove(String name)
      Removes the definition with the specified name.
      Parameters:
      name - The name of the definition to remove
    • getDefinition

      @Nullable public @Nullable String getDefinition(String name)
      Retrieves a definition by name.
      Parameters:
      name - The name of the definition
      Returns:
      The definition with that name or null if it doesn't exist
    • getDefinitions

      public Map<String,String> getDefinitions()
      Returns:
      A view of all definitions
    • getStaticDefinitions

      public Map<String,String> getStaticDefinitions()
      Returns:
      A view of all static definitions