Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

test(render): the level a frame chose, and the mistakes that would change it

esenginefccb9dc1f985
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index f60424c2c..c87e4cc3c 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -29,7 +29,7 @@ env:
test_registry_ondestroy test_view_api_matrix
test_shader_device test_draw_params test_texture_fb test_buffer_device
test_compressed_format test_batch_builder test_boundary_span test_webgpu_device
- test_clip_depth test_shadow_atlas test_particle_shapes
+ test_clip_depth test_shadow_atlas test_particle_shapes test_lod_selection
test_text_edit test_render_graph test_device_loss test_physics_interpolation
test_bitmap_font test_texture_cache test_aot_host test_aot_conformance
test_frame_lifecycle
diff --git a/fixtures/scenes/lod-3d.esscene b/fixtures/scenes/lod-3d.esscene
new file mode 100644
index 000000000..86ffadf06
--- /dev/null
+++ b/fixtures/scenes/lod-3d.esscene
@@ -0,0 +1,232 @@
+{
+ "version": 4,
+ "name": "Lod3D",
+ "entities": [
+ {
+ "id": 0,
+ "name": "Camera",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "Camera",
+ "data": {
+ "projectionType": 0,
+ "fov": 60.0,
+ "nearPlane": 1,
+ "farPlane": 20000.0,
+ "isActive": true,
+ "priority": 0
+ }
+ }
+ ]
+ },
+ {
+ "id": 1,
+ "name": "Near",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": -500
+ }
+ }
+ },
+ {
+ "type": "MeshRenderer",
+ "data": {
+ "mesh": "/scenes/lod-high.esmesh",
+ "lit": false,
+ "opaque": true,
+ "cullBackfaces": true,
+ "enabled": true,
+ "color": {
+ "r": 1,
+ "g": 1,
+ "b": 1,
+ "a": 1
+ }
+ }
+ },
+ {
+ "type": "LODGroup",
+ "data": {
+ "lod1": "/scenes/lod-mid.esmesh",
+ "lod2": "/scenes/lod-low.esmesh",
+ "lod3": 0,
+ "lod1Size": 0.5,
+ "lod2Size": 0.25,
+ "lod3Size": 0.0,
+ "cullSize": 0.05,
+ "hysteresis": 0.1,
+ "enabled": true
+ }
+ }
+ ]
+ },
+ {
+ "id": 2,
+ "name": "Mid",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": -1000
+ }
+ }
+ },
+ {
+ "type": "MeshRenderer",
+ "data": {
+ "mesh": "/scenes/lod-high.esmesh",
+ "lit": false,
+ "opaque": true,
+ "cullBackfaces": true,
+ "enabled": true,
+ "color": {
+ "r": 1,
+ "g": 1,
+ "b": 1,
+ "a": 1
+ }
+ }
+ },
+ {
+ "type": "LODGroup",
+ "data": {
+ "lod1": "/scenes/lod-mid.esmesh",
+ "lod2": "/scenes/lod-low.esmesh",
+ "lod3": 0,
+ "lod1Size": 0.5,
+ "lod2Size": 0.25,
+ "lod3Size": 0.0,
+ "cullSize": 0.05,
+ "hysteresis": 0.1,
+ "enabled": true
+ }
+ }
+ ]
+ },
+ {
+ "id": 3,
+ "name": "Far",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": -2000
+ }
+ }
+ },
+ {
+ "type": "MeshRenderer",
+ "data": {
+ "mesh": "/scenes/lod-high.esmesh",
+ "lit": false,
+ "opaque": true,
+ "cullBackfaces": true,
+ "enabled": true,
+ "color": {
+ "r": 1,
+ "g": 1,
+ "b": 1,
+ "a": 1
+ }
+ }
+ },
+ {
+ "type": "LODGroup",
+ "data": {
+ "lod1": "/scenes/lod-mid.esmesh",
+ "lod2": "/scenes/lod-low.esmesh",
+ "lod3": 0,
+ "lod1Size": 0.5,
+ "lod2Size": 0.25,
+ "lod3Size": 0.0,
+ "cullSize": 0.05,
+ "hysteresis": 0.1,
+ "enabled": true
+ }
+ }
+ ]
+ },
+ {
+ "id": 4,
+ "name": "Tiny",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": -8000
+ }
+ }
+ },
+ {
+ "type": "MeshRenderer",
+ "data": {
+ "mesh": "/scenes/lod-high.esmesh",
+ "lit": false,
+ "opaque": true,
+ "cullBackfaces": true,
+ "enabled": true,
+ "color": {
+ "r": 1,
+ "g": 1,
+ "b": 1,
+ "a": 1
+ }
+ }
+ },
+ {
+ "type": "LODGroup",
+ "data": {
+ "lod1": "/scenes/lod-mid.esmesh",
+ "lod2": "/scenes/lod-low.esmesh",
+ "lod3": 0,
+ "lod1Size": 0.5,
+ "lod2Size": 0.25,
+ "lod3Size": 0.0,
+ "cullSize": 0.05,
+ "hysteresis": 0.1,
+ "enabled": true
+ }
+ }
+ ]
+ }
+ ]
+}
diff --git a/fixtures/scenes/lod-high.esmesh b/fixtures/scenes/lod-high.esmesh
new file mode 100644
index 000000000..6ded4f7fb
Binary files /dev/null and b/fixtures/scenes/lod-high.esmesh differ
diff --git a/fixtures/scenes/lod-high.esmesh.meta b/fixtures/scenes/lod-high.esmesh.meta
new file mode 100644
index 000000000..07a1ff1ec
--- /dev/null
+++ b/fixtures/scenes/lod-high.esmesh.meta
@@ -0,0 +1,6 @@
+{
+ "uuid": "583b4e0b-572a-42bd-8b8e-296cd9aeb6fd",
+ "version": "2.0",
+ "type": "mesh",
+ "importer": {}
+}
diff --git a/fixtures/scenes/lod-high.esprefab b/fixtures/scenes/lod-high.esprefab
new file mode 100644
index 000000000..ca5bd8463
--- /dev/null
+++ b/fixtures/scenes/lod-high.esprefab
@@ -0,0 +1,28 @@
+{
+ "version": "2",
+ "name": "lod-high",
+ "rootEntityId": "n0",
+ "entities": [
+ {
+ "prefabEntityId": "n0",
+ "name": "node_0",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {}
+ },
+ {
+ "type": "MeshRenderer",
+ "data": {
+ "mesh": "scenes/lod-high.esmesh",
+ "lit": true,
+ "enabled": true
+ }
+ }
+ ]
+ }
+ ]
+}
diff --git a/fixtures/scenes/lod-high.esprefab.meta b/fixtures/scenes/lod-high.esprefab.meta
new file mode 100644
index 000000000..f3f75a073
--- /dev/null
+++ b/fixtures/scenes/lod-high.esprefab.meta
@@ -0,0 +1,6 @@
+{
+ "uuid": "50588d73-7e45-497f-9a70-d93e1c9ffaa2",
+ "version": "2.0",
+ "type": "prefab",
+ "importer": {}
+}
diff --git a/fixtures/scenes/lod-high.gltf b/fixtures/scenes/lod-high.gltf
new file mode 100644
index 000000000..45a9eff5c
--- /dev/null
+++ b/fixtures/scenes/lod-high.gltf
@@ -0,0 +1,99 @@
+{
+ "asset": {
+ "version": "2.0",
+ "generator": "estella test fixture"
+ },
+ "buffers": [
+ {
+ "byteLength": 7464,
+ "uri": "data:application/octet-stream;base64,AAAAAAAAyEIAAAAAAAAAAAAAyEIAAAAAAAAAAAAAyEIAAAAAAAAAAAAAyEIAAAAAAAAAAAAAyEIAAAAAAAAAgAAAyEIAAAAAAAAAgAAAyEIAAAAAAAAAgAAAyEIAAAAAAAAAgAAAyEIAAAAAAAAAgAAAyEIAAACAAAAAgAAAyEIAAACAAAAAgAAAyEIAAACAAAAAgAAAyEIAAACAAAAAAAAAyEIAAACAAAAAAAAAyEIAAACAAAAAAAAAyEIAAACAAAAAAAAAyEIAAACAyRIZQqLGuEIAAAAA3msNQqLGuEKIUGpBe3rYQaLGuEJ7ethBiFBqQaLGuELeaw1ChdkoJ6LGuELJEhlCiFBqwaLGuELeaw1Ce3rYwaLGuEJ7ethB3msNwqLGuEKIUGpByRIZwqLGuEKF2agn3msNwqLGuEKIU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FMAQwBUAFMARABFAFUARQBWAFUARQBGAFYARgBXAFYARgBHAFcARwBYAFcARwBIAFgASABZAFgASABJAFkASQBaAFkASQBKAFoASgBbAFoASgBLAFsASwBcAFsASwBMAFwATABdAFwATABNAF0ATQBeAF0ATQBOAF4ATgBfAF4ATgBPAF8ATwBgAF8ATwBQAGAAUABhAGAAUABRAGEAUQBiAGEAUQBSAGIAUgBjAGIAUgBTAGMAUwBkAGMAUwBUAGQAVABlAGQAVQBWAGYAVgBnAGYAVgBXAGcAVwBoAGcAVwBYAGgAWABpAGgAWABZAGkAWQBqAGkAWQBaAGoAWgBrAGoAWgBbAGsAWwBsAGsAWwBcAGwAXABtAGwAXABdAG0AXQBuAG0AXQBeAG4AXgBvAG4AXgBfAG8AXwBwAG8AXwBgAHAAYABxAHAAYABhAHEAYQByAHEAYQBiAHIAYgBzAHIAYgBjAHMAYwB0AHMAYwBkAHQAZAB1AHQAZABlAHUAZQB2AHUAZgBnAHcAZwB4AHcAZwBoAHgAaAB5AHgAaABpAHkAaQB6AHkAaQBqAHoAagB7AHoAagBrAHsAawB8AHsAawBsAHwAbAB9AHwAbABtAH0AbQB+AH0AbQBuAH4AbgB/AH4AbgBvAH8AbwCAAH8AbwBwAIAAcACBAIAAcABxAIEAcQCCAIEAcQByAIIAcgCDAIIAcgBzAIMAcwCEAIMAcwB0AIQAdACFAIQAdAB1AIUAdQCGAIUAdQB2AIYAdgCHAIYAdwB4AIgAeAB5AIkAeQB6AIoAegB7AIsAewB8AIwAfAB9AI0AfQB+AI4AfgB/AI8AfwCAAJAAgACBAJEAgQCCAJIAggCDAJMAgwCEAJQAhACFAJUAhQCGAJYAhgCHAJcA"
+ }
+ ],
+ "bufferViews": [
+ {
+ "buffer": 0,
+ "byteOffset": 0,
+ "byteLength": 1836
+ },
+ {
+ "buffer": 0,
+ "byteOffset": 1836,
+ "byteLength": 1836
+ },
+ {
+ "buffer": 0,
+ "byteOffset": 3672,
+ "byteLength": 2448
+ },
+ {
+ "buffer": 0,
+ "byteOffset": 6120,
+ "byteLength": 1344
+ }
+ ],
+ "accessors": [
+ {
+ "bufferView": 0,
+ "componentType": 5126,
+ "count": 153,
+ "type": "VEC3",
+ "min": [
+ -100.0,
+ -100.0,
+ -100.0
+ ],
+ "max": [
+ 100.0,
+ 100.0,
+ 100.0
+ ]
+ },
+ {
+ "bufferView": 1,
+ "componentType": 5126,
+ "count": 153,
+ "type": "VEC3"
+ },
+ {
+ "bufferView": 2,
+ "componentType": 5126,
+ "count": 153,
+ "type": "VEC4"
+ },
+ {
+ "bufferView": 3,
+ "componentType": 5123,
+ "count": 672,
+ "type": "SCALAR"
+ }
+ ],
+ "meshes": [
+ {
+ "name": "LodHigh",
+ "primitives": [
+ {
+ "attributes": {
+ "POSITION": 0,
+ "NORMAL": 1,
+ "COLOR_0": 2
+ },
+ "indices": 3,
+ "mode": 4
+ }
+ ]
+ }
+ ],
+ "nodes": [
+ {
+ "mesh": 0
+ }
+ ],
+ "scenes": [
+ {
+ "nodes": [
+ 0
+ ]
+ }
+ ],
+ "scene": 0
+}
diff --git a/fixtures/scenes/lod-hyst.esscene b/fixtures/scenes/lod-hyst.esscene
new file mode 100644
index 000000000..cfc42520d
--- /dev/null
+++ b/fixtures/scenes/lod-hyst.esscene
@@ -0,0 +1,85 @@
+{
+ "version": 4,
+ "name": "LodHysteresis",
+ "entities": [
+ {
+ "id": 0,
+ "name": "Camera",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "Camera",
+ "data": {
+ "projectionType": 0,
+ "fov": 60.0,
+ "nearPlane": 1,
+ "farPlane": 20000.0,
+ "isActive": true,
+ "priority": 0
+ }
+ }
+ ]
+ },
+ {
+ "id": 1,
+ "name": "Subject",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": -577
+ }
+ }
+ },
+ {
+ "type": "MeshRenderer",
+ "data": {
+ "mesh": "/scenes/lod-high.esmesh",
+ "lit": false,
+ "opaque": true,
+ "cullBackfaces": true,
+ "enabled": true,
+ "color": {
+ "r": 1,
+ "g": 1,
+ "b": 1,
+ "a": 1
+ }
+ }
+ },
+ {
+ "type": "LODGroup",
+ "data": {
+ "lod1": "/scenes/lod-mid.esmesh",
+ "lod2": "/scenes/lod-low.esmesh",
+ "lod3": 0,
+ "lod1Size": 0.5,
+ "lod2Size": 0.25,
+ "lod3Size": 0.0,
+ "cullSize": 0.05,
+ "hysteresis": 0.1,
+ "enabled": true
+ }
+ }
+ ]
+ }
+ ]
+}
diff --git a/fixtures/scenes/lod-instanced.esscene b/fixtures/scenes/lod-instanced.esscene
new file mode 100644
index 000000000..8593c1d72
--- /dev/null
+++ b/fixtures/scenes/lod-instanced.esscene
@@ -0,0 +1,85 @@
+{
+ "version": 4,
+ "name": "LodInstanced",
+ "entities": [
+ {
+ "id": 0,
+ "name": "Camera",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "Camera",
+ "data": {
+ "projectionType": 0,
+ "fov": 60.0,
+ "nearPlane": 1,
+ "farPlane": 20000.0,
+ "isActive": true,
+ "priority": 0
+ }
+ }
+ ]
+ },
+ {
+ "id": 1,
+ "name": "Prop",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": -857
+ }
+ }
+ },
+ {
+ "type": "MeshRenderer",
+ "data": {
+ "mesh": "/scenes/lod-high.esmesh",
+ "lit": false,
+ "opaque": true,
+ "cullBackfaces": true,
+ "enabled": true,
+ "color": {
+ "r": 1,
+ "g": 1,
+ "b": 1,
+ "a": 1
+ }
+ }
+ },
+ {
+ "type": "LODGroup",
+ "data": {
+ "lod1": "/scenes/lod-mid.esmesh",
+ "lod2": "/scenes/lod-low.esmesh",
+ "lod3": 0,
+ "lod1Size": 0.5,
+ "lod2Size": 0.25,
+ "lod3Size": 0.0,
+ "cullSize": 0.05,
+ "hysteresis": 0.1,
+ "enabled": true
+ }
+ }
+ ]
+ }
+ ]
+}
diff --git a/fixtures/scenes/lod-low.esmesh b/fixtures/scenes/lod-low.esmesh
new file mode 100644
index 000000000..f632cf7e1
Binary files /dev/null and b/fixtures/scenes/lod-low.esmesh differ
diff --git a/fixtures/scenes/lod-low.esmesh.meta b/fixtures/scenes/lod-low.esmesh.meta
new file mode 100644
index 000000000..a40ebd230
--- /dev/null
+++ b/fixtures/scenes/lod-low.esmesh.meta
@@ -0,0 +1,6 @@
+{
+ "uuid": "2b5a259c-86a1-42ca-9032-137fdabed981",
+ "version": "2.0",
+ "type": "mesh",
+ "importer": {}
+}
diff --git a/fixtures/scenes/lod-low.esprefab b/fixtures/scenes/lod-low.esprefab
new file mode 100644
index 000000000..2a866b3c4
--- /dev/null
+++ b/fixtures/scenes/lod-low.esprefab
@@ -0,0 +1,28 @@
+{
+ "version": "2",
+ "name": "lod-low",
+ "rootEntityId": "n0",
+ "entities": [
+ {
+ "prefabEntityId": "n0",
+ "name": "node_0",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {}
+ },
+ {
+ "type": "MeshRenderer",
+ "data": {
+ "mesh": "scenes/lod-low.esmesh",
+ "lit": true,
+ "enabled": true
+ }
+ }
+ ]
+ }
+ ]
+}
diff --git a/fixtures/scenes/lod-low.esprefab.meta b/fixtures/scenes/lod-low.esprefab.meta
new file mode 100644
index 000000000..3f26ec681
--- /dev/null
+++ b/fixtures/scenes/lod-low.esprefab.meta
@@ -0,0 +1,6 @@
+{
+ "uuid": "465c330a-78e8-4b27-930e-56d9d2b2d095",
+ "version": "2.0",
+ "type": "prefab",
+ "importer": {}
+}
diff --git a/fixtures/scenes/lod-low.gltf b/fixtures/scenes/lod-low.gltf
new file mode 100644
index 000000000..0b38f4452
--- /dev/null
+++ b/fixtures/scenes/lod-low.gltf
@@ -0,0 +1,99 @@
+{
+ "asset": {
+ "version": "2.0",
+ "generator": "estella test fixture"
+ },
+ "buffers": [
+ {
+ "byteLength": 504,
+ "uri": "data:application/octet-stream;base64,AADIQQAAyEEAAMhBAADIQQAAyMEAAMjBAADIwQAAyEEAAMjBAADIQQAAyEEAAMhBAADIwQAAyEEAAMjBAADIwQAAyMEAAMhBAADIQQAAyEEAAMhBAADIwQAAyMEAAMhBAADIQQAAyMEAAMjBAADIQQAAyMEAAMjBAADIwQAAyMEAAMhBAADIwQAAyEEAAMjBOs0TPzrNEz86zRO/Os0TPzrNEz86zRO/Os0TPzrNEz86zRO/Os0TvzrNEz86zRM/Os0TvzrNEz86zRM/Os0TvzrNEz86zRM/Os0TPzrNE786zRM/Os0TPzrNE786zRM/Os0TPzrNE786zRM/Os0TvzrNE786zRO/Os0TvzrNE786zRO/Os0TvzrNE786zRO/AAAAAAAAAAAAAIA/AACAPwAAAAAAAAAAAACAPwAAgD8AAAAAAAAAAAAAgD8AAIA/AAAAAAAAAAAAAIA/AACAPwAAAAAAAAAAAACAPwAAgD8AAAAAAAAAAAAAgD8AAIA/AAAAAAAAAAAAAIA/AACAPwAAAAAAAAAAAACAPwAAgD8AAAAAAAAAAAAAgD8AAIA/AAAAAAAAAAAAAIA/AACAPwAAAAAAAAAAAACAPwAAgD8AAAAAAAAAAAAAgD8AAIA/AAABAAIAAwAEAAUABgAHAAgACQAKAAsA"
+ }
+ ],
+ "bufferViews": [
+ {
+ "buffer": 0,
+ "byteOffset": 0,
+ "byteLength": 144
+ },
+ {
+ "buffer": 0,
+ "byteOffset": 144,
+ "byteLength": 144
+ },
+ {
+ "buffer": 0,
+ "byteOffset": 288,
+ "byteLength": 192
+ },
+ {
+ "buffer": 0,
+ "byteOffset": 480,
+ "byteLength": 24
+ }
+ ],
+ "accessors": [
+ {
+ "bufferView": 0,
+ "componentType": 5126,
+ "count": 12,
+ "type": "VEC3",
+ "min": [
+ -25.0,
+ -25.0,
+ -25.0
+ ],
+ "max": [
+ 25.0,
+ 25.0,
+ 25.0
+ ]
+ },
+ {
+ "bufferView": 1,
+ "componentType": 5126,
+ "count": 12,
+ "type": "VEC3"
+ },
+ {
+ "bufferView": 2,
+ "componentType": 5126,
+ "count": 12,
+ "type": "VEC4"
+ },
+ {
+ "bufferView": 3,
+ "componentType": 5123,
+ "count": 12,
+ "type": "SCALAR"
+ }
+ ],
+ "meshes": [
+ {
+ "name": "LodLow",
+ "primitives": [
+ {
+ "attributes": {
+ "POSITION": 0,
+ "NORMAL": 1,
+ "COLOR_0": 2
+ },
+ "indices": 3,
+ "mode": 4
+ }
+ ]
+ }
+ ],
+ "nodes": [
+ {
+ "mesh": 0
+ }
+ ],
+ "scenes": [
+ {
+ "nodes": [
+ 0
+ ]
+ }
+ ],
+ "scene": 0
+}
diff --git a/fixtures/scenes/lod-mid.esmesh b/fixtures/scenes/lod-mid.esmesh
new file mode 100644
index 000000000..f43182205
Binary files /dev/null and b/fixtures/scenes/lod-mid.esmesh differ
diff --git a/fixtures/scenes/lod-mid.esmesh.meta b/fixtures/scenes/lod-mid.esmesh.meta
new file mode 100644
index 000000000..482ba22fb
--- /dev/null
+++ b/fixtures/scenes/lod-mid.esmesh.meta
@@ -0,0 +1,6 @@
+{
+ "uuid": "9f8dadf7-3847-4f1f-bff0-a1bd6bfb84f2",
+ "version": "2.0",
+ "type": "mesh",
+ "importer": {}
+}
diff --git a/fixtures/scenes/lod-mid.esprefab b/fixtures/scenes/lod-mid.esprefab
new file mode 100644
index 000000000..d2c16e7ee
--- /dev/null
+++ b/fixtures/scenes/lod-mid.esprefab
@@ -0,0 +1,28 @@
+{
+ "version": "2",
+ "name": "lod-mid",
+ "rootEntityId": "n0",
+ "entities": [
+ {
+ "prefabEntityId": "n0",
+ "name": "node_0",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {}
+ },
+ {
+ "type": "MeshRenderer",
+ "data": {
+ "mesh": "scenes/lod-mid.esmesh",
+ "lit": true,
+ "enabled": true
+ }
+ }
+ ]
+ }
+ ]
+}
diff --git a/fixtures/scenes/lod-mid.esprefab.meta b/fixtures/scenes/lod-mid.esprefab.meta
new file mode 100644
index 000000000..a2fa4fa43
--- /dev/null
+++ b/fixtures/scenes/lod-mid.esprefab.meta
@@ -0,0 +1,6 @@
+{
+ "uuid": "d16516ce-8461-4624-8c36-c3943854fa64",
+ "version": "2.0",
+ "type": "prefab",
+ "importer": {}
+}
diff --git a/fixtures/scenes/lod-mid.gltf b/fixtures/scenes/lod-mid.gltf
new file mode 100644
index 000000000..942ad4ef6
--- /dev/null
+++ b/fixtures/scenes/lod-mid.gltf
@@ -0,0 +1,99 @@
+{
+ "asset": {
+ "version": "2.0",
+ "generator": "estella test fixture"
+ },
+ "buffers": [
+ {
+ "byteLength": 1008,
+ "uri": "data:application/octet-stream;base64,AABwQgAAAAAAAAAAAAAAAAAAcEIAAAAAAAAAAAAAAAAAAHBCAAAAAAAAcEIAAAAAAABwwgAAAAAAAAAAAAAAAAAAAAAAAHBCAABwwgAAAAAAAAAAAAAAAAAAcMIAAAAAAAAAAAAAAAAAAHBCAAAAAAAAcMIAAAAAAABwQgAAAAAAAAAAAAAAAAAAAAAAAHBCAAAAAAAAcEIAAAAAAABwQgAAAAAAAAAAAAAAAAAAAAAAAHDCAABwwgAAAAAAAAAAAAAAAAAAcEIAAAAAAAAAAAAAAAAAAHDCAAAAAAAAcMIAAAAAAABwwgAAAAAAAAAAAAAAAAAAAAAAAHDCAABwQgAAAAAAAAAAAAAAAAAAcMIAAAAAAAAAAAAAAAAAAHDCOs0TPzrNEz86zRM/Os0TPzrNEz86zRM/Os0TPzrNEz86zRM/Os0TvzrNEz86zRM/Os0TvzrNEz86zRM/Os0TvzrNEz86zRM/Os0TvzrNE786zRM/Os0TvzrNE786zRM/Os0TvzrNE786zRM/Os0TPzrNE786zRM/Os0TPzrNE786zRM/Os0TPzrNE786zRM/Os0TPzrNEz86zRO/Os0TPzrNEz86zRO/Os0TPzrNEz86zRO/Os0TvzrNEz86zRO/Os0TvzrNEz86zRO/Os0TvzrNEz86zRO/Os0TvzrNE786zRO/Os0TvzrNE786zRO/Os0TvzrNE786zRO/Os0TPzrNE786zRO/Os0TPzrNE786zRO/Os0TPzrNE786zRO/AAAAAAAAgD8AAAAAAACAPwAAAAAAAIA/AAAAAAAAgD8AAAAAAACAPwAAAAAAAIA/AAAAAAAAgD8AAAAAAACAPwAAAAAAAIA/AAAAAAAAgD8AAAAAAACAPwAAAAAAAIA/AAAAAAAAgD8AAAAAAACAPwAAAAAAAIA/AAAAAAAAgD8AAAAAAACAPwAAAAAAAIA/AAAAAAAAgD8AAAAAAACAPwAAAAAAAIA/AAAAAAAAgD8AAAAAAACAPwAAAAAAAIA/AAAAAAAAgD8AAAAAAACAPwAAAAAAAIA/AAAAAAAAgD8AAAAAAACAPwAAAAAAAIA/AAAAAAAAgD8AAAAAAACAPwAAAAAAAIA/AAAAAAAAgD8AAAAAAACAPwAAAAAAAIA/AAAAAAAAgD8AAAAAAACAPwAAAAAAAIA/AAAAAAAAgD8AAAAAAACAPwAAAAAAAIA/AAAAAAAAgD8AAAAAAACAPwAAAAAAAIA/AAAAAAAAgD8AAAAAAACAPwAAAAAAAIA/AAABAAIAAwAEAAUABgAHAAgACQAKAAsADAANAA4ADwAQABEAEgATABQAFQAWABcA"
+ }
+ ],
+ "bufferViews": [
+ {
+ "buffer": 0,
+ "byteOffset": 0,
+ "byteLength": 288
+ },
+ {
+ "buffer": 0,
+ "byteOffset": 288,
+ "byteLength": 288
+ },
+ {
+ "buffer": 0,
+ "byteOffset": 576,
+ "byteLength": 384
+ },
+ {
+ "buffer": 0,
+ "byteOffset": 960,
+ "byteLength": 48
+ }
+ ],
+ "accessors": [
+ {
+ "bufferView": 0,
+ "componentType": 5126,
+ "count": 24,
+ "type": "VEC3",
+ "min": [
+ -60.0,
+ -60.0,
+ -60.0
+ ],
+ "max": [
+ 60.0,
+ 60.0,
+ 60.0
+ ]
+ },
+ {
+ "bufferView": 1,
+ "componentType": 5126,
+ "count": 24,
+ "type": "VEC3"
+ },
+ {
+ "bufferView": 2,
+ "componentType": 5126,
+ "count": 24,
+ "type": "VEC4"
+ },
+ {
+ "bufferView": 3,
+ "componentType": 5123,
+ "count": 24,
+ "type": "SCALAR"
+ }
+ ],
+ "meshes": [
+ {
+ "name": "LodMid",
+ "primitives": [
+ {
+ "attributes": {
+ "POSITION": 0,
+ "NORMAL": 1,
+ "COLOR_0": 2
+ },
+ "indices": 3,
+ "mode": 4
+ }
+ ]
+ }
+ ],
+ "nodes": [
+ {
+ "mesh": 0
+ }
+ ],
+ "scenes": [
+ {
+ "nodes": [
+ 0
+ ]
+ }
+ ],
+ "scene": 0
+}
diff --git a/fixtures/scenes/lod-multicam.esscene b/fixtures/scenes/lod-multicam.esscene
new file mode 100644
index 000000000..1de7e648c
--- /dev/null
+++ b/fixtures/scenes/lod-multicam.esscene
@@ -0,0 +1,127 @@
+{
+ "version": 4,
+ "name": "LodMultiCamera",
+ "entities": [
+ {
+ "id": 0,
+ "name": "CameraNear",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": -423
+ }
+ }
+ },
+ {
+ "type": "Camera",
+ "data": {
+ "projectionType": 0,
+ "fov": 60.0,
+ "nearPlane": 1,
+ "farPlane": 20000.0,
+ "isActive": true,
+ "priority": 0,
+ "viewport": {
+ "x": 0.0,
+ "y": 0.0,
+ "z": 0.5,
+ "w": 1.0
+ }
+ }
+ }
+ ]
+ },
+ {
+ "id": 1,
+ "name": "CameraFar",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": -375
+ }
+ }
+ },
+ {
+ "type": "Camera",
+ "data": {
+ "projectionType": 0,
+ "fov": 60.0,
+ "nearPlane": 1,
+ "farPlane": 20000.0,
+ "isActive": true,
+ "priority": 1,
+ "viewport": {
+ "x": 0.5,
+ "y": 0.0,
+ "z": 0.5,
+ "w": 1.0
+ }
+ }
+ }
+ ]
+ },
+ {
+ "id": 2,
+ "name": "Subject",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": -1000
+ }
+ }
+ },
+ {
+ "type": "MeshRenderer",
+ "data": {
+ "mesh": "/scenes/lod-high.esmesh",
+ "lit": false,
+ "opaque": true,
+ "cullBackfaces": true,
+ "enabled": true,
+ "color": {
+ "r": 1,
+ "g": 1,
+ "b": 1,
+ "a": 1
+ }
+ }
+ },
+ {
+ "type": "LODGroup",
+ "data": {
+ "lod1": "/scenes/lod-mid.esmesh",
+ "lod2": "/scenes/lod-low.esmesh",
+ "lod3": 0,
+ "lod1Size": 0.5,
+ "lod2Size": 0.25,
+ "lod3Size": 0.0,
+ "cullSize": 0.05,
+ "hysteresis": 0.1,
+ "enabled": true
+ }
+ }
+ ]
+ }
+ ]
+}
diff --git a/fixtures/scenes/lod-size.esscene b/fixtures/scenes/lod-size.esscene
new file mode 100644
index 000000000..3b1ddc70b
--- /dev/null
+++ b/fixtures/scenes/lod-size.esscene
@@ -0,0 +1,139 @@
+{
+ "version": 4,
+ "name": "LodSize",
+ "entities": [
+ {
+ "id": 0,
+ "name": "Camera",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "Camera",
+ "data": {
+ "projectionType": 0,
+ "fov": 60.0,
+ "nearPlane": 1,
+ "farPlane": 20000.0,
+ "isActive": true,
+ "priority": 0
+ }
+ }
+ ]
+ },
+ {
+ "id": 1,
+ "name": "Big",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": -200,
+ "y": 0,
+ "z": -1000
+ }
+ }
+ },
+ {
+ "type": "MeshRenderer",
+ "data": {
+ "mesh": "/scenes/lod-high.esmesh",
+ "lit": false,
+ "opaque": true,
+ "cullBackfaces": true,
+ "enabled": true,
+ "color": {
+ "r": 1,
+ "g": 1,
+ "b": 1,
+ "a": 1
+ }
+ }
+ },
+ {
+ "type": "LODGroup",
+ "data": {
+ "lod1": "/scenes/lod-mid.esmesh",
+ "lod2": "/scenes/lod-low.esmesh",
+ "lod3": 0,
+ "lod1Size": 0.5,
+ "lod2Size": 0.25,
+ "lod3Size": 0.0,
+ "cullSize": 0.05,
+ "hysteresis": 0.1,
+ "enabled": true
+ }
+ }
+ ]
+ },
+ {
+ "id": 2,
+ "name": "Small",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 200,
+ "y": 0,
+ "z": -1000
+ },
+ "scale": {
+ "x": 0.4,
+ "y": 0.4,
+ "z": 0.4
+ }
+ }
+ },
+ {
+ "type": "MeshRenderer",
+ "data": {
+ "mesh": "/scenes/lod-high.esmesh",
+ "lit": false,
+ "opaque": true,
+ "cullBackfaces": true,
+ "enabled": true,
+ "color": {
+ "r": 1,
+ "g": 1,
+ "b": 1,
+ "a": 1
+ }
+ }
+ },
+ {
+ "type": "LODGroup",
+ "data": {
+ "lod1": "/scenes/lod-mid.esmesh",
+ "lod2": "/scenes/lod-low.esmesh",
+ "lod3": 0,
+ "lod1Size": 0.5,
+ "lod2Size": 0.25,
+ "lod3Size": 0.0,
+ "cullSize": 0.05,
+ "hysteresis": 0.1,
+ "enabled": true
+ }
+ }
+ ]
+ }
+ ]
+}
diff --git a/fixtures/scenes/lod-skin.esscene b/fixtures/scenes/lod-skin.esscene
new file mode 100644
index 000000000..7be863611
--- /dev/null
+++ b/fixtures/scenes/lod-skin.esscene
@@ -0,0 +1,127 @@
+{
+ "version": 4,
+ "name": "LodSkin",
+ "entities": [
+ {
+ "id": 0,
+ "name": "Camera",
+ "parent": null,
+ "children": [],
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 60,
+ "y": 20,
+ "z": 10
+ }
+ }
+ },
+ {
+ "type": "Camera",
+ "data": {
+ "projectionType": 1,
+ "orthoSize": 100,
+ "isActive": true,
+ "priority": 0
+ }
+ }
+ ],
+ "visible": true
+ },
+ {
+ "id": 1,
+ "name": "Bone0",
+ "parent": null,
+ "children": [],
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": 0
+ }
+ }
+ }
+ ],
+ "visible": true
+ },
+ {
+ "id": 2,
+ "name": "Bone1",
+ "parent": null,
+ "children": [],
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 60,
+ "y": 60,
+ "z": 0
+ }
+ }
+ }
+ ],
+ "visible": true
+ },
+ {
+ "id": 3,
+ "name": "Body",
+ "parent": null,
+ "children": [],
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "MeshRenderer",
+ "data": {
+ "mesh": "scenes/skinned-arm.esmesh",
+ "color": {
+ "r": 0,
+ "g": 1,
+ "b": 0,
+ "a": 1
+ },
+ "enabled": true
+ }
+ },
+ {
+ "type": "MeshSkin",
+ "data": {
+ "joints": [
+ 1,
+ 2
+ ]
+ }
+ },
+ {
+ "type": "LODGroup",
+ "data": {
+ "lod1": "/scenes/lod-mid.esmesh",
+ "lod2": 0,
+ "lod3": 0,
+ "lod1Size": 0.9,
+ "lod2Size": 0.0,
+ "lod3Size": 0.0,
+ "cullSize": 0.5,
+ "hysteresis": 0.1,
+ "enabled": true
+ }
+ }
+ ],
+ "visible": true
+ }
+ ]
+}
diff --git a/fixtures/scenes/lod-swap.esscene b/fixtures/scenes/lod-swap.esscene
new file mode 100644
index 000000000..652d3666f
--- /dev/null
+++ b/fixtures/scenes/lod-swap.esscene
@@ -0,0 +1,85 @@
+{
+ "version": 4,
+ "name": "LodSwap",
+ "entities": [
+ {
+ "id": 0,
+ "name": "Camera",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "Camera",
+ "data": {
+ "projectionType": 0,
+ "fov": 60.0,
+ "nearPlane": 1,
+ "farPlane": 20000.0,
+ "isActive": true,
+ "priority": 0
+ }
+ }
+ ]
+ },
+ {
+ "id": 1,
+ "name": "Subject",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": -300
+ }
+ }
+ },
+ {
+ "type": "MeshRenderer",
+ "data": {
+ "mesh": "/scenes/lod-high.esmesh",
+ "lit": false,
+ "opaque": true,
+ "cullBackfaces": true,
+ "enabled": true,
+ "color": {
+ "r": 1,
+ "g": 1,
+ "b": 1,
+ "a": 1
+ }
+ }
+ },
+ {
+ "type": "LODGroup",
+ "data": {
+ "lod1": "/scenes/lod-mid.esmesh",
+ "lod2": "/scenes/lod-low.esmesh",
+ "lod3": 0,
+ "lod1Size": 0.9,
+ "lod2Size": 0.8,
+ "lod3Size": 0.0,
+ "cullSize": 0.05,
+ "hysteresis": 0.1,
+ "enabled": true
+ }
+ }
+ ]
+ }
+ ]
+}
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 07b578900..3824bfc60 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -199,6 +199,16 @@ target_include_directories(test_particle_shapes PRIVATE
)
add_test(NAME test_particle_shapes COMMAND test_particle_shapes)
+# LOD selection: the projection arithmetic, the hysteresis band and the per-view
+# memory. Header-only, so it runs without a device — the pixel gates say which
+# level was drawn, this says which of the claims behind it broke.
+add_executable(test_lod_selection renderer/test_lod_selection.cpp)
+target_include_directories(test_lod_selection PRIVATE
+ ${CMAKE_SOURCE_DIR}/src
+ ${CMAKE_SOURCE_DIR}/third_party/glm
+)
+add_test(NAME test_lod_selection COMMAND test_lod_selection)
+
add_executable(test_shadow_atlas renderer/test_shadow_atlas.cpp)
target_include_directories(test_shadow_atlas PRIVATE
${CMAKE_SOURCE_DIR}/src
diff --git a/tests/renderer/test_lod_selection.cpp b/tests/renderer/test_lod_selection.cpp
new file mode 100644
index 000000000..fd9a70542
--- /dev/null
+++ b/tests/renderer/test_lod_selection.cpp
@@ -0,0 +1,186 @@
+// The arithmetic behind LODGroup, held against its own claims without a device:
+// a projection, a sphere and the level last shown are the whole input. A pixel
+// gate can say the wrong level was drawn; only this can say which claim broke.
+
+#include "esengine/renderer/lod/LodSelection.hpp"
+#include "esengine/renderer/lod/LodViewState.hpp"
+
+#include <glm/gtc/matrix_transform.hpp>
+
+#include <cmath>
+#include <cstdio>
+
+using namespace esengine;
+
+static int g_failures = 0;
+#define CHECK(cond, msg) \
+ do { \
+ if (!(cond)) { std::printf("FAIL: %s\n", msg); ++g_failures; } \
+ else { std::printf("ok: %s\n", msg); } \
+ } while (0)
+
+static bool near(f32 a, f32 b, f32 eps = 1e-4f) { return std::fabs(a - b) < eps; }
+
+/** A camera at the origin looking down -Z, the convention the engine's own builds. */
+static glm::mat4 perspectiveVP(f32 fovDeg, f32 aspect) {
+ return glm::perspective(glm::radians(fovDeg), aspect, 1.0f, 100000.0f)
+ * glm::lookAt(glm::vec3(0.0f), glm::vec3(0.0f, 0.0f, -1.0f), glm::vec3(0.0f, 1.0f, 0.0f));
+}
+
+static glm::mat4 orthographicVP(f32 halfHeight, f32 aspect) {
+ return glm::ortho(-halfHeight * aspect, halfHeight * aspect, -halfHeight, halfHeight,
+ 1.0f, 100000.0f)
+ * glm::lookAt(glm::vec3(0.0f), glm::vec3(0.0f, 0.0f, -1.0f), glm::vec3(0.0f, 1.0f, 0.0f));
+}
+
+static f32 sizeAt(const glm::mat4& vp, f32 distance, f32 radius) {
+ return lod::screenRelativeSize(vp, glm::vec3(0.0f, 0.0f, -distance), radius);
+}
+
+static void testProjection() {
+ const glm::mat4 vp = perspectiveVP(60.0f, 1.0f);
+ const f32 tanHalf = std::tan(glm::radians(30.0f));
+
+ // The closed form a fraction of the screen HEIGHT has: a sphere of radius R at
+ // distance d covers 2R of the 2*d*tan(fov/2) the frame is tall there.
+ CHECK(near(sizeAt(vp, 1000.0f, 100.0f), 100.0f / (1000.0f * tanHalf)),
+ "perspective size is radius / (distance * tan(fov/2))");
+ CHECK(near(sizeAt(vp, 500.0f, 100.0f), 2.0f * sizeAt(vp, 1000.0f, 100.0f)),
+ "halving the distance doubles the size");
+ CHECK(near(sizeAt(vp, 1000.0f, 200.0f), 2.0f * sizeAt(vp, 1000.0f, 100.0f)),
+ "doubling the radius doubles the size");
+
+ // The claim a world distance cannot make: nothing moved, and the answer changed.
+ const glm::mat4 narrow = perspectiveVP(30.0f, 1.0f);
+ CHECK(near(sizeAt(narrow, 1000.0f, 100.0f),
+ sizeAt(vp, 1000.0f, 100.0f) * tanHalf / std::tan(glm::radians(15.0f)), 1e-3f),
+ "narrowing the field of view grows the size at a fixed distance");
+
+ // Aspect is horizontal only, so a frame twice as wide frames the same height.
+ CHECK(near(sizeAt(perspectiveVP(60.0f, 2.0f), 1000.0f, 100.0f), sizeAt(vp, 1000.0f, 100.0f)),
+ "the aspect ratio does not change a fraction of the height");
+
+ const glm::mat4 ortho = orthographicVP(500.0f, 1.0f);
+ CHECK(near(sizeAt(ortho, 1000.0f, 100.0f), 200.0f / 1000.0f),
+ "orthographic size is the diameter over the visible height");
+ CHECK(near(sizeAt(ortho, 5000.0f, 100.0f), sizeAt(ortho, 1000.0f, 100.0f)),
+ "orthographic size does not change with distance");
+
+ CHECK(sizeAt(vp, -10.0f, 100.0f) == lod::kSizeAtEye,
+ "a centre behind the eye reports the size that picks the nearest level");
+}
+
+static void testBoundingSphere() {
+ const glm::vec3 min(-100.0f, -50.0f, -25.0f), max(100.0f, 50.0f, 25.0f);
+ glm::vec3 centre(0.0f);
+ f32 radius = 0.0f;
+ lod::boundingSphere(glm::vec3(10.0f, 0.0f, -1000.0f), glm::quat(1.0f, 0.0f, 0.0f, 0.0f),
+ glm::vec3(1.0f), min, max, centre, radius);
+ CHECK(near(radius, std::sqrt(100.0f * 100.0f + 50.0f * 50.0f + 25.0f * 25.0f)),
+ "the radius is the half-diagonal of the box");
+ CHECK(near(centre.x, 10.0f) && near(centre.z, -1000.0f), "the centre is where the box is");
+
+ // A spinning object must not change level for spinning: the sphere is why.
+ glm::vec3 turnedCentre(0.0f);
+ f32 turnedRadius = 0.0f;
+ lod::boundingSphere(glm::vec3(10.0f, 0.0f, -1000.0f),
+ glm::angleAxis(glm::radians(37.0f), glm::vec3(0.3f, 1.0f, 0.2f)),
+ glm::vec3(1.0f), min, max, turnedCentre, turnedRadius);
+ CHECK(near(turnedRadius, radius), "turning the object does not change the radius");
+
+ lod::boundingSphere(glm::vec3(0.0f), glm::quat(1.0f, 0.0f, 0.0f, 0.0f), glm::vec3(2.0f),
+ min, max, centre, radius);
+ CHECK(near(radius, 2.0f * turnedRadius), "scale multiplies the radius");
+}
+
+/** Two stand-ins at 0.5 and 0.25, culled under 0.05, with a tenth of hysteresis. */
+static lod::LevelSet twoStandIns(f32 hysteresis = 0.1f) {
+ lod::LevelSet set;
+ set.takeOver[0] = 0.5f;
+ set.takeOver[1] = 0.25f;
+ set.count = 2;
+ set.cull = 0.05f;
+ set.hysteresis = hysteresis;
+ return set;
+}
+
+static void testSelection() {
+ const lod::LevelSet set = twoStandIns();
+ CHECK(lod::selectLevel(set, 0.80f, 0) == 0, "a big object takes level 0");
+ CHECK(lod::selectLevel(set, 0.30f, 0) == 1, "under the first threshold takes level 1");
+ CHECK(lod::selectLevel(set, 0.10f, 0) == 2, "under the second threshold takes level 2");
+ CHECK(lod::selectLevel(set, 0.01f, 0) == lod::kCulled, "under the cull size nothing is drawn");
+
+ lod::LevelSet noCull = set;
+ noCull.cull = 0.0f;
+ CHECK(lod::selectLevel(noCull, 0.0001f, 0) == 2,
+ "a group with no cull size is never invisible");
+}
+
+static void testHysteresis() {
+ const lod::LevelSet set = twoStandIns();
+
+ // The band the boundary is thick by: 0.5 going coarse, 0.55 coming back.
+ CHECK(lod::selectLevel(set, 0.49f, 0) == 1, "0.49 hands over to level 1");
+ CHECK(lod::selectLevel(set, 0.52f, 1) == 1, "inside the band the coarse level holds");
+ CHECK(lod::selectLevel(set, 0.56f, 1) == 0, "past the band the fine level returns");
+
+ lod::LevelSet none = twoStandIns(0.0f);
+ CHECK(lod::selectLevel(none, 0.52f, 1) == 0,
+ "without hysteresis the same size flips straight back");
+
+ // A camera breathing across the boundary: with the band the level is drawn once
+ // and stays, without it the level changes on every frame.
+ u8 held = 0, flipped = 0, heldChanges = 0, flippedChanges = 0;
+ for (int i = 0; i < 8; ++i) {
+ const f32 size = (i % 2 == 0) ? 0.49f : 0.51f;
+ const u8 nextHeld = lod::selectLevel(set, size, held);
+ const u8 nextFlipped = lod::selectLevel(none, size, flipped);
+ if (nextHeld != held) ++heldChanges;
+ if (nextFlipped != flipped) ++flippedChanges;
+ held = nextHeld;
+ flipped = nextFlipped;
+ }
+ CHECK(heldChanges == 1, "jitter across the boundary changes the level once");
+ CHECK(flippedChanges == 8, "with no band the same jitter changes it every frame");
+
+ CHECK(lod::selectLevel(set, 0.052f, lod::kCulled) == lod::kCulled,
+ "the cull boundary has the same band");
+ CHECK(lod::selectLevel(set, 0.06f, lod::kCulled) == 2, "past it the object comes back");
+}
+
+static void testViewOwnership() {
+ lod::LodViewState state;
+ const Entity object = Entity::make(7, 1);
+ const u32 mainCamera = 11, minimap = 12;
+
+ state.beginFrame();
+ CHECK(state.lastLevel(mainCamera, object) == 0, "an unseen pair starts unbiased");
+
+ state.remember(mainCamera, object, 0);
+ state.remember(minimap, object, 2);
+ CHECK(state.lastLevel(mainCamera, object) == 0 && state.lastLevel(minimap, object) == 2,
+ "one object is remembered at two levels by two views");
+
+ // The same size, decided under each view's own memory: the near camera holds
+ // the fine level inside the band and the far one holds the coarse level.
+ const lod::LevelSet set = twoStandIns();
+ CHECK(lod::selectLevel(set, 0.52f, state.lastLevel(mainCamera, object)) == 0
+ && lod::selectLevel(set, 0.52f, state.lastLevel(minimap, object)) == 1,
+ "two views decide the same size differently");
+
+ const usize before = state.size();
+ for (u64 i = 0; i < lod::LodViewState::kKeepFrames * 3; ++i) state.beginFrame();
+ CHECK(before == 2 && state.size() == 0, "a pair no view asks about again is dropped");
+}
+
+int main() {
+ testProjection();
+ testBoundingSphere();
+ testSelection();
+ testHysteresis();
+ testViewOwnership();
+ std::printf(g_failures ? "\n%d failure(s)\n" : "\nall LOD selection claims hold\n",
+ g_failures);
+ return g_failures ? 1 : 0;
+}
diff --git a/tools/render-host/run.mjs b/tools/render-host/run.mjs
index 5a23d8d4a..16f477a02 100644
--- a/tools/render-host/run.mjs
+++ b/tools/render-host/run.mjs
@@ -361,17 +361,23 @@ app.whenReady().then(async () => {
// ESTELLA_VERIFY_SET_FIELD={"entity","component","key","value"} writes one
// inspector field the way the editor's own door does, then waits: an asset
// assigned after load is COLD, and reaching the World is an async load away.
+ // An ARRAY of those is a route rather than a position, which is what a gate
+ // about where a frame CAME FROM needs — the LOD hysteresis gates park one
+ // object at one place along two different roads and read two answers.
if (process.env.ESTELLA_VERIFY_SET_FIELD) {
- const spec = JSON.parse(process.env.ESTELLA_VERIFY_SET_FIELD);
+ const parsed = JSON.parse(process.env.ESTELLA_VERIFY_SET_FIELD);
+ const writes = Array.isArray(parsed) ? parsed : [parsed];
setField = await exec(`(async () => {
const api = window.__estellaHeadless.api;
- api.setField(${JSON.stringify(spec.entity)}, ${JSON.stringify(spec.component)},
- ${JSON.stringify(spec.key)}, "asset", ${JSON.stringify(spec.value)});
- for (let i = 0; i < 40; i++) {
- await api.step(1, 1 / 60);
- await new Promise((r) => setTimeout(r, 16));
+ const writes = ${JSON.stringify(writes)};
+ for (const w of writes) {
+ api.setField(w.entity, w.component, w.key, "asset", w.value);
+ for (let i = 0; i < (w.steps ?? 40); i++) {
+ await api.step(1, 1 / 60);
+ await new Promise((r) => setTimeout(r, 16));
+ }
}
- return { wrote: ${JSON.stringify(spec.key)} };
+ return { wrote: writes.map((w) => w.key).join(',') };
})()`);
}
diff --git a/tools/renderScenes.mjs b/tools/renderScenes.mjs
index e00bfd7c7..6cf0df52b 100644
--- a/tools/renderScenes.mjs
+++ b/tools/renderScenes.mjs
@@ -188,6 +188,42 @@ export const SCENES = [
// depth layer and boots LINEAR — the cheap way to engage the post-process capture.
// Opaque sorts front-to-back, so with no attachment the far cube paints over.
{ id: "mesh-depth-through-capture", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_COLORSPACE: "linear", ESTELLA_VERIFY_SCENE: "/scenes/mesh-depth-through-capture.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.57,\"y\":0.5,\"rgb\":[255,0,0],\"tol\":30},{\"x\":0.4,\"y\":0.5,\"rgb\":[255,0,0],\"tol\":30},{\"x\":0.74,\"y\":0.5,\"rgb\":[0,255,0],\"tol\":30},{\"x\":0.1,\"y\":0.5,\"rgb\":[0,0,0],\"tol\":20}]" } },
+ // Four identical groups on the view axis, where the projected size is exactly
+ // 300/distance: 0.60, 0.30, 0.15, 0.0375 against thresholds 0.5, 0.25, cull 0.05.
+ // 224 + 8 + 4 triangles is the second witness — one of each mesh, nothing else.
+ { id: "lod-levels", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/lod-3d.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "4", ESTELLA_VERIFY_COUNTERS: "{\"render.lod.groups\":4,\"render.lod.level0\":1,\"render.lod.level1\":1,\"render.lod.level2\":1,\"render.lod.level3\":0,\"render.lod.culled\":1,\"render.culled\":1,\"render.meshes\":3,\"render.triangles\":236}" } },
+ // The same scene with nothing moved and the field of view halved. Every level
+ // steps one finer, which is the claim a world distance cannot make: a distance
+ // threshold answers the same at 60 degrees and at 30.
+ { id: "lod-fov", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/lod-3d.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "4", ESTELLA_VERIFY_SET_FIELD: "{\"entity\":0,\"component\":\"Camera\",\"key\":\"fov\",\"value\":30,\"steps\":4}", ESTELLA_VERIFY_COUNTERS: "{\"render.lod.groups\":4,\"render.lod.level0\":2,\"render.lod.level1\":1,\"render.lod.level2\":1,\"render.lod.culled\":0,\"render.triangles\":460}" } },
+ // Two of the same group at the SAME distance, one scaled to two fifths. They take
+ // different levels, which is what "how big does it look" means and what a distance
+ // cannot express: a hundred metres is one answer for a tower and another for a pebble.
+ { id: "lod-size", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/lod-size.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "4", ESTELLA_VERIFY_COUNTERS: "{\"render.lod.groups\":2,\"render.lod.level0\":0,\"render.lod.level1\":1,\"render.lod.level2\":1,\"render.triangles\":12}" } },
+ // ONE object, two cameras, one frame — and two levels, only possible if the choice
+ // belongs to the view. Their sizes sit either side of one boundary and inside each
+ // other's band, so a memory SHARED between the views drags both onto one level.
+ { id: "lod-multi-camera", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/lod-multicam.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "8", ESTELLA_VERIFY_COUNTERS: "{\"render.lod.groups\":2,\"render.lod.level0\":1,\"render.lod.level1\":1,\"render.lod.level2\":0,\"render.lod.culled\":0}" } },
+ // Sixty-four copies of one group, all at one distance and so all at one level. What
+ // the batcher achieved is the whole assertion: choosing a level changes which
+ // geometry a draw names and nothing else, so the copies still fold into ONE call.
+ { id: "lod-instancing", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/lod-instanced.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "4", ESTELLA_VERIFY_SCALE: "{\"copies\":64,\"cols\":8,\"spacing\":[110,110]}", ESTELLA_VERIFY_COUNTERS: "{\"render.lod.groups\":64,\"render.lod.level1\":64,\"render.meshes\":64,\"render.triangles\":512,\"batch.draws\":1}" } },
+ // Parked at 577 units, where the size is 0.5199 — past the 0.5 boundary, inside the
+ // tenth of hysteresis above it. Arrived at from FARTHER away, so the coarse level
+ // holds. The pair below is the same place reached from the other side.
+ { id: "lod-hysteresis-coarse", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/lod-hyst.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "4", ESTELLA_VERIFY_SET_FIELD: "[{\"entity\":1,\"component\":\"Transform\",\"key\":\"position.z\",\"value\":-900,\"steps\":4},{\"entity\":1,\"component\":\"Transform\",\"key\":\"position.z\",\"value\":-577,\"steps\":4}]", ESTELLA_VERIFY_COUNTERS: "{\"render.lod.level0\":0,\"render.lod.level1\":1,\"render.triangles\":8}" } },
+ // The same object at the same 577 units, reached from NEARER. Level 0 holds, and the
+ // two gates differ in nothing a frame can see but where the object came from.
+ { id: "lod-hysteresis-fine", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/lod-hyst.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "4", ESTELLA_VERIFY_SET_FIELD: "[{\"entity\":1,\"component\":\"Transform\",\"key\":\"position.z\",\"value\":-400,\"steps\":4},{\"entity\":1,\"component\":\"Transform\",\"key\":\"position.z\",\"value\":-577,\"steps\":4}]", ESTELLA_VERIFY_COUNTERS: "{\"render.lod.level0\":1,\"render.lod.level1\":0,\"render.triangles\":224}" } },
+ // The swap as a PICTURE, which no counter is: the three meshes are red, green and
+ // blue, so the pixel at the centre says which geometry the frame actually holds.
+ { id: "lod-swap-near", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/lod-swap.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "4", ESTELLA_VERIFY_COUNTERS: "{\"render.lod.level0\":1,\"render.triangles\":224}", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.5,\"y\":0.5,\"rgb\":[255,0,0],\"tol\":40}]" } },
+ { id: "lod-swap-mid", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/lod-swap.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "4", ESTELLA_VERIFY_SET_FIELD: "{\"entity\":1,\"component\":\"Transform\",\"key\":\"position.z\",\"value\":-360,\"steps\":4}", ESTELLA_VERIFY_COUNTERS: "{\"render.lod.level1\":1,\"render.triangles\":8}", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.5,\"y\":0.5,\"rgb\":[0,255,0],\"tol\":40}]" } },
+ { id: "lod-swap-far", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/lod-swap.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "4", ESTELLA_VERIFY_SET_FIELD: "{\"entity\":1,\"component\":\"Transform\",\"key\":\"position.z\",\"value\":-400,\"steps\":4}", ESTELLA_VERIFY_COUNTERS: "{\"render.lod.level2\":1,\"render.triangles\":4}", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.5,\"y\":0.5,\"rgb\":[0,0,255],\"tol\":40}]" } },
+ // A group whose stand-in cannot be posed by the same skeleton is REFUSED whole
+ // rather than honoured into a bind pose: the skin draws as it always did
+ // (mesh-skin's own points), and thresholds that would cull it decide nothing.
+ { id: "lod-skin-refused", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/lod-skin.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_COUNTERS: "{\"render.lod.groups\":0,\"render.lod.culled\":0,\"render.meshes\":1}", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.35,\"y\":0.6,\"rgb\":[0,255,0],\"tol\":30},{\"x\":0.75,\"y\":0.35,\"rgb\":[0,255,0],\"tol\":30},{\"x\":0.75,\"y\":0.60,\"rgb\":[0,0,0],\"tol\":20}]" } },
{ id: "mesh-builtin", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/mesh-builtin.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.3667,\"y\":0.5,\"rgb\":[236,236,236],\"tol\":20},{\"x\":0.1333,\"y\":0.5,\"rgb\":[98,98,98],\"tol\":20},{\"x\":0.75,\"y\":0.5,\"rgb\":[236,236,236],\"tol\":20},{\"x\":0.6667,\"y\":0.5,\"rgb\":[155,155,155],\"tol\":20},{\"x\":0.5,\"y\":0.5,\"rgb\":[0,0,0],\"tol\":20}]" } },
// A baked panorama lighting a surface BY DIRECTION: two coplanar triangles, one
// white colour, normals up and down under a sky blue above and red below. A flat