From 49e8398565fbda946692e64dbbc26052308e83d4 Mon Sep 17 00:00:00 2001 From: Svjatoslav Agejenko Date: Sun, 15 Mar 2026 14:22:55 +0200 Subject: [PATCH] feat(benchmark): add StarGridTest benchmark for billboard rendering Add a new benchmark test that measures glowing point (billboard) rendering performance using a 16x16x16 grid of stars with randomized colors. Also increase wireframe line width for better visibility. --- .../examples/benchmark/GraphicsBenchmark.java | 2 + .../e3d/examples/benchmark/StarGridTest.java | 85 +++++++++++++++++++ .../benchmark/WireframeCubesTest.java | 2 +- .../e3d/examples/benchmark/package-info.java | 1 + 4 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 src/main/java/eu/svjatoslav/sixth/e3d/examples/benchmark/StarGridTest.java diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/examples/benchmark/GraphicsBenchmark.java b/src/main/java/eu/svjatoslav/sixth/e3d/examples/benchmark/GraphicsBenchmark.java index d336dee..dc93a19 100644 --- a/src/main/java/eu/svjatoslav/sixth/e3d/examples/benchmark/GraphicsBenchmark.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/examples/benchmark/GraphicsBenchmark.java @@ -35,6 +35,7 @@ import java.util.List; *
  • {@link SolidCubesTest} - Solid-color polygon rendering
  • *
  • {@link TexturedCubesTest} - Textured polygon rendering
  • *
  • {@link WireframeCubesTest} - Line rendering
  • + *
  • {@link StarGridTest} - Billboard (glowing point) rendering
  • * */ public class GraphicsBenchmark implements FrameListener, KeyboardInputHandler { @@ -92,6 +93,7 @@ public class GraphicsBenchmark implements FrameListener, KeyboardInputHandler { tests.add(new SolidCubesTest()); tests.add(new TexturedCubesTest()); tests.add(new WireframeCubesTest()); + tests.add(new StarGridTest()); } private void startNextTest() { diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/examples/benchmark/StarGridTest.java b/src/main/java/eu/svjatoslav/sixth/e3d/examples/benchmark/StarGridTest.java new file mode 100644 index 0000000..967a621 --- /dev/null +++ b/src/main/java/eu/svjatoslav/sixth/e3d/examples/benchmark/StarGridTest.java @@ -0,0 +1,85 @@ +/* + * Sixth 3D engine demos. Author: Svjatoslav Agejenko. + * This project is released under Creative Commons Zero (CC0) license. + */ + +package eu.svjatoslav.sixth.e3d.examples.benchmark; + +import eu.svjatoslav.sixth.e3d.geometry.Point3D; +import eu.svjatoslav.sixth.e3d.renderer.raster.Color; +import eu.svjatoslav.sixth.e3d.renderer.raster.ShapeCollection; +import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.GlowingPoint; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +/** + * Benchmark test for glowing point (star) billboards. + * Renders a grid of glowing points arranged in a cube formation to test + * billboard rendering and texture blending performance. + */ +public class StarGridTest implements BenchmarkTest { + + private static final int GRID_SIZE = 16; + private static final double SPACING = 80; + private static final double STAR_SIZE = 20; + private static final int UNIQUE_COLORS_COUNT = 30; + private static final long RANDOM_SEED = 42; + + private final Random random = new Random(RANDOM_SEED); + private final List stars = new ArrayList<>(); + private List colors; + + @Override + public String getName() { + return "Star Grid"; + } + + @Override + public void setup(ShapeCollection shapes) { + initializeColors(); + random.setSeed(RANDOM_SEED); + double offset = -(GRID_SIZE - 1) * SPACING / 2; + + for (int x = 0; x < GRID_SIZE; x++) { + for (int y = 0; y < GRID_SIZE; y++) { + for (int z = 0; z < GRID_SIZE; z++) { + double px = offset + x * SPACING; + double py = offset + y * SPACING; + double pz = offset + z * SPACING; + + Color color = colors.get(random.nextInt(colors.size())); + GlowingPoint star = new GlowingPoint( + new Point3D(px, py, pz), + STAR_SIZE, + color + ); + shapes.addShape(star); + stars.add(star); + } + } + } + } + + @Override + public void teardown(ShapeCollection shapes) { + for (Object star : stars) { + shapes.getShapes().remove(star); + } + stars.clear(); + } + + private void initializeColors() { + colors = new ArrayList<>(); + random.setSeed(RANDOM_SEED); + for (int i = 0; i < UNIQUE_COLORS_COUNT; i++) { + colors.add(new Color( + random.nextDouble() + 0.5, + random.nextDouble() + 0.5, + random.nextDouble() + 0.5, + 255 + )); + } + } +} \ No newline at end of file diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/examples/benchmark/WireframeCubesTest.java b/src/main/java/eu/svjatoslav/sixth/e3d/examples/benchmark/WireframeCubesTest.java index 4ea1ea9..c625627 100644 --- a/src/main/java/eu/svjatoslav/sixth/e3d/examples/benchmark/WireframeCubesTest.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/examples/benchmark/WireframeCubesTest.java @@ -51,7 +51,7 @@ public class WireframeCubesTest implements BenchmarkTest { 100 + random.nextInt(155), 100 + random.nextInt(155) ); - LineAppearance appearance = new LineAppearance(1.5, color); + LineAppearance appearance = new LineAppearance(5.5, color); Point3D center = new Point3D(px, py, pz); Point3D p1 = new Point3D(center.x - CUBE_SIZE, center.y - CUBE_SIZE, center.z - CUBE_SIZE); diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/examples/benchmark/package-info.java b/src/main/java/eu/svjatoslav/sixth/e3d/examples/benchmark/package-info.java index 41d5c8b..f95f2b4 100644 --- a/src/main/java/eu/svjatoslav/sixth/e3d/examples/benchmark/package-info.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/examples/benchmark/package-info.java @@ -13,6 +13,7 @@ *
  • {@link eu.svjatoslav.sixth.e3d.examples.benchmark.SolidCubesTest} - Solid-color cube rendering test
  • *
  • {@link eu.svjatoslav.sixth.e3d.examples.benchmark.TexturedCubesTest} - Textured cube rendering test
  • *
  • {@link eu.svjatoslav.sixth.e3d.examples.benchmark.WireframeCubesTest} - Wireframe cube rendering test
  • + *
  • {@link eu.svjatoslav.sixth.e3d.examples.benchmark.StarGridTest} - Billboard (glowing point) rendering test
  • * */ -- 2.20.1