Record Class ScreenEffectDefinition
java.lang.Object
java.lang.Record
net.ixdarklord.coolcatcanvas.api.client.effect.ScreenEffectDefinition
public record ScreenEffectDefinition(Map<net.minecraft.resources.ResourceLocation,ScreenEffectDefinition.Target> targets, List<ScreenEffectDefinition.Pass> passes)
extends Record
The passes and targets of a screen effect, in the
post_effect format of later Minecraft versions. Loaded from
assets/<namespace>/post_effect/<path>.json, or built with builder(). A vanilla 1.21 post chain
(assets/<namespace>/shaders/post/<path>.json, vanilla's own included) loads too, when no post_effect
file has that id.
Each pass draws a fragment shader over its output target: vertex_shader and fragment_shader name
assets/<namespace>/shaders/<path>.vsh and .fsh, GLSL 150 with plain uniforms
(minecraft:core/screenquad and minecraft:core/blit_screen stand for SCREENQUAD_VERTEX_SHADER
and BLIT_FRAGMENT_SHADER).
- An input is sampled as
uniform sampler2D <sampler_name>Sampler, its size in pixels read asuniform vec2 <sampler_name>Size.InSizeis the first input's size,OutSizethe output's,ScreenSizethe window's, andProjMatthe projectionSCREENQUAD_VERTEX_SHADERuses. - Every uniform needs a
"name", by which the effect sets it, and a type; the shader declares it as a plain uniform of that name. The block names they're grouped under only organize them. Strength,Time,AgeandSeedare set for every pass; seecoolcatcanvas:screen_effect.glsl.- The only external target is
minecraft:main; its depth can be read with"use_depth_buffer": true.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classstatic interfaceWhat a pass samples: a target or a texture.static final recordOne draw of a fragment shader over its output target.static final classstatic final recordA target a pass can draw into.static final recordSamples a target's color, or its depth withuseDepthBuffer.static final recordSamplesassets/<namespace>/textures/effect/<path>.png.static final recordA named uniform and its default value:{"name": "Amount", "type": "float", "value": 0.5}.static enumThe GLSL types a uniform can have.static final recordA uniform's value. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final net.minecraft.resources.ResourceLocationCopies itsInsampler, no uniforms.static final com.mojang.serialization.Codec<ScreenEffectDefinition> static final net.minecraft.resources.ResourceLocationUniform block names taken by the runtime.Uniform names the runtime sets, which no pass can declare.static final net.minecraft.resources.ResourceLocationDraws the screen as a quad, giving the fragment shadertexCoord. -
Constructor Summary
ConstructorsConstructorDescriptionScreenEffectDefinition(Map<net.minecraft.resources.ResourceLocation, ScreenEffectDefinition.Target> targets, List<ScreenEffectDefinition.Pass> passes) Creates an instance of aScreenEffectDefinitionrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.passes()Returns the value of thepassesrecord component.static net.minecraft.resources.ResourceLocationresolveShader(net.minecraft.resources.ResourceLocation shader) The shader ids of later versions' vanilla post shaders, mapped to CoolCatLib's equivalents.static ScreenEffectDefinitionsimple(net.minecraft.resources.ResourceLocation fragmentShader, String uniformBlock, ScreenEffectDefinition.UniformSpec... uniforms) One fragment shader over the screen: readsminecraft:mainasIn, writes a swap target, then copies it back.Map<net.minecraft.resources.ResourceLocation, ScreenEffectDefinition.Target> targets()Returns the value of thetargetsrecord component.final StringtoString()Returns a string representation of this record class.Every uniform name any pass declares.static com.mojang.serialization.DataResult<ScreenEffectDefinition> validate(ScreenEffectDefinition definition) Checks a definition built without theScreenEffectDefinition.Builder, as loading it does.
-
Field Details
-
MAIN_TARGET
public static final net.minecraft.resources.ResourceLocation MAIN_TARGET -
SCREENQUAD_VERTEX_SHADER
public static final net.minecraft.resources.ResourceLocation SCREENQUAD_VERTEX_SHADERDraws the screen as a quad, giving the fragment shadertexCoord. -
BLIT_FRAGMENT_SHADER
public static final net.minecraft.resources.ResourceLocation BLIT_FRAGMENT_SHADERCopies itsInsampler, no uniforms. -
RESERVED_UNIFORM_BLOCKS
Uniform block names taken by the runtime. -
RESERVED_UNIFORMS
Uniform names the runtime sets, which no pass can declare. -
CODEC
-
-
Constructor Details
-
ScreenEffectDefinition
public ScreenEffectDefinition(Map<net.minecraft.resources.ResourceLocation, ScreenEffectDefinition.Target> targets, List<ScreenEffectDefinition.Pass> passes) Creates an instance of aScreenEffectDefinitionrecord class.- Parameters:
targets- the value for thetargetsrecord componentpasses- the value for thepassesrecord component
-
-
Method Details
-
builder
-
simple
public static ScreenEffectDefinition simple(net.minecraft.resources.ResourceLocation fragmentShader, String uniformBlock, ScreenEffectDefinition.UniformSpec... uniforms) One fragment shader over the screen: readsminecraft:mainasIn, writes a swap target, then copies it back. The simplest effect there is.- Parameters:
uniformBlock- the name the uniforms are grouped under, ignored ifuniformsis emptyuniforms- the shader's uniforms
-
uniformNames
Every uniform name any pass declares. -
resolveShader
public static net.minecraft.resources.ResourceLocation resolveShader(net.minecraft.resources.ResourceLocation shader) The shader ids of later versions' vanilla post shaders, mapped to CoolCatLib's equivalents. -
validate
public static com.mojang.serialization.DataResult<ScreenEffectDefinition> validate(ScreenEffectDefinition definition) Checks a definition built without theScreenEffectDefinition.Builder, as loading it does. -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
targets
Returns the value of thetargetsrecord component.- Returns:
- the value of the
targetsrecord component
-
passes
Returns the value of thepassesrecord component.- Returns:
- the value of the
passesrecord component
-