Record Class ScreenEffectDefinition

java.lang.Object
java.lang.Record
net.ixdarklord.coolcatcanvas.api.client.effect.ScreenEffectDefinition

public record ScreenEffectDefinition(Map<net.minecraft.resources.Identifier, net.minecraft.client.renderer.PostChainConfig.InternalTarget> targets, List<ScreenEffectDefinition.Pass> passes) extends Record
The passes and targets of a screen effect: the vanilla post_effect format, so vanilla's own effects load as is. Loaded from assets/<namespace>/post_effect/<path>.json, or built with builder().

Vanilla parses every post_effect file too, so keep them valid for it (a "vertex_shader" on every pass; minecraft:core/screenquad is the usual one). Differences from vanilla:

  • Every uniform needs a "name" (vanilla's files all have one), by which the effect sets it.
  • Every pass also gets an EffectInfo uniform block (see coolcatlib:screen_effect.glsl), and vanilla's Globals block.
  • The only external target is minecraft:main; its depth can be read with "use_depth_buffer": true.
  • Field Details

    • MAIN_TARGET

      public static final net.minecraft.resources.Identifier MAIN_TARGET
    • SCREENQUAD_VERTEX_SHADER

      public static final net.minecraft.resources.Identifier SCREENQUAD_VERTEX_SHADER
    • BLIT_FRAGMENT_SHADER

      public static final net.minecraft.resources.Identifier BLIT_FRAGMENT_SHADER
      Copies its In sampler, no uniforms.
    • RESERVED_UNIFORM_BLOCKS

      public static final Set<String> RESERVED_UNIFORM_BLOCKS
      Uniform block names taken by the runtime.
    • CODEC

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

    • ScreenEffectDefinition

      public ScreenEffectDefinition(Map<net.minecraft.resources.Identifier, net.minecraft.client.renderer.PostChainConfig.InternalTarget> 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.Identifier fragmentShader, String uniformBlock, ScreenEffectDefinition.UniformSpec... uniforms)
      One fragment shader over the screen: reads minecraft:main as In, writes a swap target, then copies it back. The simplest effect there is.
      Parameters:
      uniformBlock - the shader's uniform block name, ignored if uniforms is empty
      uniforms - the block's uniforms, in declaration order
    • uniformNames

      public Set<String> uniformNames()
      Every uniform name any pass declares.
    • 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.Identifier, net.minecraft.client.renderer.PostChainConfig.InternalTarget> 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