Package dev.cammiescorner.velvet.impl
Class ResettableManagedShaderEffect
java.lang.Object
dev.cammiescorner.velvet.impl.ResettableManagedShaderBase<net.minecraft.client.renderer.PostChain>
dev.cammiescorner.velvet.impl.ResettableManagedShaderEffect
- All Implemented Interfaces:
ManagedShaderEffect,UniformFinder
public final class ResettableManagedShaderEffect
extends ResettableManagedShaderBase<net.minecraft.client.renderer.PostChain>
implements ManagedShaderEffect
A
ManagedShaderEffect that can be setup(int, int) several times in its lifetime,
triggering an initialization callback.- Since:
- 1.0.0
- See Also:
-
Field Summary
Fields inherited from class dev.cammiescorner.velvet.impl.ResettableManagedShaderBase
shader -
Constructor Summary
ConstructorsConstructorDescriptionResettableManagedShaderEffect(net.minecraft.resources.ResourceLocation location, Consumer<ManagedShaderEffect> initCallback) Creates a new shader effect. -
Method Summary
Modifier and TypeMethodDescriptionfindSampler(String samplerName) Finds a sampler declared in json@Nullable net.minecraft.client.renderer.PostChainReturns this object's managedPostChain, creating and initializing it if it doesn't exist.voidInitializes this shader, allocating required system resources such as render target objects, shaders objects and texture objects.protected voidprotected net.minecraft.client.renderer.PostChainparseShader(net.minecraft.server.packs.resources.ResourceProvider resourceFactory, net.minecraft.client.Minecraft mc, net.minecraft.resources.ResourceLocation location) voidrender(float tickDelta) Renders this shader.voidsetSamplerUniform(String samplerName, int textureName) Sets the value of a sampler uniform declared in jsonvoidsetSamplerUniform(String samplerName, com.mojang.blaze3d.pipeline.RenderTarget textureFbo) Sets the value of a sampler uniform declared in jsonvoidsetSamplerUniform(String samplerName, net.minecraft.client.renderer.texture.AbstractTexture texture) Sets the value of a sampler uniform declared in jsonvoidsetUniformValue(String uniformName, float value) Sets the value of a uniform declared in jsonvoidsetUniformValue(String uniformName, float value0, float value1) Sets the value of a uniform declared in jsonvoidsetUniformValue(String uniformName, float value0, float value1, float value2) Sets the value of a uniform declared in jsonvoidsetUniformValue(String uniformName, float value0, float value1, float value2, float value3) Sets the value of a uniform declared in jsonvoidsetUniformValue(String uniformName, int value) Sets the value of a uniform declared in jsonvoidsetUniformValue(String uniformName, int value0, int value1) Sets the value of a uniform declared in jsonvoidsetUniformValue(String uniformName, int value0, int value1, int value2) Sets the value of a uniform declared in jsonvoidsetUniformValue(String uniformName, int value0, int value1, int value2, int value3) Sets the value of a uniform declared in jsonvoidsetUniformValue(String uniformName, org.joml.Matrix4f value) Sets the value of a uniform declared in jsonvoidsetup(int windowWidth, int windowHeight) voidsetupDynamicUniforms(int index, Runnable dynamicSetBlock) Runs the given block while the shader at the given index is activevoidsetupDynamicUniforms(Runnable dynamicSetBlock) Forwards toManagedShaderEffect.setupDynamicUniforms(int, Runnable)with an index of 0protected booleansetupUniform(ManagedUniformBase uniform, net.minecraft.client.renderer.PostChain shader) Methods inherited from class dev.cammiescorner.velvet.impl.ResettableManagedShaderBase
findUniform1f, findUniform1i, findUniform2f, findUniform2i, findUniform3f, findUniform3i, findUniform4f, findUniform4i, findUniformMat4, getLocation, getManagedUniforms, initialize, initializeOrLog, isErrored, isInitialized, manageUniform, release, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface dev.cammiescorner.velvet.api.managed.ManagedShaderEffect
isErrored, isInitialized, releaseMethods inherited from interface dev.cammiescorner.velvet.api.managed.uniform.UniformFinder
findUniform1f, findUniform1i, findUniform2f, findUniform2i, findUniform3f, findUniform3i, findUniform4f, findUniform4i, findUniformMat4
-
Constructor Details
-
ResettableManagedShaderEffect
@API(status=INTERNAL) public ResettableManagedShaderEffect(net.minecraft.resources.ResourceLocation location, Consumer<ManagedShaderEffect> initCallback) Creates a new shader effect.
Users should obtain instanced of this class throughShaderEffectManager- Parameters:
location- the location of a shader effect JSON definition fileinitCallback- code to run insetup(int, int)- See Also:
-
-
Method Details
-
getShaderEffect
@Nullable public @Nullable net.minecraft.client.renderer.PostChain getShaderEffect()Description copied from interface:ManagedShaderEffectReturns this object's managedPostChain, creating and initializing it if it doesn't exist.This method will return
nullif an error occurs during initialization.Note: calling this before the graphic context is ready will cause issues.
- Specified by:
getShaderEffectin interfaceManagedShaderEffect- Returns:
- the
PostChainmanaged by this object - See Also:
-
initialize
Description copied from interface:ManagedShaderEffectInitializes this shader, allocating required system resources such as render target objects, shaders objects and texture objects. Any exception thrown during initialization is relayed to the caller.If the shader is already initialized, previously allocated resources will be disposed of before initializing new ones.
- Specified by:
initializein interfaceManagedShaderEffect- Throws:
IOException- See Also:
-
parseShader
protected net.minecraft.client.renderer.PostChain parseShader(net.minecraft.server.packs.resources.ResourceProvider resourceFactory, net.minecraft.client.Minecraft mc, net.minecraft.resources.ResourceLocation location) throws IOException - Specified by:
parseShaderin classResettableManagedShaderBase<net.minecraft.client.renderer.PostChain>- Throws:
IOException
-
setup
public void setup(int windowWidth, int windowHeight) - Specified by:
setupin classResettableManagedShaderBase<net.minecraft.client.renderer.PostChain>
-
render
public void render(float tickDelta) Renders this shader.Calling this method first setups the graphic state for rendering, then uploads uniforms to the GPU if they have been changed since last draw, draws the
main render target's texture to intermediaterender targetsas defined by the JSON files and resets part of the graphic state. The shader will beinitializedif it has not been before.This method should be called every frame when the shader is active. Uniforms should be set before rendering.
- Specified by:
renderin interfaceManagedShaderEffect
-
getTarget
- Specified by:
getTargetin interfaceManagedShaderEffect
-
setUniformValue
Sets the value of a uniform declared in json- Specified by:
setUniformValuein interfaceManagedShaderEffect- Parameters:
uniformName- the name of the uniform field in the shader source filevalue- int value- See Also:
-
setUniformValue
Sets the value of a uniform declared in json- Specified by:
setUniformValuein interfaceManagedShaderEffect- Parameters:
uniformName- the name of the uniform field in the shader source filevalue0- int valuevalue1- int value- See Also:
-
setUniformValue
Sets the value of a uniform declared in json- Specified by:
setUniformValuein interfaceManagedShaderEffect- Parameters:
uniformName- the name of the uniform field in the shader source filevalue0- int valuevalue1- int valuevalue2- int value- See Also:
-
setUniformValue
Sets the value of a uniform declared in json- Specified by:
setUniformValuein interfaceManagedShaderEffect- Parameters:
uniformName- the name of the uniform field in the shader source filevalue0- int valuevalue1- int valuevalue2- int valuevalue3- int value- See Also:
-
setUniformValue
Sets the value of a uniform declared in json- Specified by:
setUniformValuein interfaceManagedShaderEffect- Parameters:
uniformName- the name of the uniform field in the shader source filevalue- float value- See Also:
-
setUniformValue
Sets the value of a uniform declared in json- Specified by:
setUniformValuein interfaceManagedShaderEffect- Parameters:
uniformName- the name of the uniform field in the shader source filevalue0- float valuevalue1- float value- See Also:
-
setUniformValue
Sets the value of a uniform declared in json- Specified by:
setUniformValuein interfaceManagedShaderEffect- Parameters:
uniformName- the name of the uniform field in the shader source filevalue0- float valuevalue1- float valuevalue2- float value- See Also:
-
setUniformValue
public void setUniformValue(String uniformName, float value0, float value1, float value2, float value3) Sets the value of a uniform declared in json- Specified by:
setUniformValuein interfaceManagedShaderEffect- Parameters:
uniformName- the name of the uniform field in the shader source filevalue0- float valuevalue1- float valuevalue2- float valuevalue3- float value- See Also:
-
setUniformValue
Sets the value of a uniform declared in json- Specified by:
setUniformValuein interfaceManagedShaderEffect- Parameters:
uniformName- the name of the uniform field in the shader source filevalue- a matrix- See Also:
-
setSamplerUniform
public void setSamplerUniform(String samplerName, net.minecraft.client.renderer.texture.AbstractTexture texture) Sets the value of a sampler uniform declared in json- Specified by:
setSamplerUniformin interfaceManagedShaderEffect- Parameters:
samplerName- the name of the sampler uniform field in the shader source file and jsontexture- a texture object- See Also:
-
setSamplerUniform
public void setSamplerUniform(String samplerName, com.mojang.blaze3d.pipeline.RenderTarget textureFbo) Sets the value of a sampler uniform declared in json- Specified by:
setSamplerUniformin interfaceManagedShaderEffect- Parameters:
samplerName- the name of the sampler uniform field in the shader source file and jsontextureFbo- a render target which main texture will be used- See Also:
-
setSamplerUniform
Sets the value of a sampler uniform declared in json- Specified by:
setSamplerUniformin interfaceManagedShaderEffect- Parameters:
samplerName- the name of the sampler uniform field in the shader source file and jsontextureName- an opengl texture name- See Also:
-
findSampler
Description copied from interface:UniformFinderFinds a sampler declared in json- Specified by:
findSamplerin interfaceManagedShaderEffect- Specified by:
findSamplerin interfaceUniformFinder- Parameters:
samplerName- the name of the sampler field in the shader source file
-
setupDynamicUniforms
Description copied from interface:ManagedShaderEffectForwards toManagedShaderEffect.setupDynamicUniforms(int, Runnable)with an index of 0- Specified by:
setupDynamicUniformsin interfaceManagedShaderEffect- Parameters:
dynamicSetBlock- a block in which dynamic uniforms are set
-
setupDynamicUniforms
Description copied from interface:ManagedShaderEffectRuns the given block while the shader at the given index is active- Specified by:
setupDynamicUniformsin interfaceManagedShaderEffect- Parameters:
index- the shader index within the groupdynamicSetBlock- a block in which dynamic name uniforms are set
-
setupUniform
protected boolean setupUniform(ManagedUniformBase uniform, net.minecraft.client.renderer.PostChain shader) - Specified by:
setupUniformin classResettableManagedShaderBase<net.minecraft.client.renderer.PostChain>
-
logInitError
- Specified by:
logInitErrorin classResettableManagedShaderBase<net.minecraft.client.renderer.PostChain>
-