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.
Shaders can be recompiled using recompile(ResourceLocation, ResourceProvider) or
recompile(ResourceLocation, ResourceProvider, ShaderCompiler) to use a custom compiler.
- 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
FieldsModifier and TypeFieldDescriptionstatic final ShaderSourceSetstatic final net.minecraft.resources.FileToIdConverterstatic final ShaderSourceSet -
Constructor Summary
ConstructorsConstructorDescriptionShaderManager(ShaderSourceSet sourceSet, ShaderPreDefinitions shaderPreDefinitions) Creates a new shader manager. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()getName()@Nullable ShaderProgramgetShader(net.minecraft.resources.ResourceLocation id) Retrieves a shader by the specified id.Map<net.minecraft.resources.ResourceLocation, ShaderProgram> static StringgetTypeName(int type) Retrieves a readable name for a shader type.voidrecompile(net.minecraft.resources.ResourceLocation id, net.minecraft.server.packs.resources.ResourceProvider provider) Attempts to recompile the shader with the specified id.voidrecompile(net.minecraft.resources.ResourceLocation id, net.minecraft.server.packs.resources.ResourceProvider provider, ShaderCompiler compiler) Attempts to recompile the shader with the specified id.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) reload(net.minecraft.server.packs.resources.ResourceManager resourceManager, Executor backgroundExecutor, Executor gameExecutor) Recompiles all shaders in the background.voidscheduleRecompile(net.minecraft.resources.ResourceLocation shader) Schedules a shader recompilation on the next loop iteration.voidsetGlobal(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
Creates a new shader manager.- Parameters:
sourceSet- The source set to load all shaders fromshaderPreDefinitions- The set of shader pre-definitions
-
-
Method Details
-
recompile
public void recompile(net.minecraft.resources.ResourceLocation id, net.minecraft.server.packs.resources.ResourceProvider provider) Attempts to recompile the shader with the specified id.- Parameters:
id- The id of the shader to recompileprovider- The source of resources
-
recompile
public void recompile(net.minecraft.resources.ResourceLocation id, net.minecraft.server.packs.resources.ResourceProvider provider, ShaderCompiler compiler) Attempts to recompile the shader with the specified id.- Parameters:
id- The id of the shader to recompileprovider- The source of resourcescompiler- The compiler instance to use. If unsure, userecompile(ResourceLocation, ResourceProvider)
-
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
nullif 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
-
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:
reloadin interfacenet.minecraft.server.packs.resources.PreparableReloadListener
-
getName
- Specified by:
getNamein interfacenet.minecraft.server.packs.resources.PreparableReloadListener
-
reload
public CompletableFuture<Void> reload(net.minecraft.server.packs.resources.ResourceManager resourceManager, Executor backgroundExecutor, Executor gameExecutor) Recompiles all shaders in the background.- Parameters:
resourceManager- The manager for resources. Shader files and definitions are loaded from this managerbackgroundExecutor- The executor for preparation tasksgameExecutor- The executor for applying the shaders- Returns:
- A future representing when shader compilation will be done
-
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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-