slightly faster bilinear interpolation #33

Merged
embeddedt merged 4 commits from rdh/celeritas:ao-better into stonecutter 2026-08-18 20:00:03 -04:00
3 changed files with 13 additions and 1 deletions
Showing only changes of commit f71bafdc1e - Show all commits

No files matched your search

@@ -32,7 +32,9 @@ public class ChunkMeshBufferBuilder {
} }
public void push(ChunkVertexEncoder.Vertex[] vertices, Material material) { public void push(ChunkVertexEncoder.Vertex[] vertices, Material material) {
postprocessVertices(vertices); if (this.encoder.supportsBilinearCorrection()) {
postprocessVertices(vertices);
}
var vertexStart = this.count * this.stride; var vertexStart = this.count * this.stride;
var vertexSize = vertices.length * this.stride; var vertexSize = vertices.length * this.stride;
@@ -5,6 +5,10 @@ import org.embeddedt.embeddium.impl.render.chunk.terrain.material.Material;
public interface ChunkVertexEncoder { public interface ChunkVertexEncoder {
long write(long ptr, Material material, Vertex vertex, int sectionIndex); long write(long ptr, Material material, Vertex vertex, int sectionIndex);
default boolean supportsBilinearCorrection() {
return true;
}
class Vertex { class Vertex {
public float x; public float x;
public float y; public float y;
@@ -144,6 +144,11 @@ public class XHFPTerrainVertex implements ChunkVertexEncoder, ContextAwareChunkV
this.ignoreMidBlock = false; this.ignoreMidBlock = false;
} }
@Override
public boolean supportsBilinearCorrection() {
return false;
}
@Override @Override
public long write(long ptr, public long write(long ptr,
Material material, Vertex vertex, int chunkId) { Material material, Vertex vertex, int chunkId) {
@@ -151,6 +156,7 @@ public class XHFPTerrainVertex implements ChunkVertexEncoder, ContextAwareChunkV
vSum += vertex.v; vSum += vertex.v;
vertexCount++; vertexCount++;
vertex.rdhFactor = 0;
this.baseEncoder.write(ptr, material, vertex, chunkId); this.baseEncoder.write(ptr, material, vertex, chunkId);
MemoryUtil.memPutShort(ptr + MC_ENTITY_OFFSET + 2, renderType); MemoryUtil.memPutShort(ptr + MC_ENTITY_OFFSET + 2, renderType);