Class EnhancedAoRenderStorage
java.lang.Object
net.minecraft.client.renderer.block.ModelBlockRenderer.CommonRenderStorage
net.minecraft.client.renderer.block.ModelBlockRenderer.AmbientOcclusionRenderStorage
net.neoforged.neoforge.client.model.ao.EnhancedAoRenderStorage
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 everyEnhancedAoRenderStorage. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final floatprivate static final ThreadLocal<EnhancedAoRenderStorage.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 BakedQuadprivate static final org.slf4j.Loggerprivate static final floatprivate final float[]Fields inherited from class net.minecraft.client.renderer.block.ModelBlockRenderer.AmbientOcclusionRenderStorage
faceShapeFields inherited from class net.minecraft.client.renderer.block.ModelBlockRenderer.CommonRenderStorage
brightness, cache, faceCubic, facePartial, lightmap, scratchPos, tintCacheIndex, tintCacheValue -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidapplyFlatQuadBrightness(BlockAndTintGetter level, BakedQuad quad, ModelBlockRenderer.CommonRenderStorage storage) "Enhanced" flat shading logic.voidcalculate(BlockAndTintGetter level, BlockState state, BlockPos pos, Direction direction, boolean shade) private voidcalculateAxisAligned(BlockAndTintGetter level, BlockState state, BlockPos pos, Direction direction, boolean shade) Computes AO for an axis-aligned quad.private voidcalculateIrregular(BlockAndTintGetter level, BlockState state, BlockPos pos, boolean shade) Computes AO for a general quad.voidcaptureQuad(BakedQuad 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) private static floatnormalComponent(int normal, int axis) Unpacks a normal component.private static floatvertexPos(int[] vertices, int vertex, int axis) Extracts the position of a vertex from quad data.Methods inherited from class net.minecraft.client.renderer.block.ModelBlockRenderer.AmbientOcclusionRenderStorage
blend
-
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 -
currentQuad
-
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
-
EnhancedAoRenderStorage
public EnhancedAoRenderStorage()
-
-
Method Details
-
newInstance
-
applyFlatQuadBrightness
public static void applyFlatQuadBrightness(BlockAndTintGetter level, BakedQuad quad, ModelBlockRenderer.CommonRenderStorage storage) "Enhanced" flat shading logic. -
captureQuad
- Overrides:
captureQuadin classModelBlockRenderer.AmbientOcclusionRenderStorage
-
calculate
public void calculate(BlockAndTintGetter level, BlockState state, BlockPos pos, Direction direction, boolean shade) - Overrides:
calculatein classModelBlockRenderer.AmbientOcclusionRenderStorage
-
calculateAxisAligned
private void calculateAxisAligned(BlockAndTintGetter level, BlockState state, BlockPos pos, Direction direction, boolean shade) 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, boolean shade) Computes AO for a general quad. Projects onto each axis, computes the AO, then combines proportionally to the square of each normal component. -
vertexPos
private static float vertexPos(int[] vertices, int vertex, int axis) Extracts the position of a vertex from quad data.- Parameters:
vertices- quad datavertex- vertex index, from 0 to 3 includedaxis- axis index, for 0 to 2 included
-
normalComponent
private static float normalComponent(int normal, int axis) Unpacks a normal component. -
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)
-