mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-19 20:09:39 +00:00
Fix Chisel energised voidstone missing its border corners (#2254)
Fixes #2246
This commit is contained in:
1 parent
85d0641a73
commit
0cae2be1f6
4 files changed
+227
-37
No files matched your search
+3
-36
@@ -36,7 +36,6 @@ import org.embeddedt.embeddium.impl.render.chunk.RenderPassConfiguration;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.compile.ChunkBuildBuffers;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.compile.ChunkBuildContext;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.data.MinecraftBuiltRenderSectionData;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.sprite.SpriteTransparencyLevel;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.terrain.material.Material;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.vertex.format.ChunkVertexEncoder;
|
||||
import org.embeddedt.embeddium.impl.util.QuadUtil;
|
||||
@@ -62,6 +61,7 @@ public class AngelicaChunkBuildContext extends ChunkBuildContext {
|
||||
@Getter private final FloatArrayList teBoundsScratch = new FloatArrayList();
|
||||
@Getter private final long[] deferredMask = new long[64];
|
||||
private final VertexArrayQuadView quadView;
|
||||
private final QuadMaterialSelector materialSelector = new QuadMaterialSelector();
|
||||
private final boolean hasColoredLight;
|
||||
private final float[] tintResult = new float[3];
|
||||
private List<IDynamicLightSource> chunkLightSources;
|
||||
@@ -116,27 +116,6 @@ public class AngelicaChunkBuildContext extends ChunkBuildContext {
|
||||
}
|
||||
}
|
||||
|
||||
private Material selectMaterial(Material material, TextureAtlasSprite sprite, boolean isShaderPackOverride,
|
||||
boolean useRenderPassOptimization) {
|
||||
// Don't apply transparency-based optimization when shader pack explicitly overrides the material
|
||||
if (isShaderPackOverride) {
|
||||
return material;
|
||||
}
|
||||
|
||||
if (useRenderPassOptimization
|
||||
&& sprite != null && sprite.getClass() == TextureAtlasSprite.class && !sprite.hasAnimationMetadata()) {
|
||||
final var transparencyLevel = ((SpriteExtension) sprite).celeritas$getTransparencyLevel();
|
||||
if (transparencyLevel == SpriteTransparencyLevel.OPAQUE
|
||||
&& material == AngelicaRenderPassConfiguration.CUTOUT_MIPPED_MATERIAL) {
|
||||
return AngelicaRenderPassConfiguration.SOLID_MATERIAL;
|
||||
} else if (material == AngelicaRenderPassConfiguration.TRANSLUCENT_MATERIAL && transparencyLevel != SpriteTransparencyLevel.TRANSLUCENT) {
|
||||
return AngelicaRenderPassConfiguration.CUTOUT_MIPPED_MATERIAL;
|
||||
}
|
||||
}
|
||||
|
||||
return material;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void copyRawBuffer(int[] rawBuffer, int vertexCount, int[] vertexStates,
|
||||
int[] shaderOverrideBlockIds,
|
||||
@@ -174,9 +153,7 @@ public class AngelicaChunkBuildContext extends ChunkBuildContext {
|
||||
final short originalBlockId = blockRenderContext.blockId;
|
||||
|
||||
int stateIdx = 0;
|
||||
boolean hasCachedMaterial = false;
|
||||
TextureAtlasSprite lastSprite = null;
|
||||
Material lastMaterial = null;
|
||||
materialSelector.reset(material, isShaderPackOverride, useRenderPassOptimization);
|
||||
this.fluidQuadLightFace = null;
|
||||
|
||||
for (int quadIdx = 0; quadIdx < numQuads; quadIdx++) {
|
||||
@@ -266,17 +243,7 @@ public class AngelicaChunkBuildContext extends ChunkBuildContext {
|
||||
// Apply RGB block light tint from provider
|
||||
applyBlockLightTint(worldX, worldY, worldZ, vertices);
|
||||
|
||||
final Material correctMaterial;
|
||||
if (material == AngelicaRenderPassConfiguration.TRANSLUCENT_MATERIAL && hasVertexTransparency) {
|
||||
correctMaterial = material;
|
||||
} else if (hasCachedMaterial && sprite == lastSprite) {
|
||||
correctMaterial = lastMaterial;
|
||||
} else {
|
||||
correctMaterial = selectMaterial(material, sprite, isShaderPackOverride, useRenderPassOptimization);
|
||||
lastSprite = sprite;
|
||||
lastMaterial = correctMaterial;
|
||||
hasCachedMaterial = true;
|
||||
}
|
||||
final Material correctMaterial = materialSelector.select(facing, sprite, hasVertexTransparency);
|
||||
final var builder = buffers.get(correctMaterial);
|
||||
|
||||
final int shaderOverrideBlockId = shaderOverrideBlockIds[quadIdx * 4];
|
||||
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
package com.gtnewhorizons.angelica.rendering.celeritas;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import org.embeddedt.embeddium.impl.model.quad.properties.ModelQuadFacing;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.sprite.SpriteTransparencyLevel;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.terrain.material.Material;
|
||||
|
||||
class QuadMaterialSelector {
|
||||
private Material material;
|
||||
private boolean canDemote;
|
||||
private int facesAtBaseMaterial;
|
||||
private TextureAtlasSprite lastSprite;
|
||||
private Material lastMaterial;
|
||||
|
||||
void reset(Material material, boolean isShaderPackOverride, boolean useRenderPassOptimization) {
|
||||
this.material = material;
|
||||
// Don't apply transparency-based optimization when shader pack explicitly overrides the material
|
||||
this.canDemote = useRenderPassOptimization && !isShaderPackOverride;
|
||||
facesAtBaseMaterial = 0;
|
||||
lastMaterial = null;
|
||||
}
|
||||
|
||||
Material select(ModelQuadFacing facing, TextureAtlasSprite sprite, boolean hasVertexTransparency) {
|
||||
final int faceBit = 1 << facing.ordinal();
|
||||
final Material correctMaterial;
|
||||
if ((facesAtBaseMaterial & faceBit) != 0 || (material == AngelicaRenderPassConfiguration.TRANSLUCENT_MATERIAL && hasVertexTransparency)) {
|
||||
correctMaterial = material;
|
||||
} else if (lastMaterial != null && sprite == lastSprite) {
|
||||
correctMaterial = lastMaterial;
|
||||
} else {
|
||||
correctMaterial = demote(sprite);
|
||||
lastSprite = sprite;
|
||||
lastMaterial = correctMaterial;
|
||||
}
|
||||
if (correctMaterial == material) {
|
||||
facesAtBaseMaterial |= faceBit;
|
||||
}
|
||||
return correctMaterial;
|
||||
}
|
||||
|
||||
private Material demote(TextureAtlasSprite sprite) {
|
||||
if (canDemote && sprite != null && sprite.getClass() == TextureAtlasSprite.class && !sprite.hasAnimationMetadata()) {
|
||||
final var transparencyLevel = transparencyLevel(sprite);
|
||||
if (transparencyLevel == SpriteTransparencyLevel.OPAQUE && material == AngelicaRenderPassConfiguration.CUTOUT_MIPPED_MATERIAL) {
|
||||
return AngelicaRenderPassConfiguration.SOLID_MATERIAL;
|
||||
} else if (material == AngelicaRenderPassConfiguration.TRANSLUCENT_MATERIAL && transparencyLevel != SpriteTransparencyLevel.TRANSLUCENT) {
|
||||
return AngelicaRenderPassConfiguration.CUTOUT_MIPPED_MATERIAL;
|
||||
}
|
||||
}
|
||||
|
||||
return material;
|
||||
}
|
||||
|
||||
SpriteTransparencyLevel transparencyLevel(TextureAtlasSprite sprite) {
|
||||
return ((SpriteExtension) sprite).celeritas$getTransparencyLevel();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user