Class QuadLighter
java.lang.Object
net.neoforged.neoforge.client.model.lighting.QuadLighter
- Direct Known Subclasses:
FlatQuadLighter
,SmoothQuadLighter
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 Summary
Modifier and TypeFieldDescriptionprivate final org.joml.Vector3f
private final org.joml.Vector3f
private final org.joml.Vector3f
private final float[]
private final float[]
private final float[]
private int
private final BlockColors
private int
private BlockAndTintGetter
private final int[]
private final byte[][]
private final int[]
private BlockPos
private final float[][]
private BlockState
private static final float[]
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract float
calculateBrightness
(float[] position) protected abstract int
calculateLightmap
(float[] position, byte[] normal) static float
calculateShade
(float normalX, float normalY, float normalZ, boolean constantAmbientLight) protected abstract void
computeLightingAt
(BlockAndTintGetter level, BlockPos pos, BlockState state) final void
Compute the brightness and lightmap values for each vertex of this quad.private float[]
getColorFast
(int tintIndex) final float[]
Returns the computed brightness for each vertex of this quad.final int[]
Returns the computed lightmap for each vertex of this quad.final void
process
(VertexConsumer consumer, PoseStack.Pose pose, BakedQuad quad, int overlay) final void
reset()
Invalidate and reset any cached state of this lighter.final void
setup
(BlockAndTintGetter level, BlockPos pos, BlockState state) Set up this lighter to light quads of the given block.
-
Field Details
-
WHITE
private static final float[] WHITE -
colors
-
currentHash
private int currentHash -
level
-
pos
-
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
-
-
Method Details
-
computeLightingAt
-
calculateBrightness
protected abstract float calculateBrightness(float[] position) -
calculateLightmap
protected abstract int calculateLightmap(float[] position, byte[] normal) -
setup
Set up this lighter to light quads of the given block.- Parameters:
level
- the region containing this blockpos
- the position of the block in the given regionstate
- the block state at this position
-
reset
public final void reset()Invalidate and reset any cached state of this lighter. -
computeLightingForQuad
Compute the brightness and lightmap values for each vertex of this quad. After a call to this method, the values may be accessed usinggetComputedBrightness()
andgetComputedLightmap()
.- 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)
-