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
FieldsModifier and TypeFieldDescriptionstatic final net.minecraft.resources.FileToIdConverterstatic final ShaderSourceSet -
Constructor Summary
ConstructorsConstructorDescriptionShaderManager(ShaderSourceSet sourceSet, ShaderPreDefinitions shaderPreDefinitions, DynamicBufferManager dynamicBufferManager) Creates a new shader manager. -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidclose()createDynamicProgram(net.minecraft.resources.ResourceLocation id, it.unimi.dsi.fastutil.ints.Int2ObjectMap<String> shaderSources) Creates a new dynamic shader with the specified shader sources.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.booleanhasFeatures(ShaderFeature... features) Checks if the requested shader features are available.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) voidscheduleRecompile(net.minecraft.resources.ResourceLocation shader) Schedules a shader recompilation on the next loop iteration.voidsetActiveBuffers(int activeBuffers) voidsetGlobal(Consumer<ShaderProgram> setter) Sets a global shader value.
-
Field Details
-
INCLUDE_LISTER
public static final net.minecraft.resources.FileToIdConverter INCLUDE_LISTER -
PROGRAM_SET
-
-
Constructor Details
-
ShaderManager
public ShaderManager(ShaderSourceSet sourceSet, ShaderPreDefinitions shaderPreDefinitions, DynamicBufferManager 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
-
createDynamicProgram
public CompletableFuture<ShaderProgram> createDynamicProgram(net.minecraft.resources.ResourceLocation id, it.unimi.dsi.fastutil.ints.Int2ObjectMap<String> shaderSources) Creates a new dynamic shader with the specified shader sources.- Parameters:
id- The internal ID of the shadershaderSources- A map of all shader sources from GL shader enum values to GLSL source code- Returns:
- A future for when the shader is done compiling
-
setGlobal
Sets a global shader value.- Parameters:
setter- The setter for shaders
-
hasFeatures
Checks if the requested shader features are available.- Parameters:
features- The features to check for- Returns:
- Whether those features are supported
- Since:
- 2.0.0
-
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
-
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:
reloadin interfacenet.minecraft.server.packs.resources.PreparableReloadListener
-
getName
- Specified by:
getNamein interfacenet.minecraft.server.packs.resources.PreparableReloadListener
-
getRecompileFuture
- Returns:
- The current future for dirty shader recompilation status
-
getUpdateBuffersFuture
- Returns:
- The current future for updating dynamic buffers
-
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
-
addMacros
-