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:
  • Field Details

    • INCLUDE_LISTER

      public static final net.minecraft.resources.FileToIdConverter INCLUDE_LISTER
    • PROGRAM_SET

      public static final ShaderSourceSet PROGRAM_SET
    • DEFERRED_SET

      public static final ShaderSourceSet 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 from
      shaderPreDefinitions - The set of shader pre-definitions
      dynamicBufferManager - The manager for dynamic buffers
  • Method Details

    • setGlobal

      public void setGlobal(Consumer<ShaderProgram> setter)
      Sets a global shader value.
      Parameters:
      setter - The setter for shaders
    • getShader

      @Nullable public @Nullable ShaderProgram getShader(net.minecraft.resources.ResourceLocation id)
      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

      public Map<net.minecraft.resources.ResourceLocation,ShaderProgram> getShaders()
      Returns:
      All shader programs registered
    • getSourceSet

      public ShaderSourceSet 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 interface net.minecraft.server.packs.resources.PreparableReloadListener
    • getName

      public String getName()
      Specified by:
      getName in interface net.minecraft.server.packs.resources.PreparableReloadListener
    • getReloadFuture

      public CompletableFuture<Void> getReloadFuture()
      Returns:
      The current future for full shader reload status
    • getRecompileFuture

      public CompletableFuture<Void> getRecompileFuture()
      Returns:
      The current future for dirty shader recompilation status
    • getTypeName

      public static String getTypeName(int type)
      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 interface AutoCloseable
      Specified by:
      close in interface Closeable