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" archivesBaseName = "fabric-renderer-indigo"
version = getSubprojectVersion(project, "0.1.3") version = getSubprojectVersion(project, "0.1.4")
dependencies { dependencies {
compile project(path: ':fabric-api-base', configuration: 'dev') 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) { private void renderQuad(BakedQuad quad, Direction cullFace, Value defaultMaterial) {
final MutableQuadViewImpl editorQuad = this.editorQuad;
System.arraycopy(quad.getVertexData(), 0, editorBuffer, 0, 28); System.arraycopy(quad.getVertexData(), 0, editorBuffer, 0, 28);
editorQuad.cullFace(cullFace); editorQuad.cullFace(cullFace);
final Direction lightFace = quad.getFace(); final Direction lightFace = quad.getFace();
@ -129,13 +130,12 @@ public class TerrainFallbackConsumer extends AbstractQuadRenderer implements Con
tesselateSmooth(editorQuad, blockInfo.defaultLayerIndex, editorQuad.colorIndex()); tesselateSmooth(editorQuad, blockInfo.defaultLayerIndex, editorQuad.colorIndex());
} else { } else {
// vanilla compatibility hack // vanilla compatibility hack
// For flat lighting, if cull face is set always use neighbor light. // For flat lighting, cull face drives everything and light face is ignored.
// Otherwise still need to ensure geometry is updated before offsets are applied
if(cullFace == null) { if(cullFace == null) {
editorQuad.invalidateShape(); editorQuad.geometryFlags(0);
editorQuad.geometryFlags();
} else { } else {
editorQuad.geometryFlags(GeometryHelper.AXIS_ALIGNED_FLAG | GeometryHelper.LIGHT_FACE_FLAG); editorQuad.geometryFlags(GeometryHelper.LIGHT_FACE_FLAG);
editorQuad.lightFace(cullFace);
} }
chunkInfo.applyOffsets(editorQuad); chunkInfo.applyOffsets(editorQuad);
tesselateFlat(editorQuad, blockInfo.defaultLayerIndex, editorQuad.colorIndex()); tesselateFlat(editorQuad, blockInfo.defaultLayerIndex, editorQuad.colorIndex());