Interface ShaderProgram
- All Superinterfaces:
AutoCloseable,MutableUniformAccess,org.lwjgl.system.NativeResource,TextureUniformAccess,UniformAccess
- All Known Implementing Classes:
DynamicShaderProgramImpl,ShaderProgramImpl
@NonExtendable
public interface ShaderProgram
extends org.lwjgl.system.NativeResource, MutableUniformAccess, TextureUniformAccess
Represents a usable shader program with shaders attached.
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidbind()Binds this program for use.int@Nullable ProgramDefinition@Nullable com.mojang.blaze3d.vertex.VertexFormatnet.minecraft.resources.ResourceLocationgetName()Retrieves a uniform by name or creates a reference to one that may exist in the future.intit.unimi.dsi.fastutil.ints.Int2ObjectMap<CompiledShader> getUniform(CharSequence name) Retrieves a uniform by name.default booleandefault booleandefault booleandefault booleandefault booleanbooleanisValid()default voidsetDefaultUniforms(com.mojang.blaze3d.vertex.VertexFormat.Mode mode) Sets the default uniforms in this shader.voidsetDefaultUniforms(com.mojang.blaze3d.vertex.VertexFormat.Mode mode, org.joml.Matrix4fc modelViewMatrix, org.joml.Matrix4fc projectionMatrix) Sets the default uniforms in this 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.net.minecraft.client.renderer.ShaderInstanceDeprecated.static voidunbind()Unbinds the currently bound shader program.Methods inherited from interface org.lwjgl.system.NativeResource
close, freeMethods inherited from interface foundry.veil.api.client.render.shader.program.TextureUniformAccess
bindSamplers, bindSamplers, clearSamplers, removeSampler, setFramebufferSamplers, setSampler, setSamplerMethods inherited from interface foundry.veil.api.client.render.shader.program.UniformAccess
getStorageBlock, getUniformBlock, getUniformLocation, getUniformSafe, hasStorageBlock, hasUniform, hasUniformBlock
-
Method Details
-
bind
default void bind()Binds this program for use. -
unbind
static void unbind()Unbinds the currently bound shader program. -
setDefaultUniforms
default void setDefaultUniforms(com.mojang.blaze3d.vertex.VertexFormat.Mode mode) Sets the default uniforms in this shader.- Parameters:
mode- The expected draw mode
-
setDefaultUniforms
void setDefaultUniforms(com.mojang.blaze3d.vertex.VertexFormat.Mode mode, org.joml.Matrix4fc modelViewMatrix, org.joml.Matrix4fc projectionMatrix) Sets the default uniforms in this shader.- Parameters:
mode- The expected draw modemodelViewMatrix- The view matrix transformprojectionMatrix- The projection matrix transform
-
getProgram
int getProgram()- Returns:
- The OpenGL id of this program
-
getActiveDynamicBuffers
int getActiveDynamicBuffers()- Returns:
- The active buffers in the compiled program
- Since:
- 2.3.0
-
getUniform
Description copied from interface:UniformAccessRetrieves a uniform by name.- Specified by:
getUniformin interfaceUniformAccess- Parameters:
name- The name of the uniform to get- Returns:
- The uniform with that name or
nullif the uniform does not exist
-
getOrCreateUniform
Description copied from interface:UniformAccessRetrieves a uniform by name or creates a reference to one that may exist in the future.- Specified by:
getOrCreateUniformin interfaceUniformAccess- Parameters:
name- The name of the uniform to get- Returns:
- The uniform instance
-
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
-
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
-
isValid
boolean isValid()- Returns:
- Whether this program has a valid compiled shader
- Since:
- 2.0.0
-
hasVertex
default boolean hasVertex()- Returns:
- Whether this program has the vertex stage
-
hasGeometry
default boolean hasGeometry()- Returns:
- Whether this program has the geometry stage
-
hasFragment
default boolean hasFragment()- Returns:
- Whether this program has the fragment stage
-
hasTesselation
default boolean hasTesselation()- Returns:
- Whether this program has the tesselation stages
-
isCompute
default boolean isCompute()- Returns:
- Whether this program has the compute stage
-
getRequiredFeatures
Set<ShaderFeature> getRequiredFeatures()- Returns:
- The features this program needs to function
- Since:
- 2.0.0
-
getFormat
@Nullable @Nullable com.mojang.blaze3d.vertex.VertexFormat getFormat()- Returns:
- A guess at the best vertex format for this program
-
getDefinitionDependencies
- Returns:
- All shader definitions this program depends on
-
getName
net.minecraft.resources.ResourceLocation getName()- Returns:
- The name of this program
-
toShaderInstance
Deprecated.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.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.
-
VeilRenderBridge.toShaderInstance(ShaderProgram)