Fix #223 (bad flat lighting on irregular cull face quads) (#224)

This commit is contained in:
grondag 2019-05-29 23:04:12 +02:00 committed by asie
parent 4d26f9bab4
commit 620b4d6141
2 changed files with 6 additions and 6 deletions

View file

@ -1,5 +1,5 @@
archivesBaseName = "fabric-renderer-indigo"
version = getSubprojectVersion(project, "0.1.3")
version = getSubprojectVersion(project, "0.1.4")
dependencies {
compile project(path: ':fabric-api-base', configuration: 'dev')

View file

@ -109,6 +109,7 @@ public class TerrainFallbackConsumer extends AbstractQuadRenderer implements Con
}
private void renderQuad(BakedQuad quad, Direction cullFace, Value defaultMaterial) {
final MutableQuadViewImpl editorQuad = this.editorQuad;
System.arraycopy(quad.getVertexData(), 0, editorBuffer, 0, 28);
editorQuad.cullFace(cullFace);
final Direction lightFace = quad.getFace();
@ -129,13 +130,12 @@ public class TerrainFallbackConsumer extends AbstractQuadRenderer implements Con
tesselateSmooth(editorQuad, blockInfo.defaultLayerIndex, editorQuad.colorIndex());
} else {
// vanilla compatibility hack
// For flat lighting, if cull face is set always use neighbor light.
// Otherwise still need to ensure geometry is updated before offsets are applied
// For flat lighting, cull face drives everything and light face is ignored.
if(cullFace == null) {
editorQuad.invalidateShape();
editorQuad.geometryFlags();
editorQuad.geometryFlags(0);
} else {
editorQuad.geometryFlags(GeometryHelper.AXIS_ALIGNED_FLAG | GeometryHelper.LIGHT_FACE_FLAG);
editorQuad.geometryFlags(GeometryHelper.LIGHT_FACE_FLAG);
editorQuad.lightFace(cullFace);
}
chunkInfo.applyOffsets(editorQuad);
tesselateFlat(editorQuad, blockInfo.defaultLayerIndex, editorQuad.colorIndex());