java.lang.Object
net.neoforged.neoforge.client.model.lighting.QuadLighter
Direct Known Subclasses:
FlatQuadLighter, SmoothQuadLighter

public abstract class QuadLighter extends Object
Base class for all quad lighting providers.

Contains all the shared elements needed for BakedQuad processing and defers lighting logic to inheritors.

See Also:
  • Field Details

    • WHITE

      private static final float[] WHITE
    • colors

      private final BlockColors colors
    • currentHash

      private int currentHash
    • level

      private BlockAndTintGetter level
    • pos

      private BlockPos pos
    • state

      private BlockState state
    • cachedTintIndex

      private int cachedTintIndex
    • cachedTintColor

      private final float[] cachedTintColor
    • brightness

      private final float[] brightness
    • lightmap

      private final int[] lightmap
    • positions

      private final float[][] positions
    • normals

      private final byte[][] normals
    • packedLightmaps

      private final int[] packedLightmaps
    • adjustedPosition

      private final float[] adjustedPosition
    • a

      private final org.joml.Vector3f a
    • ab

      private final org.joml.Vector3f ab
    • ac

      private final org.joml.Vector3f ac
  • Constructor Details

    • QuadLighter

      protected QuadLighter(BlockColors colors)
  • Method Details

    • computeLightingAt

      protected abstract void computeLightingAt(BlockAndTintGetter level, BlockPos pos, BlockState state)
    • calculateBrightness

      protected abstract float calculateBrightness(float[] position)
    • calculateLightmap

      protected abstract int calculateLightmap(float[] position, byte[] normal)
    • setup

      public final void setup(BlockAndTintGetter level, BlockPos pos, BlockState state)
      Set up this lighter to light quads of the given block.
      Parameters:
      level - the region containing this block
      pos - the position of the block in the given region
      state - the block state at this position
    • reset

      public final void reset()
      Invalidate and reset any cached state of this lighter.
    • computeLightingForQuad

      public final void computeLightingForQuad(BakedQuad quad)
      Compute the brightness and lightmap values for each vertex of this quad. After a call to this method, the values may be accessed using getComputedBrightness() and getComputedLightmap().
      Parameters:
      quad - the quad to compute lightmap values for
    • getComputedBrightness

      public final float[] getComputedBrightness()
      Returns the computed brightness for each vertex of this quad.

      The returned array is only valid until this lighter is asked to light another quad.

    • getComputedLightmap

      public final int[] getComputedLightmap()
      Returns the computed lightmap for each vertex of this quad.

      The returned array is only valid until this lighter is asked to light another quad.

    • process

      public final void process(VertexConsumer consumer, PoseStack.Pose pose, BakedQuad quad, int overlay)
    • getColorFast

      private float[] getColorFast(int tintIndex)
    • calculateShade

      public static float calculateShade(float normalX, float normalY, float normalZ, boolean constantAmbientLight)