Class ShaderProgramImpl
java.lang.Object
foundry.veil.impl.client.render.shader.ShaderProgramImpl
- All Implemented Interfaces:
MutableUniformAccess,ShaderProgram,TextureUniformAccess,UniformAccess,AutoCloseable,org.lwjgl.system.NativeResource
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classNested classes/interfaces inherited from interface foundry.veil.api.client.render.shader.program.TextureUniformAccess
TextureUniformAccess.SamplerListener -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSampler(CharSequence name, int textureId) Adds a texture that is dynamically bound and sets texture units.voidAdds a listener for sampler updates.intapplyShaderSamplers(ShaderTextureSource.Context context, int sampler) Loads the samplers set byTextureUniformAccess.addSampler(CharSequence, int)into the shader.voidClears all samplers.voidcompile(ShaderCompiler.Context context, ShaderCompiler compiler) Compiles this shader based on the specified definition.voidfree()@Nullable ProgramDefinitionnet.minecraft.resources.ResourceLocationgetId()intit.unimi.dsi.fastutil.ints.Int2ObjectMap<CompiledShader> intgetStorageBlock(CharSequence name) Retrieves the location of a storage block.intgetUniform(CharSequence name) Retrieves the location of a uniform.intgetUniformBlock(CharSequence name) Retrieves the location of a uniform block.voidremoveSampler(CharSequence name) Removes the specified sampler binding.voidRemoves a listener from sampler updates.booleansetActiveBuffers(int activeBuffers) Wraps this shader with a vanilla Minecraft shader instance wrapper.voidupdateActiveBuffers(ShaderCompiler.Context context, ShaderCompiler compiler) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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
closeMethods inherited from interface foundry.veil.api.client.render.shader.program.ShaderProgram
bind, getFloat, getFloats, getInt, getInts, getMatrix, getMatrix, getMatrix, getMatrix, getMatrix, getVector, getVector, getVector, getVector, getVector, getVector, hasGeometry, hasTesselation, isCompute, setFloat, setFloats, setInt, setInts, setMatrix, setMatrix, setMatrix, setMatrix, setMatrix, setStorageBlock, setUniformBlock, setup, setVector, setVector, setVector, setVectorI, setVectorI, setVectorI, setVectors, setVectors, setVectors, setVectors, setVectors, setVectorsMethods inherited from interface foundry.veil.api.client.render.shader.program.TextureUniformAccess
addRenderSystemTextures, applyShaderSamplers, setFramebufferSamplersMethods inherited from interface foundry.veil.api.client.render.shader.program.UniformAccess
hasStorageBlock, hasUniform, hasUniformBlock
-
Constructor Details
-
ShaderProgramImpl
public ShaderProgramImpl(net.minecraft.resources.ResourceLocation id)
-
-
Method Details
-
compile
public void compile(ShaderCompiler.Context context, ShaderCompiler compiler) throws ShaderException, IOException Description copied from interface:ShaderProgramCompiles this shader based on the specified definition.- Specified by:
compilein interfaceShaderProgram- Parameters:
context- The context to use when compiling shaderscompiler- The compiler to use- Throws:
ShaderException- If an error occurs while compiling or linking shadersIOException- If an error occurs while loading shaders
-
setActiveBuffers
- Throws:
ShaderException
-
updateActiveBuffers
public void updateActiveBuffers(ShaderCompiler.Context context, ShaderCompiler compiler) throws ShaderException, IOException - Throws:
ShaderExceptionIOException
-
free
public void free()- Specified by:
freein interfaceorg.lwjgl.system.NativeResource
-
getShaders
- Specified by:
getShadersin interfaceShaderProgram- Returns:
- The shaders attached to this program
-
getDefinitionDependencies
- Specified by:
getDefinitionDependenciesin interfaceShaderProgram- Returns:
- All shader definitions this program depends on
-
getId
public net.minecraft.resources.ResourceLocation getId()- Specified by:
getIdin interfaceShaderProgram- Returns:
- The id of this program
-
toShaderInstance
Description copied from interface:ShaderProgramWraps 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.
- Specified by:
toShaderInstancein interfaceShaderProgram- Returns:
- A lazily loaded shader instance wrapper for this program
- The shader instance cannot be used to free the shader program.
-
getUniform
Description copied from interface:UniformAccessRetrieves the location of a uniform.- Specified by:
getUniformin interfaceUniformAccess- Parameters:
name- The name of the uniform to get- Returns:
- The location of that uniform or
-1if not found
-
getUniformBlock
Description copied from interface:UniformAccessRetrieves the location of a uniform block.- Specified by:
getUniformBlockin interfaceUniformAccess- Parameters:
name- The name of the uniform block to get- Returns:
- The location of that uniform block or -1 if not found
-
getStorageBlock
Description copied from interface:UniformAccessRetrieves the location of a storage block.- Specified by:
getStorageBlockin interfaceUniformAccess- Parameters:
name- The name of the storage block to get- Returns:
- The location of that storage block or -1 if not found
-
getProgram
public int getProgram()- Specified by:
getProgramin interfaceShaderProgram- Returns:
- The OpenGL id of this program
-
getDefinition
- Specified by:
getDefinitionin interfaceShaderProgram- Returns:
- The definition used to compile the latest version of this shader
-
applyShaderSamplers
Description copied from interface:TextureUniformAccessLoads the samplers set byTextureUniformAccess.addSampler(CharSequence, int)into the shader.- Specified by:
applyShaderSamplersin interfaceTextureUniformAccess- Parameters:
context- The context for setting built-in shader samplers ornullto ignore normal samplerssampler- The sampler to start binding to- Returns:
- The next available sampler
-
addSamplerListener
Description copied from interface:TextureUniformAccessAdds a listener for sampler updates.- Specified by:
addSamplerListenerin interfaceTextureUniformAccess- Parameters:
listener- The listener instance
-
removeSamplerListener
Description copied from interface:TextureUniformAccessRemoves a listener from sampler updates.- Specified by:
removeSamplerListenerin interfaceTextureUniformAccess- Parameters:
listener- The listener instance
-
addSampler
Description copied from interface:TextureUniformAccessAdds a texture that is dynamically bound and sets texture units.- Specified by:
addSamplerin interfaceTextureUniformAccess- Parameters:
name- The name of the texture to settextureId- The id of the texture to bind and assign a texture unit
-
removeSampler
Description copied from interface:TextureUniformAccessRemoves the specified sampler binding.- Specified by:
removeSamplerin interfaceTextureUniformAccess- Parameters:
name- The name of the sampler to remove
-
clearSamplers
public void clearSamplers()Description copied from interface:TextureUniformAccessClears all samplers.- Specified by:
clearSamplersin interfaceTextureUniformAccess
-