Class ShaderProgram
java.lang.Object
net.ixdarklord.coolcatcanvas.internal.client.effect.ShaderProgram
- All Implemented Interfaces:
AutoCloseable
A GL program linked from
assets/<namespace>/shaders/<path>.vsh and .fsh, for screen effects and sky
layers. Vanilla's own shader classes only read the minecraft namespace and can't import includes into
effect programs, so these are compiled here: #moj_import <namespace:file.glsl> reads
assets/<namespace>/shaders/include/file.glsl (minecraft without a namespace), and
#moj_import "file.glsl" a file next to the shader.
Uniforms are plain GLSL 150 uniforms, set by name; setting one the program lacks does nothing. Only use it from the render thread. Programs don't touch vanilla's cached shader state: vanilla rebinds its program for every draw.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()static ShaderProgramcompile(net.minecraft.server.packs.resources.ResourceProvider resources, net.minecraft.resources.ResourceLocation vertexShader, net.minecraft.resources.ResourceLocation fragmentShader, List<String> defines, List<String> attributes) Compiles and links a program.booleanintThe uniform's location, or -1 if the program has none by that name.name()static voidrelease()Unbinds any program, after drawing with these.voidset(String uniform, ScreenEffectDefinition.UniformType type, float[] v) Sets a uniform of a definition's type from its components (a matrix column-major); missing components are 0, floats are truncated for int types.voidvoidvoidvoidsetSampler(String uniform, int unit) Points a sampler at a texture unit.voidvoidvoidsetVec4Array(String uniform, float[] values) Sets avec4[]from its components, 4 per element.voiduse()
-
Method Details
-
compile
public static ShaderProgram compile(net.minecraft.server.packs.resources.ResourceProvider resources, net.minecraft.resources.ResourceLocation vertexShader, net.minecraft.resources.ResourceLocation fragmentShader, List<String> defines, List<String> attributes) throws IOException Compiles and links a program.- Parameters:
defines-#defines added after the#versionline of both shadersattributes- vertex attribute names, bound to locations 0, 1, ... in order (as vanilla's vertex formats expect)- Throws:
IOException- if a shader is missing or fails to compile or link, with the driver's log
-
name
-
use
public void use() -
release
public static void release()Unbinds any program, after drawing with these. -
location
The uniform's location, or -1 if the program has none by that name. -
has
-
setFloat
-
setVec2
-
setVec4
-
setVec4Array
Sets avec4[]from its components, 4 per element. -
setInt
-
setMatrix
-
setSampler
Points a sampler at a texture unit. -
set
Sets a uniform of a definition's type from its components (a matrix column-major); missing components are 0, floats are truncated for int types. -
close
public void close()- Specified by:
closein interfaceAutoCloseable
-