mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-10-25 20:22:22 +00:00
Fix Little Tiles rendering issues (#2238)
This commit is contained in:
1 parent
78abc05711
commit
cae4fea2bb
5 files changed
+70
-2
No files matched your search
@@ -442,6 +442,7 @@ public enum Mixins implements IMixins {
|
||||
, "celeritas.terrain.MixinWorld_AwaitingDescriptor"
|
||||
, "celeritas.terrain.MixinRenderRegion"
|
||||
, "celeritas.terrain.MixinChunkRenderList"
|
||||
, "celeritas.terrain.MixinChunkMeshBufferBuilder"
|
||||
, "celeritas.terrain.MixinVisibleChunkCollector"
|
||||
, "celeritas.terrain.MixinRenderListManager"
|
||||
, "celeritas.terrain.MixinSectionRenderDataStorage"
|
||||
|
||||
+4
-2
@@ -76,8 +76,10 @@ public class AngelicaChunkBuildContext extends ChunkBuildContext {
|
||||
super(renderPassConfiguration);
|
||||
this.textureAtlas = (TextureMapExtension) Minecraft.getMinecraft().getTextureMapBlocks();
|
||||
this.worldSlice = new WorldSlice(world);
|
||||
this.smoothLightPipeline = new SmoothLightPipeline(lightDataCache, VanillaDiffuseProvider.INSTANCE, false);
|
||||
this.flatLightPipeline = new FlatLightPipeline(lightDataCache, VanillaDiffuseProvider.INSTANCE, false);
|
||||
// Shade by the quad normal so sloped quads blend the face shades instead of snapping to the dominant axis;
|
||||
// axis-aligned quads come out the same either way
|
||||
this.smoothLightPipeline = new SmoothLightPipeline(lightDataCache, VanillaDiffuseProvider.INSTANCE, true);
|
||||
this.flatLightPipeline = new FlatLightPipeline(lightDataCache, VanillaDiffuseProvider.INSTANCE, true);
|
||||
this.quadView = new VertexArrayQuadView(vertices);
|
||||
this.hasColoredLight = quadLightData instanceof ExtQuadLightData;
|
||||
}
|
||||
|
||||
@@ -109,6 +109,18 @@ public class VertexArrayQuadView implements ModelQuadView {
|
||||
return trueNormal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Directional shading follows the geometry, never the tessellator normal. In 1.7.10 chunk rendering a normal set
|
||||
* through setNormal has no visible effect (the face shade is baked by RenderBlocks), so no block relies on it for
|
||||
* shading. It does stay set until the next startDrawing though, so a normal from inventory-style code early in a
|
||||
* block would otherwise shade every later face of that block, e.g. a renderStandardBlock cube with all sides lit
|
||||
* like the top.
|
||||
*/
|
||||
@Override
|
||||
public int getModFaceNormal() {
|
||||
return trueNormal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cull face of a quad. This is distinct from the light face, as it will not be set for non-axis-aligned
|
||||
* and non-block-grid-aligned quads (i.e. quads on the surface of the 1x1x1 cube).
|
||||
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.celeritas.terrain;
|
||||
|
||||
import org.embeddedt.embeddium.impl.render.chunk.vertex.builder.ChunkMeshBufferBuilder;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.vertex.format.ChunkVertexEncoder;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
/**
|
||||
* The bilinear AO correction assumes the four vertices are the corners of a parallelogram, in order: it derives the
|
||||
* twist from c1 + c3 - c0 - c2 and the shader weights it by each fragment's position in that parallelogram. A triangle
|
||||
* sent through the tessellator as a quad with a repeated vertex has no such parallelogram, so the computed twist is just
|
||||
* the difference between two of its corners, and the correction lands along an edge the neighbouring triangle does not
|
||||
* correct. That shows up as a visible brightness step along every such edge.
|
||||
*/
|
||||
@Mixin(value = ChunkMeshBufferBuilder.class, remap = false)
|
||||
public abstract class MixinChunkMeshBufferBuilder {
|
||||
|
||||
@Inject(method = "postprocessVertices", at = @At("HEAD"), cancellable = true)
|
||||
private static void angelica$skipCorrectionForTriangles(ChunkVertexEncoder.Vertex[] vertices, CallbackInfo ci) {
|
||||
if (vertices.length != 4 || !angelica$hasRepeatedVertex(vertices)) {
|
||||
return;
|
||||
}
|
||||
for (ChunkVertexEncoder.Vertex vertex : vertices) {
|
||||
vertex.rdhFactor = 0;
|
||||
}
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
@Unique
|
||||
private static boolean angelica$hasRepeatedVertex(ChunkVertexEncoder.Vertex[] vertices) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for (int j = i + 1; j < 4; j++) {
|
||||
final ChunkVertexEncoder.Vertex a = vertices[i];
|
||||
final ChunkVertexEncoder.Vertex b = vertices[j];
|
||||
if (a.x == b.x && a.y == b.y && a.z == b.z) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -67,6 +67,14 @@ public class MixinTessellator implements StateAwareTessellator, BiomeBlendTessel
|
||||
@Inject(method = "addVertex", at = @At("RETURN"))
|
||||
private void addElementState(CallbackInfo ci) {
|
||||
if (!celeritasMeshing) return;
|
||||
|
||||
// Vanilla only writes the normal slot after setNormal, leaving whatever an earlier vertex put there otherwise.
|
||||
// Zero means "no normal" to the light pipeline, which then falls back to the computed face normal.
|
||||
final Tessellator self = (Tessellator) (Object) this;
|
||||
if (!self.hasNormals) {
|
||||
self.rawBuffer[self.rawBufferIndex - 2] = 0;
|
||||
}
|
||||
|
||||
int state = 0;
|
||||
|
||||
if (appliedAo) state |= StateAwareTessellator.RENDERED_WITH_VANILLA_AO;
|
||||
|
||||
Reference in new issue
Block a user