Class EnhancedBlockModelLighter
java.lang.Object
net.minecraft.client.renderer.block.BlockModelLighter
net.neoforged.neoforge.client.model.ao.EnhancedBlockModelLighter
Entrypoint and main class of our enhanced AO pipeline.
Vanilla's AO logic works well for faces that are axis-aligned.
That computation is replicated in FullFaceCalculator, with some bug fixes.
The job of the enhanced pipeline is to handle faces that are more complicated,
by combining multiple full faces as needed using interpolation.
Compared to vanilla, we also remove any assumption about vertex order in the quad.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final recordCache these objects so that they don't need to be reallocated for everyEnhancedBlockModelLighter.Nested classes/interfaces inherited from class BlockModelLighter
BlockModelLighter.AdjacencyInfo, BlockModelLighter.Cache, BlockModelLighter.SizeInfo -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final floatprivate static final ThreadLocal<EnhancedBlockModelLighter.AoObjectCache> private static final floatprivate final FullFaceCalculatorCalculator for full faces.private static final booleanDebug option to compare the emulated vanilla AO with the actual vanilla AO.private static final org.slf4j.Loggerprivate static final floatprivate final float[]Fields inherited from class BlockModelLighter
cache, CACHE, CHECK_LIGHT, faceCubic, faceShape, scratchPos -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcalculateAxisAligned(BlockAndTintGetter level, BlockState state, BlockPos pos, Direction direction, BakedQuad quad, QuadInstance outputInstance) Computes AO for an axis-aligned quad.private voidcalculateIrregular(BlockAndTintGetter level, BlockState state, BlockPos pos, BakedQuad quad, QuadInstance outputInstance) Computes AO for a general quad.private static floatinterpolateBrightness(AoCalculatedFace in, float[] weights) Interpolates brightness from the 4 corners of a face.private static intinterpolateLightmap(AoCalculatedFace in, float[] weights) Interpolates lightmap from the 4 corners of a face.private static intlerpLightmap(int lightmap1, float w1, int lightmap2, float w2) Interpolates two lightmaps linearly.(package private) static intmaxLightmap(int lightmap1, int lightmap2) static BlockModelLightervoidprepareQuadAmbientOcclusion(BlockAndTintGetter level, BlockState state, BlockPos pos, BakedQuad quad, QuadInstance outputInstance) voidprepareQuadFlat(BlockAndTintGetter level, BlockState state, BlockPos pos, int lightCoords, BakedQuad quad, QuadInstance outputInstance) voidreset()Methods inherited from class BlockModelLighter
clearCache, enableCaching, getLightCoords, prepareQuadShape
-
Field Details
-
COMPARE_WITH_VANILLA
private static final boolean COMPARE_WITH_VANILLADebug option to compare the emulated vanilla AO with the actual vanilla AO. Only does something if emulated AO is enabled. -
LOGGER
private static final org.slf4j.Logger LOGGER -
AO_OBJECT_CACHE
-
calculator
Calculator for full faces. -
weights
private final float[] weights -
AO_EPS
private static final float AO_EPS- See Also:
-
AVERAGE_WEIGHT
private static final float AVERAGE_WEIGHT- See Also:
-
MAX_WEIGHT
private static final float MAX_WEIGHT- See Also:
-
-
Constructor Details
-
EnhancedBlockModelLighter
public EnhancedBlockModelLighter()
-
-
Method Details
-
newInstance
-
reset
public void reset()- Overrides:
resetin classBlockModelLighter
-
prepareQuadAmbientOcclusion
public void prepareQuadAmbientOcclusion(BlockAndTintGetter level, BlockState state, BlockPos pos, BakedQuad quad, QuadInstance outputInstance) - Overrides:
prepareQuadAmbientOcclusionin classBlockModelLighter
-
calculateAxisAligned
private void calculateAxisAligned(BlockAndTintGetter level, BlockState state, BlockPos pos, Direction direction, BakedQuad quad, QuadInstance outputInstance) Computes AO for an axis-aligned quad.This is similar to vanilla in how we select whether to use the inside or outside light. However, we still use our own interpolation logic which does not make any assumption about vertex winding order.
-
calculateIrregular
private void calculateIrregular(BlockAndTintGetter level, BlockState state, BlockPos pos, BakedQuad quad, QuadInstance outputInstance) Computes AO for a general quad. Projects onto each axis, computes the AO, then combines proportionally to the square of each normal component. -
prepareQuadFlat
public void prepareQuadFlat(BlockAndTintGetter level, BlockState state, BlockPos pos, int lightCoords, BakedQuad quad, QuadInstance outputInstance) - Overrides:
prepareQuadFlatin classBlockModelLighter
-
interpolateBrightness
Interpolates brightness from the 4 corners of a face. -
interpolateLightmap
Interpolates lightmap from the 4 corners of a face. -
lerpLightmap
private static int lerpLightmap(int lightmap1, float w1, int lightmap2, float w2) Interpolates two lightmaps linearly. -
maxLightmap
static int maxLightmap(int lightmap1, int lightmap2)
-