Class ShaderPreDefinitions
java.lang.Object
foundry.veil.api.client.render.shader.definition.ShaderPreDefinitions
Manages pre-defined variables and data in java that can be applied to shaders.
Regular definitions are added with define(String)
, define(String, String)
,
and set(String, String)
. These schedule a shader recompilation every time they are set
so shaders can remain up-to-date.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(Consumer<String> definitionCallback) Adds a listener for when a change happens.void
addStaticDefinitions
(Consumer<String> definitionConsumer) Adds definitions that never change during runtime.void
Sets the value of a definition pair.void
Sets the value of a definition pair.void
defineStatic
(String name) Sets a definition added to all shaders.void
defineStatic
(String name, @Nullable String definition) Sets a definition added to all shaders.@Nullable String
getDefinition
(String name) Retrieves a definition by name.void
Removes the definition with the specified name.void
Sets the value of a definition pair.void
Sets a definition added to all shaders.
-
Constructor Details
-
ShaderPreDefinitions
public ShaderPreDefinitions()Creates a new set of predefinitions.
-
-
Method Details
-
addListener
Adds a listener for when a change happens.- Parameters:
definitionCallback
- The callback for when definitions change ornull
to ignore changes
-
define
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
-
define
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 setdefinition
- The value to associate with it ornull
to only add#define name
-
set
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 setdefinition
- The value to associate with it
-
defineStatic
Sets a definition added to all shaders. These should be treated as static final variables.- Parameters:
name
- The name of the definition to set
-
defineStatic
Sets a definition added to all shaders. These should be treated as static final variables.- Parameters:
name
- The name of the definition to setdefinition
- The value to associate with it ornull
to only add#define name
-
setStatic
Sets a definition added to all shaders. These should be treated as static final variables.- Parameters:
name
- The name of the definition to setdefinition
- The value to associate with it
-
remove
Removes the definition with the specified name.- Parameters:
name
- The name of the definition to remove
-
addStaticDefinitions
Adds definitions that never change during runtime. This is for constants, like a debug flag.- Parameters:
definitionConsumer
- The consumer for definition lines
-
getDefinition
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
- Returns:
- A view of all definitions
-