feat(benchmark): add StarGridTest benchmark for billboard rendering
authorSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Sun, 15 Mar 2026 12:22:55 +0000 (14:22 +0200)
committerSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Sun, 15 Mar 2026 12:22:55 +0000 (14:22 +0200)
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.

src/main/java/eu/svjatoslav/sixth/e3d/examples/benchmark/GraphicsBenchmark.java
src/main/java/eu/svjatoslav/sixth/e3d/examples/benchmark/StarGridTest.java [new file with mode: 0644]
src/main/java/eu/svjatoslav/sixth/e3d/examples/benchmark/WireframeCubesTest.java
src/main/java/eu/svjatoslav/sixth/e3d/examples/benchmark/package-info.java

index d336dee..dc93a19 100644 (file)
@@ -35,6 +35,7 @@ import java.util.List;
  *   <li>{@link SolidCubesTest} - Solid-color polygon rendering</li>
  *   <li>{@link TexturedCubesTest} - Textured polygon rendering</li>
  *   <li>{@link WireframeCubesTest} - Line rendering</li>
+ *   <li>{@link StarGridTest} - Billboard (glowing point) rendering</li>
  * </ul>
  */
 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 (file)
index 0000000..967a621
--- /dev/null
@@ -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<Object> stars = new ArrayList<>();
+    private List<Color> 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
index 4ea1ea9..c625627 100644 (file)
@@ -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);
index 41d5c8b..f95f2b4 100644 (file)
@@ -13,6 +13,7 @@
  *   <li>{@link eu.svjatoslav.sixth.e3d.examples.benchmark.SolidCubesTest} - Solid-color cube rendering test</li>
  *   <li>{@link eu.svjatoslav.sixth.e3d.examples.benchmark.TexturedCubesTest} - Textured cube rendering test</li>
  *   <li>{@link eu.svjatoslav.sixth.e3d.examples.benchmark.WireframeCubesTest} - Wireframe cube rendering test</li>
+ *   <li>{@link eu.svjatoslav.sixth.e3d.examples.benchmark.StarGridTest} - Billboard (glowing point) rendering test</li>
  * </ul>
  */