From: Svjatoslav Agejenko Date: Fri, 20 Mar 2026 21:03:36 +0000 (+0200) Subject: feat: enhance benchmark and add surface graph X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=commitdiff_plain;h=7bd2f838a9ff8a5ba392e42f8ea18aa2744e6d8d;p=sixth-3d-demos.git feat: enhance benchmark and add surface graph - Add results dialog with copy-to-clipboard - Add lit solid cubes test - Update benchmark results and documentation - Add SurfaceGraph3D class for 3D surface visualization - Split and rename GraphDemo to SineHeightmap - Clarify 'Cores' label as 'CPU cores' --- diff --git a/doc/Screenshots/Benchmark.png b/doc/Screenshots/Benchmark.png new file mode 100644 index 0000000..5029be0 Binary files /dev/null and b/doc/Screenshots/Benchmark.png differ diff --git a/doc/index.org b/doc/index.org index f76fea1..807bb65 100644 --- a/doc/index.org +++ b/doc/index.org @@ -39,7 +39,7 @@ #+attr_latex: :width 1000px [[file:overview.png]] -Goal of this project is to show off capabilities and API usage of +The goal of this project is to show off capabilities and API usage of [[https://www3.svjatoslav.eu/projects/sixth-3d/][Sixth 3D]] engine. All [[id:5f88b493-6ab3-4659-8280-803f75dbd5e0][example scenes in this repository]] render at interactive @@ -50,7 +50,7 @@ from here: [[file:sixth-3d-demos.jar]] It requires Java 21 or newer to run. -To start demo application, use command: +To start the demo application, use command: : java -jar sixth-3d-demos.jar * Navigating in space @@ -71,6 +71,10 @@ To start demo application, use command: :ID: 5f88b493-6ab3-4659-8280-803f75dbd5e0 :END: +Press *F12* in any demo to open the [[https://www3.svjatoslav.eu/projects/sixth-3d/#outline-container-developer-tools][Developer Tools panel]]. This +debugging interface provides real-time insight into the rendering +pipeline with diagnostic toggles. + ** Conway's Game of Life :PROPERTIES: :CUSTOM_ID: conways-game-of-life @@ -99,7 +103,7 @@ Usage: |--------------------------------+--------------------------------------| | mouse click on the cell (cell) | toggles cell state | | | next iteration | -| ENTER | next iteeration with the history | +| ENTER | next iteration with the history | | "c" | clear the matrix | ** Text editors @@ -112,7 +116,7 @@ Usage: Initial test for creating user interfaces in 3D and: + window focus handling -+ picking objecs using mouse ++ picking objects using mouse + redirecting keyboard input to focused window @@ -153,7 +157,7 @@ again, window must be unfocused first using ESC key. See also [[https://hackers-1995.vercel.app/][similar looking web based demo]] ! :) -** Mathematical formulas +** Math graphs demo :PROPERTIES: :CUSTOM_ID: mathematical-formulas :ID: b1c2d3e4-f5a6-7890-bcde-f12345678901 @@ -162,7 +166,7 @@ See also [[https://hackers-1995.vercel.app/][similar looking web based demo]] ! [[file:Screenshots/Mathematical formulas.png]] + TODO: instead of projecting 2D visualizations onto 3D space, - visualize some formula using all 3 dimensions avaliable. + visualize some formula using all 3 dimensions available. ** Sine heightmap and sphere :PROPERTIES: @@ -191,7 +195,7 @@ Test scene that is generated simultaneously using: Instead of storing voxels in dumb [X * Y * Z] array, dynamically partitioned [[https://en.wikipedia.org/wiki/Octree][octree]] is used to compress data. Press "r" key anywhere in the scene to raytrace current view through compressed voxel -datastructure. +data structure. ** Graphics Benchmark :PROPERTIES: @@ -202,22 +206,24 @@ datastructure. An automated graphics benchmark that measures the engine's rendering performance across different rendering modes. -The benchmark creates a 16x16x16 grid of cubes (4096 total) and runs -three tests sequentially, each for 30 seconds: +[[file:Screenshots/Benchmark.png]] -- *Solid Cubes* - Tests solid-color polygon rasterization -- *Textured Cubes* - Tests textured polygon rendering with texture sampling -- *Wireframe Cubes* - Tests line rendering performance +The benchmark will cycle through different scenes that utilize different +rendering primitives (textured polygons, billboards, solid polygons, +etc.) to measure their relative performance. The camera follows a deterministic orbital path around the scene, ensuring reproducible results across runs. -Example benchmark results: +At the end, the benchmark will output a report that is easy to preserve for +later comparisons. + +Example benchmark report: #+begin_example ================================================================================ GRAPHICS BENCHMARK RESULTS ================================================================================ -Date: 2026-03-15 20:16:01 +Date: 2026-03-16 19:17:51 Resolution: 1920x1080 Cubes: 4096 (16x16x16 grid) Duration: 30 seconds per test @@ -227,28 +233,19 @@ SYSTEM INFORMATION -------------------------------------------------------------------------------- CPU Name: AMD Ryzen AI 9 HX 370 w/ Radeon 890M Arch: amd64 -Cores: 24 +CPU cores: 24 -------------------------------------------------------------------------------- Test Avg FPS -------------------------------------------------------------------------------- -Solid Cubes 35.65 -Textured Cubes 26.08 -Wireframe Cubes 33.67 -Star Grid 256.88 +Solid Cubes 49.65 +Lit Solid Cubes 41.40 +Textured Cubes 32.80 +Wireframe Cubes 42.84 +Star Grid 304.59 ================================================================================ #+end_example -** Developer tools -:PROPERTIES: -:CUSTOM_ID: developer-tools -:ID: 8c5e2a1f-9d3b-4f6a-b8e7-1c4d5f7a9b2e -:END: - -Press *F12* in any demo to open the Developer Tools panel. This -debugging interface provides real-time insight into the rendering -pipeline with diagnostic toggles. - * Source code :PROPERTIES: :CUSTOM_ID: source-code diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/examples/SineHeightmap.java b/src/main/java/eu/svjatoslav/sixth/e3d/examples/SineHeightmap.java new file mode 100755 index 0000000..91993f9 --- /dev/null +++ b/src/main/java/eu/svjatoslav/sixth/e3d/examples/SineHeightmap.java @@ -0,0 +1,116 @@ +/* + * Sixth 3D engine demos. Author: Svjatoslav Agejenko. + * This project is released under Creative Commons Zero (CC0) license. + * + */ + +package eu.svjatoslav.sixth.e3d.examples; + +import eu.svjatoslav.sixth.e3d.geometry.Point3D; +import eu.svjatoslav.sixth.e3d.gui.ViewFrame; +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.line.LineAppearance; +import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.solidpolygon.SolidPolygon; +import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.wireframe.WireframeSphere; + +/** + * Demo showing a sine heightmap surface with a central wireframe sphere. + * Two wobbly surfaces are positioned above and below the sphere. + */ +public class SineHeightmap { + + /** + * Creates a new GraphDemo instance. + */ + public SineHeightmap() { + } + + /** Frequency of the wave pattern in the wobbly surfaces. */ + private static final double WAVE_FREQUENCY = 50d; + /** Amplitude of the wave pattern in the wobbly surfaces. */ + private static final double WAVE_AMPLITUDE = 50d; + /** Color for the square plates in the wobbly surfaces. */ + private static final Color SQUARE_PLATE_COLOR = new Color("88F7"); + /** Scale factor for the graph rendering. */ + private static final double GRAPH_SCALE = 50d; + + /** + * Creates a single square plate at the specified position. + * @param shapeCollection the collection to add the plate to + * @param y the Y coordinate (elevation) + * @param x the X coordinate + * @param z the Z coordinate + */ + private static void makeSquarePlate(final ShapeCollection shapeCollection, + final double y, final double x, final double z) { + final Point3D p1 = new Point3D(x, y, z); + final Point3D p2 = new Point3D(x + 20, y, z); + final Point3D p3 = new Point3D(x, y, z + 20); + final Point3D p4 = new Point3D(x + 20, y, z + 20); + final SolidPolygon polygon1 = new SolidPolygon(p1, p2, p3, SQUARE_PLATE_COLOR); + final SolidPolygon polygon2 = new SolidPolygon(p4, p2, p3, SQUARE_PLATE_COLOR); + shapeCollection.addShape(polygon1); + shapeCollection.addShape(polygon2); + } + + /** + * Creates a wobbly surface composed of square plates arranged in a wave pattern. + * @param shapeCollection the collection to add plates to + * @param surfaceElevation the base Y elevation of the surface + */ + private static void addWobblySurface(final ShapeCollection shapeCollection, + final double surfaceElevation) { + for (double x = -500; x < 500; x += 20) + for (double z = -500; z < 500; z += 20) { + + final double distanceFromCenter = Math.sqrt((x * x) + (z * z)); + + double plateElevation = Math.sin(distanceFromCenter / WAVE_FREQUENCY) * WAVE_AMPLITUDE; + + makeSquarePlate(shapeCollection, plateElevation + surfaceElevation, x, + z); + } + } + + /** + * Entry point for the graph demo. + * @param args command line arguments (ignored) + */ + public static void main(final String[] args) { + + final ViewFrame viewFrame = new ViewFrame(); + final ShapeCollection geometryCollection = viewFrame.getViewPanel() + .getRootShapeCollection(); + + addSphere(geometryCollection); + addWobblySurface(geometryCollection, 200); + addWobblySurface(geometryCollection, -200); + + setCameraLocation(viewFrame); + + viewFrame.getViewPanel().ensureRenderThreadStarted(); + } + + /** + * Adds a wireframe sphere at the center of the scene. + * @param geometryCollection the collection to add the sphere to + */ + private static void addSphere(ShapeCollection geometryCollection) { + geometryCollection.addShape(new WireframeSphere(new Point3D(0, 0, 0), + 100, + new LineAppearance( + 4, + new Color(255,0, 0, 30)) + )); + } + + /** + * Sets the camera to an initial viewing position. + * @param viewFrame the view frame whose camera to configure + */ + private static void setCameraLocation(ViewFrame viewFrame) { + viewFrame.getViewPanel().getCamera().getTransform().setTranslation(new Point3D(0, 0, -500)); + } + +} diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/examples/benchmark/BenchmarkTest.java b/src/main/java/eu/svjatoslav/sixth/e3d/examples/benchmark/BenchmarkTest.java index dec1514..14ab974 100644 --- a/src/main/java/eu/svjatoslav/sixth/e3d/examples/benchmark/BenchmarkTest.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/examples/benchmark/BenchmarkTest.java @@ -5,6 +5,7 @@ package eu.svjatoslav.sixth.e3d.examples.benchmark; +import eu.svjatoslav.sixth.e3d.gui.ViewPanel; import eu.svjatoslav.sixth.e3d.renderer.raster.ShapeCollection; /** @@ -30,4 +31,12 @@ public interface BenchmarkTest { * @param shapes the shape collection to clean up */ void teardown(ShapeCollection shapes); + + /** + * Called after setup to provide the view panel for tests that need animation. + * Default implementation does nothing. + * @param viewPanel the view panel + */ + default void setViewPanel(ViewPanel viewPanel) { + } } \ No newline at end of file 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 96a50dc..bc0ccbb 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 @@ -13,7 +13,9 @@ import eu.svjatoslav.sixth.e3d.gui.ViewPanel; import eu.svjatoslav.sixth.e3d.gui.humaninput.KeyboardInputHandler; import eu.svjatoslav.sixth.e3d.renderer.raster.ShapeCollection; -import javax.swing.SwingUtilities; +import javax.swing.*; +import java.awt.*; +import java.awt.datatransfer.StringSelection; import java.awt.event.KeyEvent; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; @@ -22,8 +24,8 @@ import java.util.List; /** * Automated graphics benchmark that tests the engine's rendering performance. - * Runs multiple tests sequentially, each for a fixed duration, and outputs - * reproducible benchmark results to standard output. + * Runs multiple tests sequentially, each for a fixed duration, and displays + * results in a dialog with copy-to-clipboard functionality. * *

The benchmark creates a 16x16x16 grid of cubes (4096 total) with the camera * following a deterministic orbital path. Each test runs for 30 seconds by default.

@@ -32,7 +34,8 @@ import java.util.List; * *

Available tests:

*