Class ShaderManager
java.lang.Object
foundry.veil.api.client.render.shader.ShaderManager
- All Implemented Interfaces:
Closeable
,AutoCloseable
,net.minecraft.server.packs.resources.PreparableReloadListener
public class ShaderManager
extends Object
implements net.minecraft.server.packs.resources.PreparableReloadListener, Closeable
Manages all shaders and compiles them automatically.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.minecraft.server.packs.resources.PreparableReloadListener
net.minecraft.server.packs.resources.PreparableReloadListener.PreparationBarrier
-
Field Summary
Modifier and TypeFieldDescriptionstatic final ShaderSourceSet
static final net.minecraft.resources.FileToIdConverter
static final ShaderSourceSet
-
Constructor Summary
ConstructorDescriptionShaderManager
(ShaderSourceSet sourceSet, ShaderPreDefinitions shaderPreDefinitions, DynamicBufferManger dynamicBufferManager) Creates a new shader manager. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
getName()
@Nullable ShaderProgram
getShader
(net.minecraft.resources.ResourceLocation id) Retrieves a shader by the specified id.Map
<net.minecraft.resources.ResourceLocation, ShaderProgram> static String
getTypeName
(int type) Retrieves a readable name for a shader type.reload
(net.minecraft.server.packs.resources.PreparableReloadListener.PreparationBarrier preparationBarrier, net.minecraft.server.packs.resources.ResourceManager resourceManager, net.minecraft.util.profiling.ProfilerFiller preparationsProfiler, net.minecraft.util.profiling.ProfilerFiller reloadProfiler, Executor backgroundExecutor, Executor gameExecutor) void
scheduleRecompile
(net.minecraft.resources.ResourceLocation shader) Schedules a shader recompilation on the next loop iteration.void
setActiveBuffers
(int activeBuffers) void
setGlobal
(Consumer<ShaderProgram> setter) Sets a global shader value.
-
Field Details
-
INCLUDE_LISTER
public static final net.minecraft.resources.FileToIdConverter INCLUDE_LISTER -
PROGRAM_SET
-
DEFERRED_SET
-
-
Constructor Details
-
ShaderManager
public ShaderManager(ShaderSourceSet sourceSet, ShaderPreDefinitions shaderPreDefinitions, DynamicBufferManger dynamicBufferManager) Creates a new shader manager.- Parameters:
sourceSet
- The source set to load all shaders fromshaderPreDefinitions
- The set of shader pre-definitionsdynamicBufferManager
- The manager for dynamic buffers
-
-
Method Details
-
setGlobal
Sets a global shader value.- Parameters:
setter
- The setter for shaders
-
getShader
Retrieves a shader by the specified id.- Parameters:
id
- The id of the shader to retrieve- Returns:
- The retrieved shader or
null
if there is no valid shader with that id
-
getShaders
- Returns:
- All shader programs registered
-
getSourceSet
- Returns:
- The source set all shaders are loaded from
-
scheduleRecompile
public void scheduleRecompile(net.minecraft.resources.ResourceLocation shader) Schedules a shader recompilation on the next loop iteration.- Parameters:
shader
- The shader to recompile
-
setActiveBuffers
@Internal public void setActiveBuffers(int activeBuffers) -
reload
public CompletableFuture<Void> reload(net.minecraft.server.packs.resources.PreparableReloadListener.PreparationBarrier preparationBarrier, net.minecraft.server.packs.resources.ResourceManager resourceManager, net.minecraft.util.profiling.ProfilerFiller preparationsProfiler, net.minecraft.util.profiling.ProfilerFiller reloadProfiler, Executor backgroundExecutor, Executor gameExecutor) - Specified by:
reload
in interfacenet.minecraft.server.packs.resources.PreparableReloadListener
-
getName
- Specified by:
getName
in interfacenet.minecraft.server.packs.resources.PreparableReloadListener
-
getReloadFuture
- Returns:
- The current future for full shader reload status
-
getRecompileFuture
- Returns:
- The current future for dirty shader recompilation status
-
getTypeName
Retrieves a readable name for a shader type. Supports all shader types instead of just vertex and fragment.- Parameters:
type
- The GL enum for the type- Returns:
- The readable name or a hex value if the type is unknown
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-