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: vanilla's post chain format, so vanilla's own effects (and any made for
them) load as they are. Loaded from
assets/<namespace>/shaders/post/<path>.json, or built with
builder().
Each pass runs a program, assets/<namespace>/shaders/program/<path>.json in vanilla's format: its
vertex and fragment shaders (namespaced, or vanilla's), its blend, and its uniforms
with their types and defaults. Differences from vanilla:
- Programs, shaders and textures can be namespaced (
"name": "mymod:swirl"), and shaders can use#moj_import, e.g.#moj_import <coolcatcanvas:screen_effect.glsl>. - Every pass also gets
Strength,Time,AgeandSeed(seecoolcatcanvas:screen_effect.glsl), and vanilla'sProjMat,InSize,OutSize,ScreenSizeandAuxSize<i>, whether the program's JSON lists them or not. - A pass may say
"bilinear": trueto sample itsintargetwith linear filtering, and anauxtargetsentry may too for a target. - The only external target is
minecraft:main; its depth can be read with"id": "minecraft:main:depth", as vanilla allows. Every target keeps its content from one frame to the next until a pass draws into it, as in vanilla's post chains.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordAnother input of a pass, sampled assampler: a target (its color, or its depth), or else a texture,assets/<namespace>/textures/effect/<path>.png.static final classstatic final recordOne draw of a program over its output target.static final classstatic final recordA target's size; screen-sized where not given.static final recordA value for a program's uniform:{"name": "Amount", "values": [0.5]}. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final net.minecraft.resources.ResourceLocationCopies its input as it is, alpha included.Uniforms the runtime writes into every pass that has them (besidesAuxSize<i>), whatever else sets them.static final com.mojang.serialization.Codec<ScreenEffectDefinition>static final StringThe sampler a pass reads itsintargetas.static final net.minecraft.resources.ResourceLocationstatic final int -
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.booleanisTarget(net.minecraft.resources.ResourceLocation id) Whetheridnames one of the definition's targets orminecraft:main.passes()Returns the value of thepassesrecord component.static ScreenEffectDefinitionsimple(net.minecraft.resources.ResourceLocation program, ScreenEffectDefinition.UniformSpec... uniforms) One program over the screen: readsminecraft:mainasDiffuseSampler, 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 a pass gives a value to.
-
Field Details
-
MAIN_TARGET
public static final net.minecraft.resources.ResourceLocation MAIN_TARGET -
MAIN_SAMPLER
The sampler a pass reads itsintargetas.- See Also:
-
BLIT_PROGRAM
public static final net.minecraft.resources.ResourceLocation BLIT_PROGRAMCopies its input as it is, alpha included. Vanilla'sblitblends by the input's alpha instead, which darkens a copy ofminecraft:main. -
BUILTIN_UNIFORMS
Uniforms the runtime writes into every pass that has them (besidesAuxSize<i>), whatever else sets them. -
MAX_UNIFORM_VALUES
public static final int MAX_UNIFORM_VALUES- See Also:
-
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 program, ScreenEffectDefinition.UniformSpec... uniforms) One program over the screen: readsminecraft:mainasDiffuseSampler, writes a swap target, then copies it back. The simplest effect there is.- Parameters:
program-assets/<namespace>/shaders/program/<path>.jsonuniforms- values for the program's uniforms, overriding its defaults
-
uniformNames
Every uniform name a pass gives a value to. The programs declare more, with their defaults. -
isTarget
public boolean isTarget(net.minecraft.resources.ResourceLocation id) Whetheridnames one of the definition's targets orminecraft:main. -
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
-