Interface ShaderProgram
- All Superinterfaces:
AutoCloseable,MutableUniformAccess,org.lwjgl.system.NativeResource,TextureUniformAccess,UniformAccess
- All Known Implementing Classes:
ShaderProgramImpl
public interface ShaderProgram
extends org.lwjgl.system.NativeResource, MutableUniformAccess, TextureUniformAccess
Represents a usable shader program with shaders attached.
-
Nested Class Summary
Nested classes/interfaces inherited from interface foundry.veil.api.client.render.shader.program.TextureUniformAccess
TextureUniformAccess.SamplerListener -
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.@Nullable ProgramDefinitiondefault floatgetFloat(CharSequence name) Retrieves a single float by the specified name.default voidgetFloats(CharSequence name, float[] values) Retrieves an array of floats by the specified name.net.minecraft.resources.ResourceLocationgetId()default intgetInt(CharSequence name) Retrieves a single integer by the specified name.default voidgetInts(CharSequence name, int[] values) Retrieves an array of integers by the specified name.default voidgetMatrix(CharSequence name, org.joml.Matrix2f value) Retrieves a matrix2x2 by the specified namedefault voidgetMatrix(CharSequence name, org.joml.Matrix3f value) Retrieves a matrix3x3 by the specified namedefault voidgetMatrix(CharSequence name, org.joml.Matrix3x2f value) Retrieves a matrix3x2 by the specified namedefault voidgetMatrix(CharSequence name, org.joml.Matrix4f value) Retrieves a matrix4x4 by the specified namedefault voidgetMatrix(CharSequence name, org.joml.Matrix4x3f value) Retrieves a matrix4x3 by the specified nameintit.unimi.dsi.fastutil.ints.Int2ObjectMap<CompiledShader> default voidgetVector(CharSequence name, org.joml.Vector2f... values) Retrieves an array of vectors by the specified name.default voidgetVector(CharSequence name, org.joml.Vector2i... values) Retrieves an array of vectors by the specified name.default voidgetVector(CharSequence name, org.joml.Vector3f... values) Retrieves an array of vectors by the specified name.default voidgetVector(CharSequence name, org.joml.Vector3i... values) Retrieves an array of vectors by the specified name.default voidgetVector(CharSequence name, org.joml.Vector4f... values) Retrieves an array of vectors by the specified name.default voidgetVector(CharSequence name, org.joml.Vector4i... values) Retrieves an array of vectors by the specified name.default booleandefault booleandefault booleandefault voidsetFloat(CharSequence name, float value) Sets a float in the shader.default voidsetFloats(CharSequence name, float... values) Sets an array of floats in the shader.default voidsetInt(CharSequence name, int value) Sets an integer in the shader.default voidsetInts(CharSequence name, int... values) Sets an array of integers in the shader.default voidsetMatrix(CharSequence name, org.joml.Matrix2fc value) Sets a matrix in the shader.default voidsetMatrix(CharSequence name, org.joml.Matrix3fc value) Sets a matrix in the shader.default voidsetMatrix(CharSequence name, org.joml.Matrix3x2fc value) Sets a matrix in the shader.default voidsetMatrix(CharSequence name, org.joml.Matrix4fc value) Sets a matrix in the shader.default voidsetMatrix(CharSequence name, org.joml.Matrix4x3fc value) Sets a matrix in the shader.default voidsetStorageBlock(CharSequence name, int binding) Sets the binding to use for the specified storage block.default voidsetUniformBlock(CharSequence name, int binding) Sets the binding to use for the specified uniform block.default voidsetup()Binds this program for use and prepares for rendering.default voidsetVector(CharSequence name, float x, float y) Sets a vector in the shader.default voidsetVector(CharSequence name, float x, float y, float z) Sets a vector in the shader.default voidsetVector(CharSequence name, float x, float y, float z, float w) Sets a vector in the shader.default voidsetVectorI(CharSequence name, int x, int y) Sets an integer vector in the shader.default voidsetVectorI(CharSequence name, int x, int y, int z) Sets an integer vector in the shader.default voidsetVectorI(CharSequence name, int x, int y, int z, int w) Sets an integer vector in the shader.default voidsetVectors(CharSequence name, org.joml.Vector2fc... values) Sets an array of vectors in the shader.default voidsetVectors(CharSequence name, org.joml.Vector2ic... values) Sets an array of integer vectors in the shader.default voidsetVectors(CharSequence name, org.joml.Vector3fc... values) Sets an array of vectors in the shader.default voidsetVectors(CharSequence name, org.joml.Vector3ic... values) Sets an array of integer vectors in the shader.default voidsetVectors(CharSequence name, org.joml.Vector4fc... values) Sets an array of vectors in the shader.default voidsetVectors(CharSequence name, org.joml.Vector4ic... values) Sets an array of integer vectors in the shader.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.api.client.render.shader.program.MutableUniformAccess
applyRenderSystem, setVector, setVector, setVector, setVector, setVectorI, setVectorI, setVectorIMethods inherited from interface org.lwjgl.system.NativeResource
close, freeMethods inherited from interface foundry.veil.api.client.render.shader.program.TextureUniformAccess
addRenderSystemTextures, addSampler, addSamplerListener, applyShaderSamplers, applyShaderSamplers, clearSamplers, removeSampler, removeSamplerListener, setFramebufferSamplersMethods inherited from interface foundry.veil.api.client.render.shader.program.UniformAccess
getStorageBlock, getUniform, getUniformBlock, hasStorageBlock, hasUniform, hasUniformBlock
-
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
void compile(ShaderCompiler.Context context, ShaderCompiler compiler) throws ShaderException, IOException Compiles this shader based on the specified definition.- Parameters:
context- The context to use when compiling shaderscompiler- The compiler to use- Throws:
IOException- If an error occurs while loading shadersShaderException- If an error occurs while compiling or linking shaders
-
getProgram
int getProgram()- Returns:
- The OpenGL id of this program
-
getFloat
Description copied from interface:UniformAccessRetrieves a single float by the specified name.- Specified by:
getFloatin interfaceUniformAccess- Parameters:
name- The name of the uniform to get- Returns:
- The float value of that uniform
-
getInt
Description copied from interface:UniformAccessRetrieves a single integer by the specified name.- Specified by:
getIntin interfaceUniformAccess- Parameters:
name- The name of the uniform to get- Returns:
- The int value of that uniform
-
getFloats
Description copied from interface:UniformAccessRetrieves an array of floats by the specified name.- Specified by:
getFloatsin interfaceUniformAccess- Parameters:
name- The name of the uniform to getvalues- The values to set
-
getVector
Description copied from interface:UniformAccessRetrieves an array of vectors by the specified name.- Specified by:
getVectorin interfaceUniformAccess- Parameters:
name- The name of the uniform to getvalues- The values to set
-
getVector
Description copied from interface:UniformAccessRetrieves an array of vectors by the specified name.- Specified by:
getVectorin interfaceUniformAccess- Parameters:
name- The name of the uniform to getvalues- The values to set
-
getVector
Description copied from interface:UniformAccessRetrieves an array of vectors by the specified name.- Specified by:
getVectorin interfaceUniformAccess- Parameters:
name- The name of the uniform to getvalues- The values to set
-
getInts
Description copied from interface:UniformAccessRetrieves an array of integers by the specified name.- Specified by:
getIntsin interfaceUniformAccess- Parameters:
name- The name of the uniform to getvalues- The values to set
-
getVector
Description copied from interface:UniformAccessRetrieves an array of vectors by the specified name.- Specified by:
getVectorin interfaceUniformAccess- Parameters:
name- The name of the uniform to getvalues- The values to set
-
getVector
Description copied from interface:UniformAccessRetrieves an array of vectors by the specified name.- Specified by:
getVectorin interfaceUniformAccess- Parameters:
name- The name of the uniform to getvalues- The values to set
-
getVector
Description copied from interface:UniformAccessRetrieves an array of vectors by the specified name.- Specified by:
getVectorin interfaceUniformAccess- Parameters:
name- The name of the uniform to getvalues- The values to set
-
getMatrix
Description copied from interface:UniformAccessRetrieves a matrix2x2 by the specified name- Specified by:
getMatrixin interfaceUniformAccess- Parameters:
name- The name of the uniform to getvalue- The value to set
-
getMatrix
Description copied from interface:UniformAccessRetrieves a matrix3x3 by the specified name- Specified by:
getMatrixin interfaceUniformAccess- Parameters:
name- The name of the uniform to getvalue- The value to set
-
getMatrix
Description copied from interface:UniformAccessRetrieves a matrix3x2 by the specified name- Specified by:
getMatrixin interfaceUniformAccess- Parameters:
name- The name of the uniform to getvalue- The value to set
-
getMatrix
Description copied from interface:UniformAccessRetrieves a matrix4x4 by the specified name- Specified by:
getMatrixin interfaceUniformAccess- Parameters:
name- The name of the uniform to getvalue- The value to set
-
getMatrix
Description copied from interface:UniformAccessRetrieves a matrix4x3 by the specified name- Specified by:
getMatrixin interfaceUniformAccess- Parameters:
name- The name of the uniform to getvalue- The value to set
-
setUniformBlock
Description copied from interface:MutableUniformAccessSets the binding to use for the specified uniform block.- Specified by:
setUniformBlockin interfaceMutableUniformAccess- Parameters:
name- The name of the block to setbinding- The binding to use for that block
-
setStorageBlock
Description copied from interface:MutableUniformAccessSets the binding to use for the specified storage block.- Specified by:
setStorageBlockin interfaceMutableUniformAccess- Parameters:
name- The name of the block to setbinding- The binding to use for that block
-
setFloat
Description copied from interface:MutableUniformAccessSets a float in the shader.- Specified by:
setFloatin interfaceMutableUniformAccess- Parameters:
name- The name of the uniform to setvalue- The value to set
-
setVector
Description copied from interface:MutableUniformAccessSets a vector in the shader.- Specified by:
setVectorin interfaceMutableUniformAccess- Parameters:
name- The name of the uniform to setx- The x component of the vectory- The y component of the vector
-
setVector
Description copied from interface:MutableUniformAccessSets a vector in the shader.- Specified by:
setVectorin interfaceMutableUniformAccess- Parameters:
name- The name of the uniform to setx- The x component of the vectory- The y component of the vectorz- The z component of the vector
-
setVector
Description copied from interface:MutableUniformAccessSets a vector in the shader.- Specified by:
setVectorin interfaceMutableUniformAccess- Parameters:
name- The name of the uniform to setx- The x component of the vectory- The y component of the vectorz- The z component of the vectorw- The w component of the vector
-
setInt
Description copied from interface:MutableUniformAccessSets an integer in the shader.- Specified by:
setIntin interfaceMutableUniformAccess- Parameters:
name- The name of the uniform to setvalue- The value to set
-
setVectorI
Description copied from interface:MutableUniformAccessSets an integer vector in the shader.- Specified by:
setVectorIin interfaceMutableUniformAccess- Parameters:
name- The name of the uniform to setx- The x component of the vectory- The y component of the vector
-
setVectorI
Description copied from interface:MutableUniformAccessSets an integer vector in the shader.- Specified by:
setVectorIin interfaceMutableUniformAccess- Parameters:
name- The name of the uniform to setx- The x component of the vectory- The y component of the vectorz- The z component of the vector
-
setVectorI
Description copied from interface:MutableUniformAccessSets an integer vector in the shader.- Specified by:
setVectorIin interfaceMutableUniformAccess- Parameters:
name- The name of the uniform to setx- The x component of the vectory- The y component of the vectorz- The z component of the vectorw- The w component of the vector
-
setFloats
Description copied from interface:MutableUniformAccessSets an array of floats in the shader.- Specified by:
setFloatsin interfaceMutableUniformAccess- Parameters:
name- The name of the uniform to setvalues- The values to set in order
-
setVectors
Description copied from interface:MutableUniformAccessSets an array of vectors in the shader.- Specified by:
setVectorsin interfaceMutableUniformAccess- Parameters:
name- The name of the uniform to setvalues- The values to set in order
-
setVectors
Description copied from interface:MutableUniformAccessSets an array of vectors in the shader.- Specified by:
setVectorsin interfaceMutableUniformAccess- Parameters:
name- The name of the uniform to setvalues- The values to set in order
-
setVectors
Description copied from interface:MutableUniformAccessSets an array of vectors in the shader.- Specified by:
setVectorsin interfaceMutableUniformAccess- Parameters:
name- The name of the uniform to setvalues- The values to set in order
-
setInts
Description copied from interface:MutableUniformAccessSets an array of integers in the shader.- Specified by:
setIntsin interfaceMutableUniformAccess- Parameters:
name- The name of the uniform to setvalues- The values to set in order
-
setVectors
Description copied from interface:MutableUniformAccessSets an array of integer vectors in the shader.- Specified by:
setVectorsin interfaceMutableUniformAccess- Parameters:
name- The name of the uniform to setvalues- The values to set in order
-
setVectors
Description copied from interface:MutableUniformAccessSets an array of integer vectors in the shader.- Specified by:
setVectorsin interfaceMutableUniformAccess- Parameters:
name- The name of the uniform to setvalues- The values to set in order
-
setVectors
Description copied from interface:MutableUniformAccessSets an array of integer vectors in the shader.- Specified by:
setVectorsin interfaceMutableUniformAccess- Parameters:
name- The name of the uniform to setvalues- The values to set in order
-
setMatrix
Description copied from interface:MutableUniformAccessSets a matrix in the shader.- Specified by:
setMatrixin interfaceMutableUniformAccess- Parameters:
name- The name of the uniform to setvalue- The value to set
-
setMatrix
Description copied from interface:MutableUniformAccessSets a matrix in the shader.- Specified by:
setMatrixin interfaceMutableUniformAccess- Parameters:
name- The name of the uniform to setvalue- The value to set
-
setMatrix
Description copied from interface:MutableUniformAccessSets a matrix in the shader.- Specified by:
setMatrixin interfaceMutableUniformAccess- Parameters:
name- The name of the uniform to setvalue- The value to set
-
setMatrix
Description copied from interface:MutableUniformAccessSets a matrix in the shader.- Specified by:
setMatrixin interfaceMutableUniformAccess- Parameters:
name- The name of the uniform to setvalue- The value to set
-
setMatrix
Description copied from interface:MutableUniformAccessSets a matrix in the shader.- Specified by:
setMatrixin interfaceMutableUniformAccess- Parameters:
name- The name of the uniform to setvalue- The value to set
-
getDefinition
- Returns:
- The definition used to compile the latest version of this shader
-
getShaders
it.unimi.dsi.fastutil.ints.Int2ObjectMap<CompiledShader> getShaders()- Returns:
- The shaders attached to this program
-
isCompute
default boolean isCompute()- Returns:
- Whether this program has the compute stage
-
hasGeometry
default boolean hasGeometry()- Returns:
- Whether this program has the geometry stage
-
hasTesselation
default boolean hasTesselation()- Returns:
- Whether this program has the tesselation stage
-
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
-