rasterized occlusion culling #38
No files matched your search
@@ -152,6 +152,16 @@ tasks.register('jmh', JavaExec) {
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register('rasterCullReport', JavaExec) {
|
||||
group = 'verification'
|
||||
description = 'Reports visible section counts per world and camera placement.'
|
||||
|
||||
classpath = sourceSets.jmh.runtimeClasspath
|
||||
mainClass = 'org.embeddedt.embeddium.impl.render.chunk.occlusion.bench.RasterCullReport'
|
||||
|
||||
maxHeapSize = '1g'
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
package org.embeddedt.embeddium.impl.render.chunk.occlusion.bench;
|
||||
|
||||
import org.embeddedt.embeddium.impl.render.chunk.RenderSection;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.occlusion.SectionLattice;
|
||||
import org.embeddedt.embeddium.impl.render.viewport.Viewport;
|
||||
|
||||
public final class RasterCullReport {
|
||||
private static final int RENDER_DISTANCE = 32;
|
||||
private static final int YAW_STEPS = 8;
|
||||
private static final WorldType[] WORLDS = { WorldType.SURFACE, WorldType.CAVES };
|
||||
|
||||
private RasterCullReport() {
|
||||
}
|
||||
|
||||
private record Placement(String name, double y, float pitch) {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
BenchPlatform.ensureInitialized();
|
||||
|
||||
System.out.printf("%-8s %-8s %10s %10s%n", "world", "camera", "visited", "visible");
|
||||
System.out.println("-".repeat(42));
|
||||
|
||||
for (WorldType world : WORLDS) {
|
||||
var syntheticWorld = new SyntheticWorld(world, RENDER_DISTANCE, true);
|
||||
float searchDistance = syntheticWorld.getSearchDistance();
|
||||
int numRegions = BenchPlatform.regionManager().getRegionIdsLength();
|
||||
|
||||
var lattice = new SectionLattice(SyntheticWorld.MIN_SECTION_Y, SyntheticWorld.MAX_SECTION_Y, false);
|
||||
|
||||
for (RenderSection section : syntheticWorld.getConstructionOrder()) {
|
||||
lattice.attach(section);
|
||||
}
|
||||
|
||||
int frame = 0;
|
||||
|
||||
for (Placement placement : placements()) {
|
||||
long visited = 0;
|
||||
long visible = 0;
|
||||
|
||||
for (int step = 0; step < YAW_STEPS; step++) {
|
||||
Viewport viewport = Cameras.viewport(8.5, placement.y(), 8.5,
|
||||
(360.0f / YAW_STEPS) * step, placement.pitch(), RENDER_DISTANCE);
|
||||
|
||||
var visitor = new CountingVisitor();
|
||||
lattice.ensureWindowCovers(viewport.getChunkCoord(), searchDistance);
|
||||
lattice.findVisible(visitor, viewport, searchDistance, numRegions, true, true, ++frame);
|
||||
|
||||
visited += visitor.visited;
|
||||
visible += visitor.visible;
|
||||
}
|
||||
|
||||
System.out.printf("%-8s %-8s %10d %10d%n", world, placement.name(),
|
||||
visited / YAW_STEPS, visible / YAW_STEPS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Placement[] placements() {
|
||||
double surfaceY = Cameras.surfaceCameraY(0, 0);
|
||||
|
||||
return new Placement[] {
|
||||
new Placement("surface", surfaceY, Cameras.DEFAULT_PITCH),
|
||||
new Placement("treetop", surfaceY + 16.0, Cameras.DEFAULT_PITCH),
|
||||
new Placement("high", 200.0, -45.0f),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,8 @@ public class Constants {
|
||||
static final int PRECISE_PIXEL_SIZE = 1 << PRECISION_BITS;
|
||||
static final int PRECISE_PIXEL_CENTER = PRECISE_PIXEL_SIZE / 2;
|
||||
static final int SCANT_PRECISE_PIXEL_CENTER = PRECISE_PIXEL_CENTER - 1;
|
||||
static final int TILE_WIDTH_BITS = 8;
|
||||
// CELERITAS: 8 upstream; 7 gives a 1024px buffer, which matches 2048's culling to within 0.1% at ~1.7x the speed
|
||||
static final int TILE_WIDTH_BITS = 7;
|
||||
static final int TILE_WIDTH = 1 << TILE_WIDTH_BITS;
|
||||
static final int TILE_WIDTH_MASK = TILE_WIDTH - 1;
|
||||
public static final int PIXEL_WIDTH = TILE_WIDTH * TILE_PIXEL_DIAMETER;
|
||||
@@ -48,7 +49,8 @@ public class Constants {
|
||||
* clamp to this to ensure value + half pixel rounds down to last pixel.
|
||||
*/
|
||||
static final int PRECISE_WIDTH_CLAMP = PRECISE_WIDTH - PRECISE_PIXEL_CENTER;
|
||||
static final int TILE_HEIGHT_BITS = 8;
|
||||
// CELERITAS: 8 upstream. See TILE_WIDTH_BITS
|
||||
static final int TILE_HEIGHT_BITS = 7;
|
||||
static final int TILE_HEIGHT = 1 << TILE_HEIGHT_BITS;
|
||||
static final int TILE_HEIGHT_MASK = (TILE_HEIGHT - 1) << TILE_WIDTH_BITS;
|
||||
public static final int PIXEL_HEIGHT = TILE_HEIGHT * TILE_PIXEL_DIAMETER;
|
||||
|
||||
Reference in new issue
Block a user