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, Age and Seed (see coolcatcanvas:screen_effect.glsl), and vanilla's ProjMat, InSize, OutSize, ScreenSize and AuxSize<i>, whether the program's JSON lists them or not.
  • A pass may say "bilinear": true to sample its intarget with linear filtering, and an auxtargets entry 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.
  • Field Details

    • MAIN_TARGET

      public static final net.minecraft.resources.ResourceLocation MAIN_TARGET
    • MAIN_SAMPLER

      public static final String MAIN_SAMPLER
      The sampler a pass reads its intarget as.
      See Also:
    • BLIT_PROGRAM

      public static final net.minecraft.resources.ResourceLocation BLIT_PROGRAM
      Copies its input as it is, alpha included. Vanilla's blit blends by the input's alpha instead, which darkens a copy of minecraft:main.
    • BUILTIN_UNIFORMS

      public static final Set<String> BUILTIN_UNIFORMS
      Uniforms the runtime writes into every pass that has them (besides AuxSize<i>), whatever else sets them.
    • MAX_UNIFORM_VALUES

      public static final int MAX_UNIFORM_VALUES
      See Also:
    • CODEC

      public static final com.mojang.serialization.Codec<ScreenEffectDefinition> CODEC
  • Constructor Details

    • ScreenEffectDefinition

      public ScreenEffectDefinition(Map<net.minecraft.resources.ResourceLocation,ScreenEffectDefinition.Target> targets, List<ScreenEffectDefinition.Pass> passes)
      Creates an instance of a ScreenEffectDefinition record class.
      Parameters:
      targets - the value for the targets record component
      passes - the value for the passes record component
  • Method Details

    • builder

      public static ScreenEffectDefinition.Builder builder()
    • simple

      public static ScreenEffectDefinition simple(net.minecraft.resources.ResourceLocation program, ScreenEffectDefinition.UniformSpec... uniforms)
      One program over the screen: reads minecraft:main as DiffuseSampler, writes a swap target, then copies it back. The simplest effect there is.
      Parameters:
      program - assets/<namespace>/shaders/program/<path>.json
      uniforms - values for the program's uniforms, overriding its defaults
    • uniformNames

      public Set<String> 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)
      Whether id names one of the definition's targets or minecraft:main.
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • targets

      public Map<net.minecraft.resources.ResourceLocation,ScreenEffectDefinition.Target> targets()
      Returns the value of the targets record component.
      Returns:
      the value of the targets record component
    • passes

      Returns the value of the passes record component.
      Returns:
      the value of the passes record component