Interface ShaderProgram
- All Superinterfaces:
AutoCloseable,MutableShaderUniformAccess,org.lwjgl.system.NativeResource,ShaderUniformAccess,UniformAccess
- All Known Implementing Classes:
ShaderProgramImpl
Represents a usable shader program with shaders attached.
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidbind()Binds this program for use.voidcompile(ShaderCompiler.Context context, ShaderCompiler compiler) Compiles this shader based on the specified definition.static ShaderProgramcreate(net.minecraft.resources.ResourceLocation id) Creates a new shader program with the specified id.net.minecraft.resources.ResourceLocationgetId()default voidsetup()Binds this program for use and prepares for rendering.net.minecraft.client.renderer.ShaderInstanceWraps this shader with a vanilla Minecraft shader instance wrapper.static voidunbind()Unbinds the currently bound shader program.Methods inherited from interface foundry.veil.render.shader.program.MutableShaderUniformAccess
addRenderSystemTextures, addSampler, applyRenderSystem, applyShaderSamplers, applyShaderSamplers, clearSamplers, removeSampler, setFloat, setFloats, setFramebufferSamplers, setInt, setInts, setMatrix, setMatrix, setMatrix, setMatrix, setMatrix, setUniformBlock, setVector, setVector, setVector, setVectorI, setVectorI, setVectorI, setVectors, setVectors, setVectors, setVectors, setVectors, setVectorsMethods inherited from interface org.lwjgl.system.NativeResource
close, freeMethods inherited from interface foundry.veil.render.shader.program.ShaderUniformAccess
getFloat, getFloats, getInt, getInts, getMatrix, getMatrix, getMatrix, getMatrix, getMatrix, getProgram, getUniform, getUniformBlock, getVector, getVector, getVector, getVector, getVector, getVectorMethods inherited from interface foundry.veil.render.shader.program.UniformAccess
setVector, setVector, setVector, setVectorI, setVectorI, setVectorI
-
Method Details
-
setup
default void setup()Binds this program for use and prepares for rendering. -
bind
default void bind()Binds this program for use. -
unbind
static void unbind()Unbinds the currently bound shader program. -
compile
Compiles this shader based on the specified definition.- Parameters:
context- The context to use when compiling shaderscompiler- The compiler to use- Throws:
Exception- If an error occurs while compiling or linking shaders
-
getShaders
Set<CompiledShader> getShaders()- Returns:
- The shaders attached to this program
-
getDefinitionDependencies
- Returns:
- All shader definitions this program depends on
-
getId
net.minecraft.resources.ResourceLocation getId()- Returns:
- The id of this program
-
toShaderInstance
net.minecraft.client.renderer.ShaderInstance toShaderInstance()Wraps this shader with a vanilla Minecraft shader instance wrapper. There are a few special properties about the shader wrapper.
- The shader instance cannot be used to free the shader program.
NativeResource.free()must be called separately. If the shader is loaded throughShaderManagerthen there is no need to free the shader. - Calling
Uniform.upload()will do nothing since the values are uploaded when the appropriate methods are called - Uniforms are lazily wrapped and will not crash when the wrong method is called.
Uniform.set(int, float)is not supported and will throw anUnsupportedOperationException.- Only
Uniform.set(Matrix3f)andUniform.set(Matrix4f)will be able to set matrix values. All other matrix methods will throw anUnsupportedOperationException. Uniform.set(float[])only works for 1, 2, 3, and 4 float elements. Any other size will throw anUnsupportedOperationException.
- Returns:
- A lazily loaded shader instance wrapper for this program
- The shader instance cannot be used to free the shader program.
-
create
Creates a new shader program with the specified id.- Parameters:
id- The id of the program- Returns:
- A new shader program
-