Record Class VfxMaterial

java.lang.Object
java.lang.Record
net.ixdarklord.coolcatcanvas.api.client.vfx.VfxMaterial
Record Components:
texture - a full texture path, such as mymod:textures/vfx/ember.png
softness - over how many blocks the effect fades out as it nears whatever is behind it, so it never ends in a hard line where it passes through a wall or the ground; 0 for a hard edge
shader - the fragment shader the material is drawn with, such as mymod:vfx/portal for assets/mymod/shaders/vfx/portal.fsh; null for the built-in textured one. See withShader(net.minecraft.resources.ResourceLocation)
smooth - whether the texture is filtered smoothly (linear) or drawn pixel for pixel (nearest), as blocks and items are; smooth by default. See withSmoothing(boolean)

public record VfxMaterial(net.minecraft.resources.ResourceLocation texture, VfxBlend blend, float softness, @Nullable net.minecraft.resources.ResourceLocation shader, boolean smooth) extends Record
What a world effect is drawn with: a texture, how it blends, and how softly it meets solid things. Everything drawn with equal materials in a frame goes out in one draw call.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final float
     
    static final net.minecraft.resources.ResourceLocation
    A round, soft glow: the bread and butter of light effects.
    static final net.minecraft.resources.ResourceLocation
    The procedural rift shader CoolCatLib ships (WorldRifts draws with it).
    static final net.minecraft.resources.ResourceLocation
    A thin ring, for shockwaves and pulses.
    static final net.minecraft.resources.ResourceLocation
    A cloudy puff, for smoke and mist.
    static final net.minecraft.resources.ResourceLocation
    A small bright core with a wide faint halo.
    static final net.minecraft.resources.ResourceLocation
    A four-pointed star with thin rays.
    static final net.minecraft.resources.ResourceLocation
    A streak that is bright along its middle and fades to both ends: for sparks, beams and trails.
  • Constructor Summary

    Constructors
    Constructor
    Description
    VfxMaterial(net.minecraft.resources.ResourceLocation texture, VfxBlend blend, float softness)
     
    VfxMaterial(net.minecraft.resources.ResourceLocation texture, VfxBlend blend, float softness, @Nullable net.minecraft.resources.ResourceLocation shader)
     
    VfxMaterial(net.minecraft.resources.ResourceLocation texture, VfxBlend blend, float softness, @Nullable net.minecraft.resources.ResourceLocation shader, boolean smooth)
    Creates an instance of a VfxMaterial record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    additive(net.minecraft.resources.ResourceLocation texture)
    An additive material with the default softness.
    alpha(net.minecraft.resources.ResourceLocation texture)
     
    Returns the value of the blend record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    luminous(net.minecraft.resources.ResourceLocation texture)
     
    @Nullable net.minecraft.resources.ResourceLocation
    Returns the value of the shader record component.
    boolean
    Returns the value of the smooth record component.
    float
    Returns the value of the softness record component.
    net.minecraft.resources.ResourceLocation
    Returns the value of the texture record component.
    final String
    Returns a string representation of this record class.
    withShader(net.minecraft.resources.ResourceLocation fragmentShader)
    The same material drawn with a fragment shader of the mod's own, for what a texture cannot do: portals, rifts, heat haze, anything procedural.
    withSmoothing(boolean smooth)
    The same material with its texture filtered smoothly (true, the default: soft glows and smoke) or drawn pixel for pixel (false: pixel art, such as block and item textures, stays crisp up close).
    withSoftness(float softness)
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • RIFT_SHADER

      public static final net.minecraft.resources.ResourceLocation RIFT_SHADER
      The procedural rift shader CoolCatLib ships (WorldRifts draws with it).
    • GLOW

      public static final net.minecraft.resources.ResourceLocation GLOW
      A round, soft glow: the bread and butter of light effects.
    • SPARKLE

      public static final net.minecraft.resources.ResourceLocation SPARKLE
      A small bright core with a wide faint halo.
    • STAR

      public static final net.minecraft.resources.ResourceLocation STAR
      A four-pointed star with thin rays.
    • RING

      public static final net.minecraft.resources.ResourceLocation RING
      A thin ring, for shockwaves and pulses.
    • SMOKE

      public static final net.minecraft.resources.ResourceLocation SMOKE
      A cloudy puff, for smoke and mist.
    • STREAK

      public static final net.minecraft.resources.ResourceLocation STREAK
      A streak that is bright along its middle and fades to both ends: for sparks, beams and trails.
    • DEFAULT_SOFTNESS

      public static final float DEFAULT_SOFTNESS
      See Also:
  • Constructor Details

    • VfxMaterial

      public VfxMaterial(net.minecraft.resources.ResourceLocation texture, VfxBlend blend, float softness)
    • VfxMaterial

      public VfxMaterial(net.minecraft.resources.ResourceLocation texture, VfxBlend blend, float softness, @Nullable @Nullable net.minecraft.resources.ResourceLocation shader)
    • VfxMaterial

      public VfxMaterial(net.minecraft.resources.ResourceLocation texture, VfxBlend blend, float softness, @Nullable @Nullable net.minecraft.resources.ResourceLocation shader, boolean smooth)
      Creates an instance of a VfxMaterial record class.
      Parameters:
      texture - the value for the texture record component
      blend - the value for the blend record component
      softness - the value for the softness record component
      shader - the value for the shader record component
      smooth - the value for the smooth record component
  • Method Details

    • additive

      public static VfxMaterial additive(net.minecraft.resources.ResourceLocation texture)
      An additive material with the default softness.
    • alpha

      public static VfxMaterial alpha(net.minecraft.resources.ResourceLocation texture)
    • luminous

      public static VfxMaterial luminous(net.minecraft.resources.ResourceLocation texture)
    • withSoftness

      public VfxMaterial withSoftness(float softness)
    • withSmoothing

      public VfxMaterial withSmoothing(boolean smooth)
      The same material with its texture filtered smoothly (true, the default: soft glows and smoke) or drawn pixel for pixel (false: pixel art, such as block and item textures, stays crisp up close).
    • withShader

      public VfxMaterial withShader(net.minecraft.resources.ResourceLocation fragmentShader)
      The same material drawn with a fragment shader of the mod's own, for what a texture cannot do: portals, rifts, heat haze, anything procedural. The shader takes the place of coolcatcanvas:vfx/quad:
      
       #version 150
       #moj_import <coolcatcanvas:vfx.glsl>   // VfxTime.x (seconds), vfx_depth_fade(...)
       uniform sampler2D Sampler0;               // the material's texture
       uniform sampler2D DepthSampler;           // the scene's depth
       in vec2 texCoord;                         // the quad's UVs, as given to VfxDraw
       in vec4 vertexColor;                      // the colour given to VfxDraw
       out vec4 fragColor;
       
      It should multiply its alpha by vfx_depth_fade(texelFetch(DepthSampler, ivec2(gl_FragCoord.xy), 0).r, gl_FragCoord.z) to hide behind solid things. A shader has no uniforms of its own; what changes from one shape to the next travels in the colour and in the UVs (VfxDraw.quad(net.minecraft.world.phys.Vec3, net.minecraft.world.phys.Vec3, net.minecraft.world.phys.Vec3, net.minecraft.world.phys.Vec3, float, float, float, float, int) takes any UV range).
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      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.
    • texture

      public net.minecraft.resources.ResourceLocation texture()
      Returns the value of the texture record component.
      Returns:
      the value of the texture record component
    • blend

      public VfxBlend blend()
      Returns the value of the blend record component.
      Returns:
      the value of the blend record component
    • softness

      public float softness()
      Returns the value of the softness record component.
      Returns:
      the value of the softness record component
    • shader

      @Nullable public @Nullable net.minecraft.resources.ResourceLocation shader()
      Returns the value of the shader record component.
      Returns:
      the value of the shader record component
    • smooth

      public boolean smooth()
      Returns the value of the smooth record component.
      Returns:
      the value of the smooth record component