Skip to content

ShaderTexture

The ShaderTexture class extends TransformTexture to render textures using custom shaders. It supports dynamic shader updates, setting uniform values, and binding textures for advanced visual effects. The class provides methods for creating shader-based textures from resource locations or raw shader code, along with caching and disposal mechanisms.

IMPORTANT!!!

If you are using raw shader, DO NOT forget to release the texture after using.

Basic Properties

Field Description
location The resource location of the shader
resolution The shader resolution factor (affects the iResolution uniform)
color Color overlay applied to the shader texture

APIs

dispose

Dispose shader.

shaderTexture.dispose();

updateShader

Updates the shader using a new resource location.

shaderTexture.updateShader(new ResourceLocation("modid:shader"));

updateRawShader

Updates the shader using raw shader code.

shaderTexture.updateRawShader("raw shader code");

setUniformCache

Sets a uniform cache consumer to update additional shader uniforms.

shaderTexture.setUniformCache(cache -> {
    // Update additional uniforms as needed
});

setResolution

Sets the resolution factor used in the shader.

shaderTexture.setResolution(2.5f);