Interface ManagedShaderEffect

All Superinterfaces:
UniformFinder
All Known Implementing Classes:
ResettableManagedShaderEffect

public interface ManagedShaderEffect extends UniformFinder
A post processing shader that is applied to the main render target

Post shaders loaded through ShaderEffectManager.manage(ResourceLocation, Consumer) are self-managed and will be reloaded when shader assets are reloaded (through F3-T or /ladylib_shader_reload) or the screen resolution changes.

Examples of json-defined shader effects are available in assets/minecraft/shaders.

Since:
1.0.0
See Also:
  • Method Details

    • getShaderEffect

      @Nullable @API(status=MAINTAINED, since="1.0.0") @Nullable net.minecraft.client.renderer.PostChain getShaderEffect()
      Returns this object's managed PostChain, creating and initializing it if it doesn't exist.

      This method will return null if an error occurs during initialization.

      Note: calling this before the graphic context is ready will cause issues.

      Returns:
      the PostChain managed by this object
      See Also:
    • initialize

      @API(status=MAINTAINED, since="1.0.0") void initialize() throws IOException
      Initializes this shader, allocating required system resources such as render target objects, shaders objects and texture objects. Any exception thrown during initialization is relayed to the caller.

      If the shader is already initialized, previously allocated resources will be disposed of before initializing new ones.

      Throws:
      IOException
      See Also:
      ApiNote:
      Calling this method directly is not required in most cases.
    • isInitialized

      @API(status=MAINTAINED, since="1.0.0") boolean isInitialized()
      Checks whether this shader is initialized. If it is not, next call to getShaderEffect() will setup the shader group.
      Returns:
      true if this does not require initialization
      See Also:
    • isErrored

      @API(status=MAINTAINED, since="1.0.0") boolean isErrored()
      Returns:
      true if this shader erred during initialization
    • release

      @API(status=EXPERIMENTAL, since="1.0.0") void release()
      Releases this shader's resources.

      After this method is called, this shader will go back to its uninitialized state. Future calls to isInitialized() will return false until initialize() is called again, recreating the shader group.

      If the caller does not intend to use this shader effect again, they should call ShaderEffectManager.dispose(ManagedShaderEffect).

      See Also:
    • render

      @API(status=STABLE, since="1.0.0") void render(float tickDelta)
      Renders this shader.

      Calling this method first setups the graphic state for rendering, then uploads uniforms to the GPU if they have been changed since last draw, draws the main render target's texture to intermediate render targets as defined by the JSON files and resets part of the graphic state. The shader will be initialized if it has not been before.

      This method should be called every frame when the shader is active. Uniforms should be set before rendering.

    • getTarget

      @API(status=EXPERIMENTAL, since="1.4.0") ManagedRenderTarget getTarget(String name)
    • setupDynamicUniforms

      @API(status=EXPERIMENTAL, since="1.0.0") void setupDynamicUniforms(Runnable dynamicSetBlock)
      Forwards to setupDynamicUniforms(int, Runnable) with an index of 0
      Parameters:
      dynamicSetBlock - a block in which dynamic uniforms are set
    • setupDynamicUniforms

      @API(status=EXPERIMENTAL, since="1.0.0") void setupDynamicUniforms(int index, Runnable dynamicSetBlock)
      Runs the given block while the shader at the given index is active
      Parameters:
      index - the shader index within the group
      dynamicSetBlock - a block in which dynamic name uniforms are set
    • setUniformValue

      @API(status=STABLE, since="1.0.0") void setUniformValue(String uniformName, int value)
      Sets the value of a uniform declared in json
      Parameters:
      uniformName - the name of the uniform field in the shader source file
      value - int value
      See Also:
    • setUniformValue

      @API(status=STABLE, since="1.0.0") void setUniformValue(String uniformName, int value0, int value1)
      Sets the value of a uniform declared in json
      Parameters:
      uniformName - the name of the uniform field in the shader source file
      value0 - int value
      value1 - int value
      See Also:
    • setUniformValue

      @API(status=STABLE, since="1.0.0") void setUniformValue(String uniformName, int value0, int value1, int value2)
      Sets the value of a uniform declared in json
      Parameters:
      uniformName - the name of the uniform field in the shader source file
      value0 - int value
      value1 - int value
      value2 - int value
      See Also:
    • setUniformValue

      @API(status=STABLE, since="1.0.0") void setUniformValue(String uniformName, int value0, int value1, int value2, int value3)
      Sets the value of a uniform declared in json
      Parameters:
      uniformName - the name of the uniform field in the shader source file
      value0 - int value
      value1 - int value
      value2 - int value
      value3 - int value
      See Also:
    • setUniformValue

      @API(status=STABLE, since="1.0.0") void setUniformValue(String uniformName, float value)
      Sets the value of a uniform declared in json
      Parameters:
      uniformName - the name of the uniform field in the shader source file
      value - float value
      See Also:
    • setUniformValue

      @API(status=STABLE, since="1.0.0") void setUniformValue(String uniformName, float value0, float value1)
      Sets the value of a uniform declared in json
      Parameters:
      uniformName - the name of the uniform field in the shader source file
      value0 - float value
      value1 - float value
      See Also:
    • setUniformValue

      @API(status=STABLE, since="1.0.0") void setUniformValue(String uniformName, float value0, float value1, float value2)
      Sets the value of a uniform declared in json
      Parameters:
      uniformName - the name of the uniform field in the shader source file
      value0 - float value
      value1 - float value
      value2 - float value
      See Also:
    • setUniformValue

      @API(status=STABLE, since="1.0.0") void setUniformValue(String uniformName, float value0, float value1, float value2, float value3)
      Sets the value of a uniform declared in json
      Parameters:
      uniformName - the name of the uniform field in the shader source file
      value0 - float value
      value1 - float value
      value2 - float value
      value3 - float value
      See Also:
    • setUniformValue

      @API(status=STABLE, since="1.0.0") void setUniformValue(String uniformName, org.joml.Matrix4f value)
      Sets the value of a uniform declared in json
      Parameters:
      uniformName - the name of the uniform field in the shader source file
      value - a matrix
      See Also:
    • setSamplerUniform

      @API(status=STABLE, since="1.0.0") void setSamplerUniform(String samplerName, net.minecraft.client.renderer.texture.AbstractTexture texture)
      Sets the value of a sampler uniform declared in json
      Parameters:
      samplerName - the name of the sampler uniform field in the shader source file and json
      texture - a texture object
      See Also:
    • setSamplerUniform

      @API(status=STABLE, since="1.0.0") void setSamplerUniform(String samplerName, com.mojang.blaze3d.pipeline.RenderTarget textureFbo)
      Sets the value of a sampler uniform declared in json
      Parameters:
      samplerName - the name of the sampler uniform field in the shader source file and json
      textureFbo - a render target which main texture will be used
      See Also:
    • setSamplerUniform

      @API(status=STABLE, since="1.0.0") void setSamplerUniform(String samplerName, int textureName)
      Sets the value of a sampler uniform declared in json
      Parameters:
      samplerName - the name of the sampler uniform field in the shader source file and json
      textureName - an opengl texture name
      See Also:
    • findSampler

      SamplerUniformV2 findSampler(String samplerName)
      Description copied from interface: UniformFinder
      Finds a sampler declared in json
      Specified by:
      findSampler in interface UniformFinder
      Parameters:
      samplerName - the name of the sampler field in the shader source file