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.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
feat(quality): the low level leaves the dynamic GI out, and a level that does builds no distance field for it either
yhh67e4e05994c7
diff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.mdindex 490e51282..4728b78fd 100644--- a/sdk/etc/index.api.md+++ b/sdk/etc/index.api.md@@ -8113,6 +8113,7 @@ antialiasing: "msaa" | "temporal"begin: () => voidbind: (camera: Entity, stack: PostProcessStack) => voidcreateStack: () => PostProcessStack+effectAllowed: (type: string) => booleanend: () => voidgetStack: (camera: Entity) => PostProcessStack | nullhdrFormat: () => HdrFormat | nulldiff --git a/sdk/etc/index.native.api.md b/sdk/etc/index.native.api.mdindex e2b061e73..00a30dd10 100644--- a/sdk/etc/index.native.api.md+++ b/sdk/etc/index.native.api.md@@ -8320,6 +8320,7 @@ antialiasing: "msaa" | "temporal"begin: () => voidbind: (camera: Entity, stack: PostProcessStack) => voidcreateStack: () => PostProcessStack+effectAllowed: (type: string) => booleanend: () => voidgetStack: (camera: Entity) => PostProcessStack | nullhdrFormat: () => HdrFormat | nulldiff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.mdindex e26384ea4..28ddea59d 100644--- a/sdk/etc/index.node.api.md+++ b/sdk/etc/index.node.api.md@@ -8108,6 +8108,7 @@ antialiasing: "msaa" | "temporal"begin: () => voidbind: (camera: Entity, stack: PostProcessStack) => voidcreateStack: () => PostProcessStack+effectAllowed: (type: string) => booleanend: () => voidgetStack: (camera: Entity) => PostProcessStack | nullhdrFormat: () => HdrFormat | nulldiff --git a/sdk/etc/minigame.api.md b/sdk/etc/minigame.api.mdindex 814d8d3c8..39b268c3a 100644--- a/sdk/etc/minigame.api.md+++ b/sdk/etc/minigame.api.md@@ -8405,6 +8405,7 @@ antialiasing: "msaa" | "temporal"begin: () => voidbind: (camera: Entity, stack: PostProcessStack) => voidcreateStack: () => PostProcessStack+effectAllowed: (type: string) => booleanend: () => voidgetStack: (camera: Entity) => PostProcessStack | nullhdrFormat: () => HdrFormat | nulldiff --git a/sdk/etc/wechat.api.md b/sdk/etc/wechat.api.mdindex 49bc67cd7..762a3c442 100644--- a/sdk/etc/wechat.api.md+++ b/sdk/etc/wechat.api.md@@ -8115,6 +8115,7 @@ antialiasing: "msaa" | "temporal"begin: () => voidbind: (camera: Entity, stack: PostProcessStack) => voidcreateStack: () => PostProcessStack+effectAllowed: (type: string) => booleanend: () => voidgetStack: (camera: Entity) => PostProcessStack | nullhdrFormat: () => HdrFormat | nulldiff --git a/sdk/src/gi/dynamicGISystem.ts b/sdk/src/gi/dynamicGISystem.tsindex 12970bd7f..6947c5131 100644--- a/sdk/src/gi/dynamicGISystem.ts+++ b/sdk/src/gi/dynamicGISystem.ts@@ -23,6 +23,7 @@ import { withScratch } from '../wasm/wasmScratch';import { marshallingCore } from '../asset/loaders/engineCore';import { nativeEngineApi } from '../ecs/bridge/engineApi';import { Material } from '../render/material';+import { PostProcess } from '../postprocess/PostProcessAPI';import { analyticBox, instanceBounds, packGPUScene, type GIInstance, type GILight, type GPUScene } from './gpuScene';import { GlobalSdf } from './globalSdf';import type { PointLight } from './surfaceCache';@@ -229,7 +230,9 @@ export function dynamicGISystem(app: App) {});};const effect = dynamicGIEffect(volumes);- if (!effect) { lastKey = ''; field = null; waiting = null; return; }+ // A quality level that leaves the effect out (the low one does: a device that cannot afford the passes) builds no field either.+ const allowed = !app.hasResource(PostProcess) || app.getResource(PostProcess).effectAllowed('dynamicGI');+ if (!effect || !allowed) { lastKey = ''; field = null; waiting = null; return; }// The web's module, or a device's host (which answers the same heap from its arena): the arrays cross the boundary through it.const m = marshallingCore(app.wasmModule ?? nativeEngineApi());if (!m?.postprocess_setGIScene) return;diff --git a/sdk/src/postprocess/PostProcessAPI.ts b/sdk/src/postprocess/PostProcessAPI.tsindex 558cffae1..c2b40be01 100644--- a/sdk/src/postprocess/PostProcessAPI.ts+++ b/sdk/src/postprocess/PostProcessAPI.ts@@ -9,6 +9,7 @@ import { WasmBridge } from '../wasm/WasmBridge';import { PostProcessStack, PostProcessState } from './PostProcessStack';import type { QualityProfile } from '../render/quality';import { qualityPassAllowed } from './qualityFilter';+import { effectPassNames } from './effects';/*** The post-process entry points as a core that HAS them answers them. Named, not@@ -262,6 +263,15 @@ export class PostProcessAPI {return this.qualityFilter_?.antialiasing ?? 'msaa';}+ /**+ * Whether the quality level in force runs an effect, by its type. For a system that prepares something for an effect off the GPU (the dynamic GI+ * builds a distance field, a second of a phone's CPU): it asks before it does.+ */+ effectAllowed(type: string): boolean {+ const passes = effectPassNames(type);+ return (passes.length > 0 ? passes : [type]).every((name) => qualityPassAllowed(this.qualityFilter_, name));+ }+private allowQualityPass_ = (name: string): boolean => {return qualityPassAllowed(this.qualityFilter_, name);};diff --git a/sdk/src/render/quality.ts b/sdk/src/render/quality.tsindex 0b683f42f..60152e933 100644--- a/sdk/src/render/quality.ts+++ b/sdk/src/render/quality.ts@@ -148,7 +148,7 @@ const PROFILES: Record<QualityLevel, QualityProfile> = {planarReflectionScale: 0.25, planarReflectionMaxSize: 512, planarReflectionUpdatesPerSecond: 0, depthPrepass: false,shadowDistance: 0, detailScale: 0.5, particleLimit: 1000, postProcess: true, ssao: false,waterWaves: 2, waterRippleCells: 32, waterDisplacement: false, waterMirror: false, waterCaustics: false,- skipEffects: ['ssr', 'taa', 'depthOfField', 'lightShafts', 'motionBlur', 'lensFlare', 'gtao', 'subsurface', 'voxelGI'],+ skipEffects: ['ssr', 'taa', 'depthOfField', 'lightShafts', 'motionBlur', 'lensFlare', 'gtao', 'subsurface', 'voxelGI', 'dynamicGI'],shelterMaskSize: 256, shadowSoftSamples: 8, lighting: 'direct', drawCallBudget: 150, textureStreaming: true, textureStreamingBudget: 128,},medium: {diff --git a/sdk/tests/quality.test.ts b/sdk/tests/quality.test.tsindex 5c9213022..6c0c494d0 100644--- a/sdk/tests/quality.test.ts+++ b/sdk/tests/quality.test.ts@@ -221,6 +221,17 @@ describe('what a quality level lets the chain run', () => {expect(qualityPassAllowed(profile, 'ssr'), 'ssr').toBe(true);});+ it('leaves the dynamic GI out of the low level and in the other two', async () => {+ const { qualityPassAllowed } = await import('../src/postprocess/qualityFilter');+ const { effectPassNames } = await import('../src/postprocess/effects');+ const passes = effectPassNames('dynamicGI');+ expect(passes.length).toBeGreaterThan(0);+ for (const mode of ['low', 'medium', 'high'] as const) {+ const profile = new QualityController({ mode }).profile;+ for (const pass of passes) expect(qualityPassAllowed(profile, pass), `${mode} ${pass}`).toBe(mode !== 'low');+ }+ });+it('keeps the old prefix reading for a name no effect answers to, and the ssao and post-process switches', async () => {const { qualityPassAllowed } = await import('../src/postprocess/qualityFilter');expect(qualityPassAllowed(level(['custom']), 'custom_pass')).toBe(false);