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 void
bind()
Binds this program for use.void
compile
(ShaderCompiler.Context context, ShaderCompiler compiler) Compiles this shader based on the specified definition.static ShaderProgram
create
(net.minecraft.resources.ResourceLocation id) Creates a new shader program with the specified id.@Nullable ProgramDefinition
default float
getFloat
(CharSequence name) Retrieves a single float by the specified name.default void
getFloats
(CharSequence name, float[] values) Retrieves an array of floats by the specified name.net.minecraft.resources.ResourceLocation
getId()
default int
getInt
(CharSequence name) Retrieves a single integer by the specified name.default void
getInts
(CharSequence name, int[] values) Retrieves an array of integers by the specified name.default void
getMatrix
(CharSequence name, org.joml.Matrix2f value) Retrieves a matrix2x2 by the specified namedefault void
getMatrix
(CharSequence name, org.joml.Matrix3f value) Retrieves a matrix3x3 by the specified namedefault void
getMatrix
(CharSequence name, org.joml.Matrix3x2f value) Retrieves a matrix3x2 by the specified namedefault void
getMatrix
(CharSequence name, org.joml.Matrix4f value) Retrieves a matrix4x4 by the specified namedefault void
getMatrix
(CharSequence name, org.joml.Matrix4x3f value) Retrieves a matrix4x3 by the specified nameint
it.unimi.dsi.fastutil.ints.Int2ObjectMap
<CompiledShader> default void
getVector
(CharSequence name, org.joml.Vector2f... values) Retrieves an array of vectors by the specified name.default void
getVector
(CharSequence name, org.joml.Vector2i... values) Retrieves an array of vectors by the specified name.default void
getVector
(CharSequence name, org.joml.Vector3f... values) Retrieves an array of vectors by the specified name.default void
getVector
(CharSequence name, org.joml.Vector3i... values) Retrieves an array of vectors by the specified name.default void
getVector
(CharSequence name, org.joml.Vector4f... values) Retrieves an array of vectors by the specified name.default void
getVector
(CharSequence name, org.joml.Vector4i... values) Retrieves an array of vectors by the specified name.default boolean
default boolean
default boolean
default void
setFloat
(CharSequence name, float value) Sets a float in the shader.default void
setFloats
(CharSequence name, float... values) Sets an array of floats in the shader.default void
setInt
(CharSequence name, int value) Sets an integer in the shader.default void
setInts
(CharSequence name, int... values) Sets an array of integers in the shader.default void
setMatrix
(CharSequence name, org.joml.Matrix2fc value) Sets a matrix in the shader.default void
setMatrix
(CharSequence name, org.joml.Matrix3fc value) Sets a matrix in the shader.default void
setMatrix
(CharSequence name, org.joml.Matrix3x2fc value) Sets a matrix in the shader.default void
setMatrix
(CharSequence name, org.joml.Matrix4fc value) Sets a matrix in the shader.default void
setMatrix
(CharSequence name, org.joml.Matrix4x3fc value) Sets a matrix in the shader.default void
setStorageBlock
(CharSequence name, int binding) Sets the binding to use for the specified storage block.default void
setUniformBlock
(CharSequence name, int binding) Sets the binding to use for the specified uniform block.default void
setup()
Binds this program for use and prepares for rendering.default void
setVector
(CharSequence name, float x, float y) Sets a vector in the shader.default void
setVector
(CharSequence name, float x, float y, float z) Sets a vector in the shader.default void
setVector
(CharSequence name, float x, float y, float z, float w) Sets a vector in the shader.default void
setVectorI
(CharSequence name, int x, int y) Sets an integer vector in the shader.default void
setVectorI
(CharSequence name, int x, int y, int z) Sets an integer vector in the shader.default void
setVectorI
(CharSequence name, int x, int y, int z, int w) Sets an integer vector in the shader.default void
setVectors
(CharSequence name, org.joml.Vector2fc... values) Sets an array of vectors in the shader.default void
setVectors
(CharSequence name, org.joml.Vector2ic... values) Sets an array of integer vectors in the shader.default void
setVectors
(CharSequence name, org.joml.Vector3fc... values) Sets an array of vectors in the shader.default void
setVectors
(CharSequence name, org.joml.Vector3ic... values) Sets an array of integer vectors in the shader.default void
setVectors
(CharSequence name, org.joml.Vector4fc... values) Sets an array of vectors in the shader.default void
setVectors
(CharSequence name, org.joml.Vector4ic... values) Sets an array of integer vectors in the shader.net.minecraft.client.renderer.ShaderInstance
Wraps this shader with a vanilla Minecraft shader instance wrapper.static void
unbind()
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, setVectorI
Methods inherited from interface org.lwjgl.system.NativeResource
close, free
Methods inherited from interface foundry.veil.api.client.render.shader.program.TextureUniformAccess
addRenderSystemTextures, addSampler, addSamplerListener, applyShaderSamplers, applyShaderSamplers, clearSamplers, removeSampler, removeSamplerListener, setFramebufferSamplers
Methods 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:UniformAccess
Retrieves a single float by the specified name.- Specified by:
getFloat
in interfaceUniformAccess
- Parameters:
name
- The name of the uniform to get- Returns:
- The float value of that uniform
-
getInt
Description copied from interface:UniformAccess
Retrieves a single integer by the specified name.- Specified by:
getInt
in interfaceUniformAccess
- Parameters:
name
- The name of the uniform to get- Returns:
- The int value of that uniform
-
getFloats
Description copied from interface:UniformAccess
Retrieves an array of floats by the specified name.- Specified by:
getFloats
in interfaceUniformAccess
- Parameters:
name
- The name of the uniform to getvalues
- The values to set
-
getVector
Description copied from interface:UniformAccess
Retrieves an array of vectors by the specified name.- Specified by:
getVector
in interfaceUniformAccess
- Parameters:
name
- The name of the uniform to getvalues
- The values to set
-
getVector
Description copied from interface:UniformAccess
Retrieves an array of vectors by the specified name.- Specified by:
getVector
in interfaceUniformAccess
- Parameters:
name
- The name of the uniform to getvalues
- The values to set
-
getVector
Description copied from interface:UniformAccess
Retrieves an array of vectors by the specified name.- Specified by:
getVector
in interfaceUniformAccess
- Parameters:
name
- The name of the uniform to getvalues
- The values to set
-
getInts
Description copied from interface:UniformAccess
Retrieves an array of integers by the specified name.- Specified by:
getInts
in interfaceUniformAccess
- Parameters:
name
- The name of the uniform to getvalues
- The values to set
-
getVector
Description copied from interface:UniformAccess
Retrieves an array of vectors by the specified name.- Specified by:
getVector
in interfaceUniformAccess
- Parameters:
name
- The name of the uniform to getvalues
- The values to set
-
getVector
Description copied from interface:UniformAccess
Retrieves an array of vectors by the specified name.- Specified by:
getVector
in interfaceUniformAccess
- Parameters:
name
- The name of the uniform to getvalues
- The values to set
-
getVector
Description copied from interface:UniformAccess
Retrieves an array of vectors by the specified name.- Specified by:
getVector
in interfaceUniformAccess
- Parameters:
name
- The name of the uniform to getvalues
- The values to set
-
getMatrix
Description copied from interface:UniformAccess
Retrieves a matrix2x2 by the specified name- Specified by:
getMatrix
in interfaceUniformAccess
- Parameters:
name
- The name of the uniform to getvalue
- The value to set
-
getMatrix
Description copied from interface:UniformAccess
Retrieves a matrix3x3 by the specified name- Specified by:
getMatrix
in interfaceUniformAccess
- Parameters:
name
- The name of the uniform to getvalue
- The value to set
-
getMatrix
Description copied from interface:UniformAccess
Retrieves a matrix3x2 by the specified name- Specified by:
getMatrix
in interfaceUniformAccess
- Parameters:
name
- The name of the uniform to getvalue
- The value to set
-
getMatrix
Description copied from interface:UniformAccess
Retrieves a matrix4x4 by the specified name- Specified by:
getMatrix
in interfaceUniformAccess
- Parameters:
name
- The name of the uniform to getvalue
- The value to set
-
getMatrix
Description copied from interface:UniformAccess
Retrieves a matrix4x3 by the specified name- Specified by:
getMatrix
in interfaceUniformAccess
- Parameters:
name
- The name of the uniform to getvalue
- The value to set
-
setUniformBlock
Description copied from interface:MutableUniformAccess
Sets the binding to use for the specified uniform block.- Specified by:
setUniformBlock
in interfaceMutableUniformAccess
- Parameters:
name
- The name of the block to setbinding
- The binding to use for that block
-
setStorageBlock
Description copied from interface:MutableUniformAccess
Sets the binding to use for the specified storage block.- Specified by:
setStorageBlock
in interfaceMutableUniformAccess
- Parameters:
name
- The name of the block to setbinding
- The binding to use for that block
-
setFloat
Description copied from interface:MutableUniformAccess
Sets a float in the shader.- Specified by:
setFloat
in interfaceMutableUniformAccess
- Parameters:
name
- The name of the uniform to setvalue
- The value to set
-
setVector
Description copied from interface:MutableUniformAccess
Sets a vector in the shader.- Specified by:
setVector
in 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:MutableUniformAccess
Sets a vector in the shader.- Specified by:
setVector
in 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:MutableUniformAccess
Sets a vector in the shader.- Specified by:
setVector
in 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:MutableUniformAccess
Sets an integer in the shader.- Specified by:
setInt
in interfaceMutableUniformAccess
- Parameters:
name
- The name of the uniform to setvalue
- The value to set
-
setVectorI
Description copied from interface:MutableUniformAccess
Sets an integer vector in the shader.- Specified by:
setVectorI
in 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:MutableUniformAccess
Sets an integer vector in the shader.- Specified by:
setVectorI
in 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:MutableUniformAccess
Sets an integer vector in the shader.- Specified by:
setVectorI
in 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:MutableUniformAccess
Sets an array of floats in the shader.- Specified by:
setFloats
in interfaceMutableUniformAccess
- Parameters:
name
- The name of the uniform to setvalues
- The values to set in order
-
setVectors
Description copied from interface:MutableUniformAccess
Sets an array of vectors in the shader.- Specified by:
setVectors
in interfaceMutableUniformAccess
- Parameters:
name
- The name of the uniform to setvalues
- The values to set in order
-
setVectors
Description copied from interface:MutableUniformAccess
Sets an array of vectors in the shader.- Specified by:
setVectors
in interfaceMutableUniformAccess
- Parameters:
name
- The name of the uniform to setvalues
- The values to set in order
-
setVectors
Description copied from interface:MutableUniformAccess
Sets an array of vectors in the shader.- Specified by:
setVectors
in interfaceMutableUniformAccess
- Parameters:
name
- The name of the uniform to setvalues
- The values to set in order
-
setInts
Description copied from interface:MutableUniformAccess
Sets an array of integers in the shader.- Specified by:
setInts
in interfaceMutableUniformAccess
- Parameters:
name
- The name of the uniform to setvalues
- The values to set in order
-
setVectors
Description copied from interface:MutableUniformAccess
Sets an array of integer vectors in the shader.- Specified by:
setVectors
in interfaceMutableUniformAccess
- Parameters:
name
- The name of the uniform to setvalues
- The values to set in order
-
setVectors
Description copied from interface:MutableUniformAccess
Sets an array of integer vectors in the shader.- Specified by:
setVectors
in interfaceMutableUniformAccess
- Parameters:
name
- The name of the uniform to setvalues
- The values to set in order
-
setVectors
Description copied from interface:MutableUniformAccess
Sets an array of integer vectors in the shader.- Specified by:
setVectors
in interfaceMutableUniformAccess
- Parameters:
name
- The name of the uniform to setvalues
- The values to set in order
-
setMatrix
Description copied from interface:MutableUniformAccess
Sets a matrix in the shader.- Specified by:
setMatrix
in interfaceMutableUniformAccess
- Parameters:
name
- The name of the uniform to setvalue
- The value to set
-
setMatrix
Description copied from interface:MutableUniformAccess
Sets a matrix in the shader.- Specified by:
setMatrix
in interfaceMutableUniformAccess
- Parameters:
name
- The name of the uniform to setvalue
- The value to set
-
setMatrix
Description copied from interface:MutableUniformAccess
Sets a matrix in the shader.- Specified by:
setMatrix
in interfaceMutableUniformAccess
- Parameters:
name
- The name of the uniform to setvalue
- The value to set
-
setMatrix
Description copied from interface:MutableUniformAccess
Sets a matrix in the shader.- Specified by:
setMatrix
in interfaceMutableUniformAccess
- Parameters:
name
- The name of the uniform to setvalue
- The value to set
-
setMatrix
Description copied from interface:MutableUniformAccess
Sets a matrix in the shader.- Specified by:
setMatrix
in 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 throughShaderManager
then 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
-