zhuda-laya-engine 0.0.0-stage → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +236 -0
- package/CHANGELOG.md +431 -0
- package/LICENSE +41 -0
- package/README.md +247 -2
- package/assets/branding/layaair-tribute-mark.svg +5 -0
- package/assets/branding/zhuda-layaair-mark.svg +34 -0
- package/assets/prefabs/CoinFountainVfx.lh +197 -0
- package/assets/prefabs/ConfirmActionButton.lh +87 -0
- package/assets/prefabs/LevelUpAuraVfx.lh +136 -0
- package/assets/prefabs/MineExplosionParticle.lh +352 -0
- package/assets/prefabs/NineSliceDialogFrame.lh +171 -0
- package/assets/prefabs/SwordSlashTrailVfx.lh +117 -0
- package/assets/prefabs/TacticalHudBar.lh +134 -0
- package/assets/prefabs/TelemetryDashboard.lh +87 -0
- package/assets/prefabs/UnityCrystalGuardian.lh +144 -0
- package/assets/prefabs/ZhudaSpine42Mascot.lh +183 -0
- package/assets/scenes/MinesweeperStage.ls +1180 -0
- package/dist/asset-calibration-report.json +969 -0
- package/dist/build-manifest.json +254 -0
- package/dist/sdk/zhuda-laya-csg.cjs +710 -0
- package/dist/sdk/zhuda-laya-csg.esm.js +683 -0
- package/dist/sdk/zhuda-laya-csg.min.cjs +7 -0
- package/dist/sdk/zhuda-laya-csg.min.esm.js +7 -0
- package/dist/sdk/zhuda-laya-demo.cjs +5990 -0
- package/dist/sdk/zhuda-laya-demo.esm.js +5956 -0
- package/dist/sdk/zhuda-laya-demo.min.cjs +12 -0
- package/dist/sdk/zhuda-laya-demo.min.esm.js +12 -0
- package/dist/sdk/zhuda-laya-engine.cjs +52628 -0
- package/dist/sdk/zhuda-laya-engine.esm.js +51848 -0
- package/dist/sdk/zhuda-laya-engine.min.cjs +2710 -0
- package/dist/sdk/zhuda-laya-engine.min.esm.js +2710 -0
- package/docs/3d-acceptance.md +47 -0
- package/docs/3d-integration.md +190 -0
- package/docs/README.md +112 -0
- package/docs/SUPPORT.md +21 -0
- package/docs/agent-development.md +219 -0
- package/docs/animation-control.md +213 -0
- package/docs/asset-loading.md +97 -0
- package/docs/assets/reference-games.jpg +0 -0
- package/docs/assets/solana-qr.png +0 -0
- package/docs/assets/sponsor-pass.svg +32 -0
- package/docs/audio.md +319 -0
- package/docs/backend-delivery.md +218 -0
- package/docs/basis-textures.md +94 -0
- package/docs/browser-sdk-releases.json +204 -0
- package/docs/browser-sdk.md +187 -0
- package/docs/cinematics.md +267 -0
- package/docs/cloth.md +280 -0
- package/docs/combat-runtime.md +82 -0
- package/docs/consumer-route.md +169 -0
- package/docs/consumer-tooling.md +518 -0
- package/docs/crowd-runtime.md +195 -0
- package/docs/developer-tooling.md +191 -0
- package/docs/film-scenes.md +1504 -0
- package/docs/filmic-rendering.md +743 -0
- package/docs/flythrough.md +89 -0
- package/docs/gpu-depth.md +207 -0
- package/docs/grass.md +127 -0
- package/docs/hdr-environment.md +76 -0
- package/docs/instanced-meshes.md +137 -0
- package/docs/layout-and-media.md +37 -0
- package/docs/layout-wireframe.md +80 -0
- package/docs/lighting-depth.md +185 -0
- package/docs/minigame-packaging.md +79 -0
- package/docs/model-editor.md +66 -0
- package/docs/model-lod.md +122 -0
- package/docs/model-pipeline.md +74 -0
- package/docs/model-showcase.md +365 -0
- package/docs/overview.md +183 -0
- package/docs/plans/README.md +133 -0
- package/docs/plans/TASK-TEMPLATE.md +64 -0
- package/docs/plans/TASK-spine38-isolated-topology-20261106.md +89 -0
- package/docs/plans/TEMPLATE.md +44 -0
- package/docs/plans/VERIFICATION-TEMPLATE.md +45 -0
- package/docs/plans/asset-packaging.md +140 -0
- package/docs/plans/cinematic-production/task.md +97 -0
- package/docs/plans/cinematic-production/verification.md +49 -0
- package/docs/plans/consumer-delivery-followups.md +129 -0
- package/docs/plans/desktop-and-agent-gates/hardening-task.md +85 -0
- package/docs/plans/desktop-and-agent-gates/hardening-verification.md +109 -0
- package/docs/plans/desktop-and-agent-gates/task.md +94 -0
- package/docs/plans/desktop-and-agent-gates/verification.md +60 -0
- package/docs/plans/prefab-toolchain.md +73 -0
- package/docs/plans/preview-runtime-hardening.md +68 -0
- package/docs/platform-adapters.md +113 -0
- package/docs/post-quality.md +242 -0
- package/docs/prefab-editor.md +194 -0
- package/docs/prefab-library.md +94 -0
- package/docs/prefab-workflow.md +75 -0
- package/docs/procedural-assets.md +463 -0
- package/docs/procedural-prefabs.md +133 -0
- package/docs/quality-route.md +386 -0
- package/docs/release-policy.md +79 -0
- package/docs/routes/README.md +180 -0
- package/docs/routes/TEMPLATE.md +54 -0
- package/docs/routes/action-adventure-3d-minigame.md +238 -0
- package/docs/routes/apocalypse-survival-3d.md +219 -0
- package/docs/routes/aqua-freeze-2d-minigame.md +183 -0
- package/docs/routes/astral-minimal-film-look.md +141 -0
- package/docs/routes/cascade-slot.md +93 -0
- package/docs/routes/clip-free-garments.md +229 -0
- package/docs/routes/drop-merge-2d-minigame.md +200 -0
- package/docs/routes/dungeon-line-slot.md +87 -0
- package/docs/routes/film-as-data.md +131 -0
- package/docs/routes/film-fight-that-lands.md +198 -0
- package/docs/routes/film-ink-lines.md +120 -0
- package/docs/routes/floating-island.md +229 -0
- package/docs/routes/game-2d.md +168 -0
- package/docs/routes/game-rules-first.md +89 -0
- package/docs/routes/game-to-prefabs.md +249 -0
- package/docs/routes/go-game-server.md +95 -0
- package/docs/routes/good-looking-3d-scene.md +99 -0
- package/docs/routes/high-quality-character.md +263 -0
- package/docs/routes/humanoid-from-shapes.md +97 -0
- package/docs/routes/hunting-action-3d.md +76 -0
- package/docs/routes/idle-gacha-2d.md +67 -0
- package/docs/routes/interactive-film-viewer.md +141 -0
- package/docs/routes/isometric-mystery-2d.md +217 -0
- package/docs/routes/key-art-to-animated-title.md +132 -0
- package/docs/routes/laya-ide-project-cli-web.md +125 -0
- package/docs/routes/layered-cloth-on-body.md +240 -0
- package/docs/routes/low-poly-character-from-shapes.md +475 -0
- package/docs/routes/match-three-2d.md +64 -0
- package/docs/routes/merge-2d.md +59 -0
- package/docs/routes/mini-game-build.md +80 -0
- package/docs/routes/mobile-always-landscape.md +149 -0
- package/docs/routes/mobile-web-fullscreen.md +255 -0
- package/docs/routes/model-from-dcc.md +106 -0
- package/docs/routes/new-game-project.md +100 -0
- package/docs/routes/onboarding-tutorial-2d.md +54 -0
- package/docs/routes/online-lockstep-match.md +473 -0
- package/docs/routes/outdoor-landscape.md +134 -0
- package/docs/routes/outfit-swap-3d.md +144 -0
- package/docs/routes/papercraft-diorama.md +186 -0
- package/docs/routes/platform-fighter-2d.md +235 -0
- package/docs/routes/platformer-2d.md +69 -0
- package/docs/routes/pole-rescue-arcade-3d.md +198 -0
- package/docs/routes/pose-atlas-motion.md +188 -0
- package/docs/routes/prototype-to-center.md +162 -0
- package/docs/routes/raft-brawl-3d-minigame.md +205 -0
- package/docs/routes/rhythm-2d.md +82 -0
- package/docs/routes/rigged-phone-character.md +120 -0
- package/docs/routes/screen-fit-game-box.md +127 -0
- package/docs/routes/shared-islands.md +195 -0
- package/docs/routes/side-view-duel.md +266 -0
- package/docs/routes/single-html-page.md +83 -0
- package/docs/routes/smooth-character-motion.md +162 -0
- package/docs/routes/spine-character.md +175 -0
- package/docs/routes/story-counting-2d.md +219 -0
- package/docs/routes/survivors-2d.md +60 -0
- package/docs/routes/third-person-town-3d.md +240 -0
- package/docs/routes/tower-defence-3d.md +67 -0
- package/docs/routes/ui-test-by-probe.md +219 -0
- package/docs/routes/underwater.md +138 -0
- package/docs/routes/visual-content-prefab.md +101 -0
- package/docs/runtime-hardening.md +108 -0
- package/docs/shader-warm-up.md +125 -0
- package/docs/spring-bones.md +79 -0
- package/docs/stylized-shading.md +171 -0
- package/docs/terrain-shader.md +130 -0
- package/docs/vrm.md +128 -0
- package/docs/walking.md +97 -0
- package/docs/webgpu.md +225 -0
- package/docs/white-label-themes.md +212 -0
- package/docs/zh-CN/README.md +130 -0
- package/examples/browser-sdk/2d-webgpu.html +46 -0
- package/examples/browser-sdk/2d.html +46 -0
- package/examples/browser-sdk/3d-gltf-webgpu.html +50 -0
- package/examples/browser-sdk/3d-gltf.html +50 -0
- package/examples/browser-sdk/3d-webgpu.html +46 -0
- package/examples/browser-sdk/3d.html +46 -0
- package/examples/cinematic-capture/Main.ts +294 -0
- package/examples/cinematic-capture/README.md +27 -0
- package/examples/model-inspector/README.md +15 -0
- package/examples/model-inspector/asset.gltf +158 -0
- package/examples/windows-webgpu/README.md +57 -0
- package/examples/windows-webgpu/bundle.mjs +122 -0
- package/examples/windows-webgpu/main.mjs +302 -0
- package/examples/windows-webgpu/package-lock.json +2353 -0
- package/examples/windows-webgpu/package.json +40 -0
- package/examples/windows-webgpu/squirrel.mjs +66 -0
- package/package.json +259 -4
- package/packages/ci-gate/export-film.mjs +347 -0
- package/packages/ci-gate/verify-sequence.mjs +285 -0
- package/packages/compiler/agent-contract.mjs +545 -0
- package/packages/compiler/ast-scanner.mjs +254 -0
- package/packages/compiler/backend-loader.mjs +62 -0
- package/packages/compiler/branding-assets.mjs +32 -0
- package/packages/compiler/branding.mjs +324 -0
- package/packages/compiler/browser-auto-example.mjs +31 -0
- package/packages/compiler/browser-model-example.mjs +53 -0
- package/packages/compiler/browser-process.mjs +344 -0
- package/packages/compiler/browser-sdk-example.mjs +50 -0
- package/packages/compiler/browser-sdk.mjs +342 -0
- package/packages/compiler/chrome-host.mjs +196 -0
- package/packages/compiler/cli.mjs +22 -0
- package/packages/compiler/compiler-runtime.mjs +41 -0
- package/packages/compiler/consumer-accept.mjs +89 -0
- package/packages/compiler/consumer-build.mjs +641 -0
- package/packages/compiler/consumer-guards.mjs +422 -0
- package/packages/compiler/consumer-publication.mjs +56 -0
- package/packages/compiler/consumer-scripts.mjs +134 -0
- package/packages/compiler/consumer-starter-2d.mjs +54 -0
- package/packages/compiler/consumer-starter-minigame.mjs +30 -0
- package/packages/compiler/editor-http.mjs +210 -0
- package/packages/compiler/editor-request.ts +12 -0
- package/packages/compiler/film-host-client.ts +249 -0
- package/packages/compiler/flythrough-file.mjs +144 -0
- package/packages/compiler/json-locate.mjs +85 -0
- package/packages/compiler/layout-contract.mjs +472 -0
- package/packages/compiler/minigame-bootstrap.mjs +24 -0
- package/packages/compiler/minigame-bridge.mjs +66 -0
- package/packages/compiler/minigame-guards.mjs +107 -0
- package/packages/compiler/minigame-toolchain.mjs +241 -0
- package/packages/compiler/model-crown.mjs +173 -0
- package/packages/compiler/model-editor-client.ts +809 -0
- package/packages/compiler/model-editor.mjs +242 -0
- package/packages/compiler/model-lod.mjs +547 -0
- package/packages/compiler/prefab-check.mjs +288 -0
- package/packages/compiler/prefab-checks.mjs +74 -0
- package/packages/compiler/prefab-dependencies.mjs +102 -0
- package/packages/compiler/prefab-editor-client.ts +950 -0
- package/packages/compiler/prefab-editor-preview.ts +89 -0
- package/packages/compiler/prefab-editor-server.mjs +585 -0
- package/packages/compiler/prefab-editor.mjs +43 -0
- package/packages/compiler/prefab-environment.mjs +107 -0
- package/packages/compiler/prefab-lifecycle.mjs +60 -0
- package/packages/compiler/prefab-preview.mjs +159 -0
- package/packages/compiler/prefab-watch.mjs +459 -0
- package/packages/compiler/runtime3d-types.mjs +91 -0
- package/packages/compiler/stage-probe.mjs +557 -0
- package/packages/compiler/visual-asset-audit.mjs +609 -0
- package/packages/compiler/visual-contract-audit.mjs +173 -0
- package/packages/compiler/webgpu-loader.mjs +153 -0
- package/packages/compiler/zhuda-build.mjs +714 -0
- package/packages/compiler/zhuda-doctor.mjs +186 -0
- package/packages/compiler/zhuda-init.mjs +353 -0
- package/packages/compiler/zhuda-layout.mjs +163 -0
- package/packages/compiler/zhuda-minigame.mjs +636 -0
- package/packages/core/BenchmarkEngine.ts +2 -0
- package/packages/core/BitmapFontContract.ts +159 -0
- package/packages/core/DeclarativeSDK.ts +686 -0
- package/packages/core/IframeSoundAdapter.ts +1824 -0
- package/packages/core/NoSleepAdapter.ts +302 -0
- package/packages/core/PixelCalibrationEngine.ts +602 -0
- package/packages/core/Prefab.ts +314 -0
- package/packages/core/RealmGuards.ts +111 -0
- package/packages/core/ResponsiveLayout.ts +149 -0
- package/packages/core/RuntimeGuards.ts +261 -0
- package/packages/core/SpineCharacter.ts +243 -0
- package/packages/core/SpineVisualContract.ts +238 -0
- package/packages/core/SplashSignal.ts +72 -0
- package/packages/core/StaticAssetPipeline.ts +3 -0
- package/packages/core/TopologyGraph.ts +693 -0
- package/packages/core/UnityBridgePipeline.ts +2 -0
- package/packages/core/VideoSurface.ts +75 -0
- package/packages/core/ViewportMatrixEngine.ts +237 -0
- package/packages/core/VisualFocusContract.ts +76 -0
- package/packages/core/VisualMigrationPipeline.ts +245 -0
- package/packages/core/WebViewSurface.ts +116 -0
- package/packages/core/audio/OfflineMix.ts +186 -0
- package/packages/core/audio/Spatial.ts +312 -0
- package/packages/core/audio/StreamVoice.ts +161 -0
- package/packages/core/csg/Bsp.ts +310 -0
- package/packages/core/csg/index.ts +589 -0
- package/packages/core/effects/Effect2D.ts +286 -0
- package/packages/core/effects/Effect3D.ts +213 -0
- package/packages/core/effects/EffectBudget.ts +695 -0
- package/packages/core/effects/EffectDirector.ts +254 -0
- package/packages/core/effects/EffectPresets.ts +843 -0
- package/packages/core/effects/EffectPresets2D.ts +1011 -0
- package/packages/core/effects/EffectSprites.ts +143 -0
- package/packages/core/effects/ParticleEventLink.ts +53 -0
- package/packages/core/effects/README.md +108 -0
- package/packages/core/effects/VfxMaterial.ts +253 -0
- package/packages/core/film/BakeKey.ts +21 -0
- package/packages/core/film/ColorValues.ts +44 -0
- package/packages/core/film/FilmLint.ts +353 -0
- package/packages/core/film/FilmPrefab.ts +82 -0
- package/packages/core/film/FilmReview.ts +84 -0
- package/packages/core/film/FilmScene.ts +3442 -0
- package/packages/core/film/FilmStage.ts +2148 -0
- package/packages/core/film/Flythrough.ts +169 -0
- package/packages/core/film/FlythroughReport.ts +326 -0
- package/packages/core/film/FrameMetrics.ts +167 -0
- package/packages/core/film/LiveLook.ts +242 -0
- package/packages/core/film/LookQuality.ts +94 -0
- package/packages/core/film/Projection.ts +74 -0
- package/packages/core/film/SceneLook.ts +363 -0
- package/packages/core/film/index.ts +12 -0
- package/packages/core/index.ts +48 -0
- package/packages/core/particles/EffectEnvelope.ts +52 -0
- package/packages/core/particles/LayaParticleRenderer.ts +182 -0
- package/packages/core/particles/LayaParticleRenderer3D.ts +218 -0
- package/packages/core/particles/ParticleExtras.ts +163 -0
- package/packages/core/particles/ParticleMesh3D.ts +156 -0
- package/packages/core/particles/ParticleSystem.ts +324 -0
- package/packages/core/particles/ParticleSystem3D.ts +411 -0
- package/packages/core/particles/ParticleTypes.ts +230 -0
- package/packages/core/particles/ParticleTypes3D.ts +115 -0
- package/packages/core/particles/README.md +181 -0
- package/packages/core/particles/RibbonPath3D.ts +234 -0
- package/packages/core/particles/RibbonTrail.ts +145 -0
- package/packages/core/particles/RibbonTrail3D.ts +166 -0
- package/packages/core/particles/index.ts +12 -0
- package/packages/core/prefabs/PrefabLibrary.ts +692 -0
- package/packages/core/prefabs/PrefabTree3D.ts +291 -0
- package/packages/core/prefabs/index.ts +10 -0
- package/packages/core/procedural/Geometry.ts +1871 -0
- package/packages/core/procedural/Hand.ts +1510 -0
- package/packages/core/procedural/Isosurface.ts +1035 -0
- package/packages/core/procedural/ModuleHarness.ts +180 -0
- package/packages/core/procedural/Noise.ts +123 -0
- package/packages/core/procedural/PhotoMaterial.ts +283 -0
- package/packages/core/procedural/ProceduralAssetProvider.ts +105 -0
- package/packages/core/procedural/ProceduralMaterial.ts +184 -0
- package/packages/core/procedural/PropFactory.ts +307 -0
- package/packages/core/procedural/Random.ts +70 -0
- package/packages/core/procedural/SynthAudio.ts +221 -0
- package/packages/core/procedural/TerrainMesh.ts +207 -0
- package/packages/core/procedural/TextureRecipe.ts +464 -0
- package/packages/core/procedural/TriplanarMaterial.ts +169 -0
- package/packages/core/procedural/Variation.ts +94 -0
- package/packages/core/procedural/index.ts +15 -0
- package/packages/core/runtime3d/ActionFrames.ts +245 -0
- package/packages/core/runtime3d/AnimationBlend.ts +282 -0
- package/packages/core/runtime3d/AnimationBlendMath.ts +98 -0
- package/packages/core/runtime3d/AssetProvider.ts +775 -0
- package/packages/core/runtime3d/AssetShowcase.ts +190 -0
- package/packages/core/runtime3d/Assets.ts +801 -0
- package/packages/core/runtime3d/AsyncDeadline.ts +53 -0
- package/packages/core/runtime3d/AsyncOperation.ts +39 -0
- package/packages/core/runtime3d/BackendChoice.ts +359 -0
- package/packages/core/runtime3d/BakedCrowd.ts +575 -0
- package/packages/core/runtime3d/BasisTexture.ts +657 -0
- package/packages/core/runtime3d/CameraCollision.ts +69 -0
- package/packages/core/runtime3d/CameraEffects.ts +752 -0
- package/packages/core/runtime3d/CameraRig.ts +70 -0
- package/packages/core/runtime3d/CharacterController.ts +272 -0
- package/packages/core/runtime3d/CinematicCapture.ts +457 -0
- package/packages/core/runtime3d/Clocks.ts +724 -0
- package/packages/core/runtime3d/Cloth.ts +183 -0
- package/packages/core/runtime3d/Clouds.ts +462 -0
- package/packages/core/runtime3d/ColorLut.ts +351 -0
- package/packages/core/runtime3d/CombatQueries.ts +240 -0
- package/packages/core/runtime3d/ComputePass.ts +582 -0
- package/packages/core/runtime3d/CrowdPresentation.ts +368 -0
- package/packages/core/runtime3d/DebugDraw.ts +567 -0
- package/packages/core/runtime3d/DebugStats.ts +35 -0
- package/packages/core/runtime3d/Decals.ts +309 -0
- package/packages/core/runtime3d/DensityVolume.ts +238 -0
- package/packages/core/runtime3d/DistanceBricks.ts +349 -0
- package/packages/core/runtime3d/Dither.ts +199 -0
- package/packages/core/runtime3d/DrawWarmUp.ts +217 -0
- package/packages/core/runtime3d/EdgeSmoothing.ts +108 -0
- package/packages/core/runtime3d/EnvironmentProbe.ts +656 -0
- package/packages/core/runtime3d/Filmic.ts +973 -0
- package/packages/core/runtime3d/Foliage.ts +367 -0
- package/packages/core/runtime3d/GltfIntake.ts +914 -0
- package/packages/core/runtime3d/GltfSecondUv.ts +153 -0
- package/packages/core/runtime3d/GraphicsGuard.ts +171 -0
- package/packages/core/runtime3d/Grass.ts +1080 -0
- package/packages/core/runtime3d/GroundTruthAO.ts +360 -0
- package/packages/core/runtime3d/HalfFloat.ts +44 -0
- package/packages/core/runtime3d/HdrEnvironment.ts +588 -0
- package/packages/core/runtime3d/Ik.ts +392 -0
- package/packages/core/runtime3d/InputBuffer.ts +165 -0
- package/packages/core/runtime3d/InstancedMesh.ts +460 -0
- package/packages/core/runtime3d/Laya342Adapters.ts +1095 -0
- package/packages/core/runtime3d/Laya342GltfAdapter.ts +751 -0
- package/packages/core/runtime3d/LensFinish.ts +153 -0
- package/packages/core/runtime3d/LensFlare.ts +490 -0
- package/packages/core/runtime3d/LightFog.ts +1008 -0
- package/packages/core/runtime3d/LightingDepth.ts +544 -0
- package/packages/core/runtime3d/Lightmap.ts +238 -0
- package/packages/core/runtime3d/Math3D.ts +84 -0
- package/packages/core/runtime3d/MeshQuery.ts +547 -0
- package/packages/core/runtime3d/MeshoptModelDecoder.ts +354 -0
- package/packages/core/runtime3d/MiniGameSplash.ts +70 -0
- package/packages/core/runtime3d/ModelAnimationSampler.ts +97 -0
- package/packages/core/runtime3d/ModelCompatibility.ts +890 -0
- package/packages/core/runtime3d/ModelDecoder.ts +294 -0
- package/packages/core/runtime3d/ModelInspector.ts +226 -0
- package/packages/core/runtime3d/ModelLod.ts +163 -0
- package/packages/core/runtime3d/ModelPlacements.ts +426 -0
- package/packages/core/runtime3d/ObjectMotion.ts +217 -0
- package/packages/core/runtime3d/PhysicalCamera.ts +190 -0
- package/packages/core/runtime3d/PointShadow.ts +500 -0
- package/packages/core/runtime3d/PointShadowSchedule.ts +201 -0
- package/packages/core/runtime3d/Pool.ts +120 -0
- package/packages/core/runtime3d/ProbeVolume.ts +695 -0
- package/packages/core/runtime3d/QualityGovernor.ts +385 -0
- package/packages/core/runtime3d/QualityMemory.ts +200 -0
- package/packages/core/runtime3d/RenderScale.ts +356 -0
- package/packages/core/runtime3d/RenderSpaces.ts +105 -0
- package/packages/core/runtime3d/Renderer.ts +377 -0
- package/packages/core/runtime3d/ResultPlayback.ts +239 -0
- package/packages/core/runtime3d/Runtime.ts +507 -0
- package/packages/core/runtime3d/RuntimeDriver.ts +127 -0
- package/packages/core/runtime3d/SceneLifecycle.ts +211 -0
- package/packages/core/runtime3d/SceneMutation.ts +107 -0
- package/packages/core/runtime3d/SceneQueries.ts +191 -0
- package/packages/core/runtime3d/ScreenReflections.ts +595 -0
- package/packages/core/runtime3d/SelectionOutline.ts +389 -0
- package/packages/core/runtime3d/ShaderErrors.ts +104 -0
- package/packages/core/runtime3d/ShaderRegistry.ts +34 -0
- package/packages/core/runtime3d/ShaderWarmUp.ts +473 -0
- package/packages/core/runtime3d/ShadowUpdates.ts +287 -0
- package/packages/core/runtime3d/SkinBinding.ts +235 -0
- package/packages/core/runtime3d/Smaa.ts +386 -0
- package/packages/core/runtime3d/SmaaTables.ts +244 -0
- package/packages/core/runtime3d/SpringBones.ts +184 -0
- package/packages/core/runtime3d/SurfaceBuffer.ts +76 -0
- package/packages/core/runtime3d/Surfaces.ts +1105 -0
- package/packages/core/runtime3d/Themes.ts +344 -0
- package/packages/core/runtime3d/Timeline.ts +362 -0
- package/packages/core/runtime3d/ToneCurves.ts +292 -0
- package/packages/core/runtime3d/TransformGizmo.ts +539 -0
- package/packages/core/runtime3d/TriangleMask.ts +250 -0
- package/packages/core/runtime3d/Underwater.ts +778 -0
- package/packages/core/runtime3d/Utf8.ts +87 -0
- package/packages/core/runtime3d/Vrm.ts +773 -0
- package/packages/core/runtime3d/VrmDocument.ts +1830 -0
- package/packages/core/runtime3d/WalkGrid.ts +471 -0
- package/packages/core/runtime3d/WebGPU342Adapters.ts +280 -0
- package/packages/core/runtime3d/index.ts +147 -0
- package/packages/core/shaders/Laya342ShaderTemplates.ts +6 -0
- package/packages/core/shaders/LitSurfaceMaterial.ts +1076 -0
- package/packages/core/shaders/LitSurfaceTemplates.ts +13 -0
- package/packages/core/shaders/ReflectiveSurface.ts +285 -0
- package/packages/core/shaders/ShaderMaterials.ts +387 -0
- package/packages/core/shaders/ToonMaterial.ts +559 -0
- package/packages/core/shaders/WaterRipples.ts +170 -0
- package/packages/core/shaders/WaterSurface.ts +480 -0
- package/packages/core/shaders/ZhudaCommon.ts +109 -0
- package/packages/core/shaders/index.ts +6 -0
- package/packages/core/simulation/Cloth.ts +1541 -0
- package/packages/core/simulation/ParticleCore.ts +498 -0
- package/packages/core/simulation/SpringBones.ts +553 -0
- package/packages/core/simulation/index.ts +3 -0
- package/packages/core/terrain/Heightfield.ts +385 -0
- package/packages/core/terrain/Terrain2D.ts +324 -0
- package/packages/core/terrain/Terrain3D.ts +452 -0
- package/packages/core/terrain/TerrainShell.ts +94 -0
- package/packages/core/terrain/index.ts +3 -0
- package/packages/demo/BenchmarkEngine.ts +184 -0
- package/packages/demo/PixelCalibrationEngine.ts +36 -0
- package/packages/demo/ProceduralStarter.ts +312 -0
- package/packages/demo/StaticAssetPipeline.ts +1631 -0
- package/packages/demo/UnityBridgePipeline.ts +485 -0
- package/packages/demo/index.ts +6 -0
- package/packages/mcp-server/arguments.mjs +81 -0
- package/packages/mcp-server/corpus.mjs +627 -0
- package/packages/mcp-server/film-host.mjs +627 -0
- package/packages/mcp-server/film-session.mjs +95 -0
- package/packages/mcp-server/film-tools.mjs +460 -0
- package/packages/mcp-server/index.mjs +931 -0
- package/packages/mcp-server/quality-route.mjs +332 -0
- package/packages/mcp-server/roots.mjs +72 -0
- package/packages/mcp-server/runtime.mjs +81 -0
- package/packages/types/BitmapFontContract.d.ts +19 -0
- package/packages/types/DeclarativeSDK.d.ts +137 -0
- package/packages/types/IframeSoundAdapter.d.ts +173 -0
- package/packages/types/NoSleepAdapter.d.ts +50 -0
- package/packages/types/PixelCalibrationEngine.d.ts +83 -0
- package/packages/types/Prefab.d.ts +11 -0
- package/packages/types/RealmGuards.d.ts +26 -0
- package/packages/types/ResponsiveLayout.d.ts +10 -0
- package/packages/types/RuntimeGuards.d.ts +55 -0
- package/packages/types/SpineCharacter.d.ts +94 -0
- package/packages/types/SpineVisualContract.d.ts +50 -0
- package/packages/types/SplashSignal.d.ts +27 -0
- package/packages/types/TopologyGraph.d.ts +76 -0
- package/packages/types/VideoSurface.d.ts +21 -0
- package/packages/types/ViewportMatrixEngine.d.ts +27 -0
- package/packages/types/VisualFocusContract.d.ts +32 -0
- package/packages/types/VisualMigrationPipeline.d.ts +53 -0
- package/packages/types/WebViewSurface.d.ts +26 -0
- package/packages/types/audio/OfflineMix.d.ts +10 -0
- package/packages/types/audio/Spatial.d.ts +63 -0
- package/packages/types/audio/StreamVoice.d.ts +31 -0
- package/packages/types/browser.d.ts +44 -0
- package/packages/types/csg/Bsp.d.ts +85 -0
- package/packages/types/csg/index.d.ts +81 -0
- package/packages/types/demo/BenchmarkEngine.d.ts +61 -0
- package/packages/types/demo/PixelCalibrationEngine.d.ts +13 -0
- package/packages/types/demo/ProceduralStarter.d.ts +11 -0
- package/packages/types/demo/StaticAssetPipeline.d.ts +87 -0
- package/packages/types/demo/UnityBridgePipeline.d.ts +49 -0
- package/packages/types/demo/index.d.ts +7 -0
- package/packages/types/editor-preview.d.ts +27 -0
- package/packages/types/effects/Effect2D.d.ts +65 -0
- package/packages/types/effects/Effect3D.d.ts +42 -0
- package/packages/types/effects/EffectBudget.d.ts +179 -0
- package/packages/types/effects/EffectDirector.d.ts +68 -0
- package/packages/types/effects/EffectPresets.d.ts +27 -0
- package/packages/types/effects/EffectPresets2D.d.ts +32 -0
- package/packages/types/effects/EffectSprites.d.ts +23 -0
- package/packages/types/effects/ParticleEventLink.d.ts +16 -0
- package/packages/types/effects/VfxMaterial.d.ts +52 -0
- package/packages/types/film/BakeKey.d.ts +9 -0
- package/packages/types/film/ColorValues.d.ts +25 -0
- package/packages/types/film/FilmLint.d.ts +40 -0
- package/packages/types/film/FilmPrefab.d.ts +22 -0
- package/packages/types/film/FilmReview.d.ts +27 -0
- package/packages/types/film/FilmScene.d.ts +1214 -0
- package/packages/types/film/FilmStage.d.ts +237 -0
- package/packages/types/film/Flythrough.d.ts +44 -0
- package/packages/types/film/FlythroughReport.d.ts +132 -0
- package/packages/types/film/FrameMetrics.d.ts +49 -0
- package/packages/types/film/LiveLook.d.ts +60 -0
- package/packages/types/film/LookQuality.d.ts +24 -0
- package/packages/types/film/Projection.d.ts +20 -0
- package/packages/types/film/SceneLook.d.ts +122 -0
- package/packages/types/film/index.d.ts +13 -0
- package/packages/types/index.d.ts +49 -0
- package/packages/types/particles/EffectEnvelope.d.ts +18 -0
- package/packages/types/particles/LayaParticleRenderer.d.ts +30 -0
- package/packages/types/particles/LayaParticleRenderer3D.d.ts +29 -0
- package/packages/types/particles/ParticleExtras.d.ts +50 -0
- package/packages/types/particles/ParticleMesh3D.d.ts +24 -0
- package/packages/types/particles/ParticleSystem.d.ts +52 -0
- package/packages/types/particles/ParticleSystem3D.d.ts +69 -0
- package/packages/types/particles/ParticleTypes.d.ts +89 -0
- package/packages/types/particles/ParticleTypes3D.d.ts +56 -0
- package/packages/types/particles/RibbonPath3D.d.ts +32 -0
- package/packages/types/particles/RibbonTrail.d.ts +38 -0
- package/packages/types/particles/RibbonTrail3D.d.ts +22 -0
- package/packages/types/particles/index.d.ts +13 -0
- package/packages/types/prefabs/PrefabLibrary.d.ts +176 -0
- package/packages/types/prefabs/PrefabTree3D.d.ts +59 -0
- package/packages/types/prefabs/index.d.ts +4 -0
- package/packages/types/procedural/Geometry.d.ts +252 -0
- package/packages/types/procedural/Hand.d.ts +150 -0
- package/packages/types/procedural/Isosurface.d.ts +181 -0
- package/packages/types/procedural/ModuleHarness.d.ts +90 -0
- package/packages/types/procedural/Noise.d.ts +15 -0
- package/packages/types/procedural/PhotoMaterial.d.ts +49 -0
- package/packages/types/procedural/ProceduralAssetProvider.d.ts +31 -0
- package/packages/types/procedural/ProceduralMaterial.d.ts +63 -0
- package/packages/types/procedural/PropFactory.d.ts +94 -0
- package/packages/types/procedural/Random.d.ts +26 -0
- package/packages/types/procedural/SynthAudio.d.ts +49 -0
- package/packages/types/procedural/TerrainMesh.d.ts +55 -0
- package/packages/types/procedural/TextureRecipe.d.ts +125 -0
- package/packages/types/procedural/TriplanarMaterial.d.ts +27 -0
- package/packages/types/procedural/Variation.d.ts +23 -0
- package/packages/types/procedural/index.d.ts +16 -0
- package/packages/types/runtime3d/ActionFrames.d.ts +62 -0
- package/packages/types/runtime3d/AnimationBlend.d.ts +57 -0
- package/packages/types/runtime3d/AnimationBlendMath.d.ts +27 -0
- package/packages/types/runtime3d/AssetProvider.d.ts +167 -0
- package/packages/types/runtime3d/AssetShowcase.d.ts +44 -0
- package/packages/types/runtime3d/Assets.d.ts +166 -0
- package/packages/types/runtime3d/AsyncDeadline.d.ts +6 -0
- package/packages/types/runtime3d/AsyncOperation.d.ts +3 -0
- package/packages/types/runtime3d/BackendChoice.d.ts +130 -0
- package/packages/types/runtime3d/BakedCrowd.d.ts +156 -0
- package/packages/types/runtime3d/BasisTexture.d.ts +169 -0
- package/packages/types/runtime3d/CameraCollision.d.ts +20 -0
- package/packages/types/runtime3d/CameraEffects.d.ts +134 -0
- package/packages/types/runtime3d/CameraRig.d.ts +27 -0
- package/packages/types/runtime3d/CharacterController.d.ts +71 -0
- package/packages/types/runtime3d/CinematicCapture.d.ts +103 -0
- package/packages/types/runtime3d/Clocks.d.ts +200 -0
- package/packages/types/runtime3d/Cloth.d.ts +57 -0
- package/packages/types/runtime3d/Clouds.d.ts +69 -0
- package/packages/types/runtime3d/ColorLut.d.ts +73 -0
- package/packages/types/runtime3d/CombatQueries.d.ts +50 -0
- package/packages/types/runtime3d/ComputePass.d.ts +134 -0
- package/packages/types/runtime3d/CrowdPresentation.d.ts +104 -0
- package/packages/types/runtime3d/DebugDraw.d.ts +161 -0
- package/packages/types/runtime3d/DebugStats.d.ts +24 -0
- package/packages/types/runtime3d/Decals.d.ts +65 -0
- package/packages/types/runtime3d/DensityVolume.d.ts +39 -0
- package/packages/types/runtime3d/DistanceBricks.d.ts +97 -0
- package/packages/types/runtime3d/Dither.d.ts +78 -0
- package/packages/types/runtime3d/DrawWarmUp.d.ts +93 -0
- package/packages/types/runtime3d/EdgeSmoothing.d.ts +10 -0
- package/packages/types/runtime3d/EnvironmentProbe.d.ts +139 -0
- package/packages/types/runtime3d/Filmic.d.ts +243 -0
- package/packages/types/runtime3d/Foliage.d.ts +95 -0
- package/packages/types/runtime3d/GltfIntake.d.ts +236 -0
- package/packages/types/runtime3d/GltfSecondUv.d.ts +54 -0
- package/packages/types/runtime3d/GraphicsGuard.d.ts +18 -0
- package/packages/types/runtime3d/Grass.d.ts +226 -0
- package/packages/types/runtime3d/GroundTruthAO.d.ts +64 -0
- package/packages/types/runtime3d/HalfFloat.d.ts +13 -0
- package/packages/types/runtime3d/HdrEnvironment.d.ts +144 -0
- package/packages/types/runtime3d/Ik.d.ts +123 -0
- package/packages/types/runtime3d/InputBuffer.d.ts +49 -0
- package/packages/types/runtime3d/InstancedMesh.d.ts +116 -0
- package/packages/types/runtime3d/Laya342Adapters.d.ts +306 -0
- package/packages/types/runtime3d/Laya342GltfAdapter.d.ts +105 -0
- package/packages/types/runtime3d/LensFinish.d.ts +38 -0
- package/packages/types/runtime3d/LensFlare.d.ts +114 -0
- package/packages/types/runtime3d/LightFog.d.ts +190 -0
- package/packages/types/runtime3d/LightingDepth.d.ts +128 -0
- package/packages/types/runtime3d/Lightmap.d.ts +55 -0
- package/packages/types/runtime3d/Math3D.d.ts +19 -0
- package/packages/types/runtime3d/MeshQuery.d.ts +107 -0
- package/packages/types/runtime3d/MeshoptModelDecoder.d.ts +34 -0
- package/packages/types/runtime3d/MiniGameSplash.d.ts +4 -0
- package/packages/types/runtime3d/ModelAnimationSampler.d.ts +26 -0
- package/packages/types/runtime3d/ModelCompatibility.d.ts +169 -0
- package/packages/types/runtime3d/ModelDecoder.d.ts +66 -0
- package/packages/types/runtime3d/ModelInspector.d.ts +77 -0
- package/packages/types/runtime3d/ModelLod.d.ts +61 -0
- package/packages/types/runtime3d/ModelPlacements.d.ts +77 -0
- package/packages/types/runtime3d/ObjectMotion.d.ts +43 -0
- package/packages/types/runtime3d/PhysicalCamera.d.ts +51 -0
- package/packages/types/runtime3d/PointShadow.d.ts +71 -0
- package/packages/types/runtime3d/PointShadowSchedule.d.ts +74 -0
- package/packages/types/runtime3d/Pool.d.ts +33 -0
- package/packages/types/runtime3d/ProbeVolume.d.ts +123 -0
- package/packages/types/runtime3d/QualityGovernor.d.ts +201 -0
- package/packages/types/runtime3d/QualityMemory.d.ts +83 -0
- package/packages/types/runtime3d/RenderScale.d.ts +69 -0
- package/packages/types/runtime3d/RenderSpaces.d.ts +44 -0
- package/packages/types/runtime3d/Renderer.d.ts +62 -0
- package/packages/types/runtime3d/ResultPlayback.d.ts +70 -0
- package/packages/types/runtime3d/Runtime.d.ts +136 -0
- package/packages/types/runtime3d/RuntimeDriver.d.ts +42 -0
- package/packages/types/runtime3d/SceneLifecycle.d.ts +84 -0
- package/packages/types/runtime3d/SceneMutation.d.ts +34 -0
- package/packages/types/runtime3d/SceneQueries.d.ts +71 -0
- package/packages/types/runtime3d/ScreenReflections.d.ts +78 -0
- package/packages/types/runtime3d/SelectionOutline.d.ts +68 -0
- package/packages/types/runtime3d/ShaderErrors.d.ts +27 -0
- package/packages/types/runtime3d/ShaderRegistry.d.ts +10 -0
- package/packages/types/runtime3d/ShaderWarmUp.d.ts +162 -0
- package/packages/types/runtime3d/ShadowUpdates.d.ts +125 -0
- package/packages/types/runtime3d/SkinBinding.d.ts +53 -0
- package/packages/types/runtime3d/Smaa.d.ts +60 -0
- package/packages/types/runtime3d/SmaaTables.d.ts +12 -0
- package/packages/types/runtime3d/SpringBones.d.ts +69 -0
- package/packages/types/runtime3d/SurfaceBuffer.d.ts +28 -0
- package/packages/types/runtime3d/Surfaces.d.ts +326 -0
- package/packages/types/runtime3d/Themes.d.ts +70 -0
- package/packages/types/runtime3d/Timeline.d.ts +88 -0
- package/packages/types/runtime3d/ToneCurves.d.ts +59 -0
- package/packages/types/runtime3d/TransformGizmo.d.ts +139 -0
- package/packages/types/runtime3d/TriangleMask.d.ts +84 -0
- package/packages/types/runtime3d/Underwater.d.ts +120 -0
- package/packages/types/runtime3d/Utf8.d.ts +12 -0
- package/packages/types/runtime3d/Vrm.d.ts +120 -0
- package/packages/types/runtime3d/VrmDocument.d.ts +381 -0
- package/packages/types/runtime3d/WalkGrid.d.ts +94 -0
- package/packages/types/runtime3d/WebGPU342Adapters.d.ts +27 -0
- package/packages/types/runtime3d/index.d.ts +102 -0
- package/packages/types/shaders/Laya342ShaderTemplates.d.ts +3 -0
- package/packages/types/shaders/LitSurfaceMaterial.d.ts +257 -0
- package/packages/types/shaders/LitSurfaceTemplates.d.ts +7 -0
- package/packages/types/shaders/ReflectiveSurface.d.ts +58 -0
- package/packages/types/shaders/ShaderMaterials.d.ts +60 -0
- package/packages/types/shaders/ToonMaterial.d.ts +176 -0
- package/packages/types/shaders/WaterRipples.d.ts +48 -0
- package/packages/types/shaders/WaterSurface.d.ts +110 -0
- package/packages/types/shaders/ZhudaCommon.d.ts +31 -0
- package/packages/types/shaders/index.d.ts +7 -0
- package/packages/types/simulation/Cloth.d.ts +381 -0
- package/packages/types/simulation/ParticleCore.d.ts +125 -0
- package/packages/types/simulation/SpringBones.d.ts +107 -0
- package/packages/types/simulation/index.d.ts +4 -0
- package/packages/types/terrain/Heightfield.d.ts +67 -0
- package/packages/types/terrain/Terrain2D.d.ts +81 -0
- package/packages/types/terrain/Terrain3D.d.ts +80 -0
- package/packages/types/terrain/TerrainShell.d.ts +8 -0
- package/packages/types/terrain/index.d.ts +4 -0
- package/packages/types/vendor/LayaAir.runtime.d.ts +97440 -0
- package/packages/types/vendor/REPAIRS.md +30 -0
- package/packages/types/vendor/restored-3.4.2.json +142 -0
- package/packages/types/vendor/spine.runtime.d.ts +1507 -0
- package/packages/types/vendor/wechat-media.d.ts +877 -0
- package/packages/types/zhuda-2d-ui.d.ts +244 -0
- package/packages/types/zhuda-3d-physics.d.ts +34 -0
- package/packages/types/zhuda-audio.d.ts +128 -0
- package/packages/types/zhuda-bootstrap.d.ts +100 -0
- package/packages/types/zhuda-branding.d.ts +6 -0
- package/packages/types/zhuda-core.d.ts +46 -0
- package/packages/types/zhuda-declarative.d.ts +81 -0
- package/packages/types/zhuda-effects.d.ts +302 -0
- package/packages/types/zhuda-layout.d.ts +96 -0
- package/packages/types/zhuda-particles.d.ts +477 -0
- package/packages/types/zhuda-spine42.d.ts +23 -0
- package/packages/types/zhuda-static-assets.d.ts +389 -0
- package/packages/types/zhuda-video.d.ts +24 -0
- package/packages/types/zhuda-visual-contract.d.ts +52 -0
- package/packages/types/zhuda-webview.d.ts +43 -0
- package/vendor/basis/LICENSE.txt +55 -0
- package/vendor/basis/README.md +25 -0
- package/vendor/basis/basis_transcoder.js +19 -0
- package/vendor/basis/basis_transcoder.wasm +0 -0
- package/vendor/laya-3.4.2/WEBGPU-LICENSES.txt +1259 -0
- package/vendor/laya-3.4.2/libs/laya.ani.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.box2D.js +1209 -0
- package/vendor/laya-3.4.2/libs/laya.bridge.js +2273 -0
- package/vendor/laya-3.4.2/libs/laya.bullet.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.core.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.d3.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.device.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.gltf.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.ik.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.light2D.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.line2D.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.native-spine42.js +7672 -0
- package/vendor/laya-3.4.2/libs/laya.navMesh2d.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.navMesh3d.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.navMeshCommon.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.particle.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.particle3D.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.particleCommon.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.physics2D.js +3774 -0
- package/vendor/laya-3.4.2/libs/laya.physics3D.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.postProcess.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.spine.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.spine3D.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.tilemap.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.trail2D.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.trail3D.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.trailCommon.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.ui.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.ui2.js +9904 -0
- package/vendor/laya-3.4.2/libs/laya.vfx.js +6754 -0
- package/vendor/laya-3.4.2/libs/laya.webgl_2D.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.webgl_3D.js +1 -0
- package/vendor/laya-3.4.2/libs/laya.webgpu_2D.js +18576 -0
- package/vendor/laya-3.4.2/libs/laya.webgpu_3D.js +6729 -0
- package/vendor/laya-3.4.2/libs/nagabind.js +395 -0
- package/vendor/laya-3.4.2/libs/nagabind_bg.wasm +0 -0
- package/vendor/laya-3.4.2/libs/shader_compiler_web.js +22 -0
- package/vendor/laya-3.4.2/libs/shader_compiler_web.wasm +0 -0
- package/vendor/laya-3.4.2/libs/spine-core-3.8.js +1 -0
- package/vendor/laya-3.4.2/libs/spine-core-4.2.js +10216 -0
- package/vendor/laya-3.4.2/webgpu-provenance.json +41 -0
- package/vendor/meshoptimizer/LICENSE.txt +21 -0
- package/vendor/meshoptimizer/README.md +13 -0
- package/vendor/threejs-post/LICENSE.txt +53 -0
- package/vendor/threejs-post/README.md +54 -0
- package/zhuda.config.json +22 -0
|
@@ -0,0 +1,1504 @@
|
|
|
1
|
+
# Film scenes for agents
|
|
2
|
+
|
|
3
|
+
An agent builds a film scene as data, changes it under revision checks, looks
|
|
4
|
+
at the result and renders final stills or MP4, without writing engine code.
|
|
5
|
+
The workflow follows the agent loop of
|
|
6
|
+
[67js](https://github.com/codepawl/67.js) (MIT); the implementation is our
|
|
7
|
+
own, on the Laya-backed renderer and the existing
|
|
8
|
+
[cinematic capture](cinematics.md). No 67js source is included.
|
|
9
|
+
|
|
10
|
+
Every image, from a one-sample preview to a final 4K frame, goes through
|
|
11
|
+
`ZhudaCinematicCapture` with a physical lens, so what the agent previews is
|
|
12
|
+
what the job renders, only with fewer samples.
|
|
13
|
+
|
|
14
|
+
Everything is drawn by Laya 3.4.2: the scene through `Laya.Scene3D` and an
|
|
15
|
+
offscreen `RenderTexture`, the review sheet through `Laya.Sprite`,
|
|
16
|
+
`Laya.Text` and `drawToRenderTexture2D`. The page returns raw pixels and the
|
|
17
|
+
Node side encodes PNG; no DOM canvas, second renderer or extra
|
|
18
|
+
`AudioContext` is involved. A review cell is pixel-identical to a single
|
|
19
|
+
preview of the same camera (checked by `verify:film`).
|
|
20
|
+
|
|
21
|
+
## Start the MCP server
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
npx zhuda-laya-mcp --film-output ./films
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Film scenes are drawn with WebGL by default. `--film-renderer webgpu` (or
|
|
28
|
+
`ZHUDA_FILM_RENDERER=webgpu`) draws them with Laya's WebGPU backend instead:
|
|
29
|
+
the same scenes, tools and capture path, on the `3d-gltf-webgpu` bundle. It
|
|
30
|
+
needs a hardware WebGPU adapter and fails rather than falling back; a shader
|
|
31
|
+
or pipeline the device rejects fails the call with the device's message.
|
|
32
|
+
Pixels differ slightly between the backends, so compare images within one.
|
|
33
|
+
`npm run verify:film-webgpu` runs every film verification on WebGPU.
|
|
34
|
+
|
|
35
|
+
The server needs a local Chrome (set `CHROME_BIN` if it is not in the usual
|
|
36
|
+
place) and, for MP4, `ffmpeg` and `ffprobe`. The browser starts on the first
|
|
37
|
+
image request and closes with the server. Render jobs write only into the
|
|
38
|
+
`--film-output` directory and never overwrite a file.
|
|
39
|
+
|
|
40
|
+
## The loop
|
|
41
|
+
|
|
42
|
+
1. `film_scene_create` with a scene. The reply lists the props and recipes the
|
|
43
|
+
host can build, and `advice`: what in this valid scene will not look its
|
|
44
|
+
best, each with the change that fixes it.
|
|
45
|
+
2. `film_scene_preview` returns a PNG of the current revision and its
|
|
46
|
+
`metrics`: the frame in numbers, with `flags` for one that lost its detail.
|
|
47
|
+
3. `film_scene_apply` with `expectedRevision` and a patch. Add `preview: true`
|
|
48
|
+
to get the new image in the same call. A stale revision or an invalid change
|
|
49
|
+
is refused and the scene stays as it was.
|
|
50
|
+
4. `film_scene_review` puts one to four labelled shots of one revision into a
|
|
51
|
+
single PNG, for example wide, side, low and top.
|
|
52
|
+
5. `film_render_job` with `kind: "still"` (anti-aliasing and depth of field,
|
|
53
|
+
16 samples by default) or `kind: "video"` along a camera path.
|
|
54
|
+
|
|
55
|
+
`film_scene_query` asks the scene where its surfaces are, so a camera, a lamp
|
|
56
|
+
or a tuft is put on the ground and not inside it. `heights: [[x, z], ...]`
|
|
57
|
+
gives the height of the topmost surface at each place; `rays: [{origin,
|
|
58
|
+
direction, maxMeters}]` the nearest surface along each. An answer names the
|
|
59
|
+
node met, the distance, the point and the surface normal (toward the ray), or
|
|
60
|
+
is null. Props, boxes, lathes, extrusions, sweeps and ground are asked;
|
|
61
|
+
models, water, mirrors, grass and decals are not. Up to 2000 questions a
|
|
62
|
+
call, and no picture is drawn. In a program the same question is
|
|
63
|
+
`stage.raycast(origin, direction, maxMeters)`.
|
|
64
|
+
|
|
65
|
+
The other way round, for a marker, a label or a bar the page draws over the
|
|
66
|
+
scene (DOM or 2D): `stage.worldToScreen(point, { width, height })` gives the
|
|
67
|
+
pixels of a world point in a picture of that size for the camera last set,
|
|
68
|
+
its depth, and whether it is inside the picture; null behind the camera.
|
|
69
|
+
Give the size in CSS pixels for a place in CSS pixels. The arithmetic alone
|
|
70
|
+
is `projectZhudaFilmPoint(camera, point, aspect)`, which needs no stage. The
|
|
71
|
+
world is right-handed: a camera looking along +Z has +X on the left of its
|
|
72
|
+
picture, which a projection written by hand gets wrong first.
|
|
73
|
+
|
|
74
|
+
Draws and triangles a frame are counted two ways, and they differ.
|
|
75
|
+
`ZhudaFilmHost.flythrough` draws each frame through the capture path (one
|
|
76
|
+
view of the film camera into a picture); a page that runs the stage in the
|
|
77
|
+
engine's loop and counts with `ZhudaRuntimeProfiler` counts what the loop
|
|
78
|
+
draws to the screen. Measured on one outside scene at 640 by 360 with a still
|
|
79
|
+
camera: 166 draws and 1,720,324 triangles through the capture path against
|
|
80
|
+
183 and 1,861,756 in its page. Of the difference two draws come with the size
|
|
81
|
+
(164 at 320 by 180: bloom has a level more) and none with camera movement;
|
|
82
|
+
what the other 17 draws and 141,000 triangles are was not traced. For a
|
|
83
|
+
phone's budget count in the page, in the loop the game runs.
|
|
84
|
+
|
|
85
|
+
`film_scene_get` reads the scene and its revision; `film_scene_lint` returns
|
|
86
|
+
the advice for a session or for a scene without drawing it; `film_scene_close`
|
|
87
|
+
discards the session. The [quality route](quality-route.md) is the order in
|
|
88
|
+
which to build a scene that looks good, and explains every advice rule and
|
|
89
|
+
metrics flag. Sessions hold data only and are dropped least recently used first
|
|
90
|
+
when more than 16 are open.
|
|
91
|
+
|
|
92
|
+
## Scene format
|
|
93
|
+
|
|
94
|
+
```json
|
|
95
|
+
{
|
|
96
|
+
"schemaVersion": 1,
|
|
97
|
+
"id": "container-yard",
|
|
98
|
+
"camera": { "eye": [11, 5.5, 14], "target": [0, 1.4, 0], "focalLengthMm": 35, "fStop": 4 },
|
|
99
|
+
"look": {
|
|
100
|
+
"sky": [0.55, 0.65, 0.78],
|
|
101
|
+
"ambient": [0.3, 0.3, 0.32],
|
|
102
|
+
"sun": { "azimuthDeg": -50, "elevationDeg": 35, "intensity": 1.3 }
|
|
103
|
+
},
|
|
104
|
+
"materials": {
|
|
105
|
+
"red-paint": { "recipe": "painted-steel", "tint": [0.75, 0.25, 0.2, 1] },
|
|
106
|
+
"plaster": { "color": [0.8, 0.78, 0.72], "roughness": 0.9 }
|
|
107
|
+
},
|
|
108
|
+
"nodes": [
|
|
109
|
+
{ "id": "ground", "type": "ground", "size": [80, 80], "material": "asphalt" },
|
|
110
|
+
{ "id": "c1", "type": "prop", "prop": "container20", "position": [0, 0, 0], "seed": 1 },
|
|
111
|
+
{
|
|
112
|
+
"id": "c2",
|
|
113
|
+
"type": "prop",
|
|
114
|
+
"prop": "container20",
|
|
115
|
+
"position": [0, 0, 3.2],
|
|
116
|
+
"yawDeg": 180,
|
|
117
|
+
"params": { "paint": "red-paint" }
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"id": "wall",
|
|
121
|
+
"type": "box",
|
|
122
|
+
"size": [6, 2.4, 0.3],
|
|
123
|
+
"position": [0, 0, -6],
|
|
124
|
+
"material": "plaster"
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
- Units are metres and degrees; Y is up and the ground top is at y = 0.
|
|
131
|
+
- `camera`: `eye` and `target`; `focalLengthMm` (default 35, full-frame
|
|
132
|
+
equivalent), `fStop` (default 8) and `focusDistanceM` (default: the
|
|
133
|
+
eye-target distance) drive depth of field in final renders. As with a
|
|
134
|
+
real lens, a long focal length close to its subject keeps only a thin
|
|
135
|
+
slice sharp: 85 mm at f/2 focused at 1.4 m holds about three centimetres
|
|
136
|
+
(by the usual 0.03 mm circle on a full frame), so a whole figure comes
|
|
137
|
+
out soft. Stop down or step back for more.
|
|
138
|
+
- `look`: colours are RGB 0..1 (see [colour values](#colour-values)). The sun
|
|
139
|
+
turns about +Y by `azimuthDeg` (at 0 it travels toward -Z) and rises by
|
|
140
|
+
`elevationDeg`.
|
|
141
|
+
- `materials`: a baked [texture recipe](procedural-assets.md) by name or
|
|
142
|
+
inline, with optional `tint` and bake `size` (128 to 2048, default 256; a
|
|
143
|
+
two-metre tile needs 512 to reach 256 pixels per metre), or a flat PBR
|
|
144
|
+
`color`. A node may also name a host recipe directly
|
|
145
|
+
(`"material": "asphalt"`), which bakes at 256. `"variation": 0.5` on a
|
|
146
|
+
recipe material lays slow changes of brightness over the surface, so that
|
|
147
|
+
a large floor does not show its tiles as a grid. The changes come from a
|
|
148
|
+
picture that repeats about every 27 m (13.7 tiles); from high above a very
|
|
149
|
+
large floor that repeat can itself be made out, more so above 0.5.
|
|
150
|
+
- `nodes`: `prop` places a registered procedural prop (its `params` and `seed`
|
|
151
|
+
as in the prop factory); `box` is a box resting on `position`; `ground` is a
|
|
152
|
+
plane at y = 0, or at its `y`: over the level part of a `terrain`, lift it a
|
|
153
|
+
few centimetres (`"y": 0.02`) so the two do not share a height. Ids are unique; unknown fields are rejected.
|
|
154
|
+
|
|
155
|
+
Props are merged into one mesh per material, so a yard of containers costs a
|
|
156
|
+
handful of draws.
|
|
157
|
+
|
|
158
|
+
A material says how it is put into the picture with `blend` (default
|
|
159
|
+
`"opaque"`), on a recipe or a flat colour alike:
|
|
160
|
+
|
|
161
|
+
```json
|
|
162
|
+
"leaf": { "recipe": { "schemaVersion": 1, "id": "leaf", "tileMeters": [0.3, 0.5],
|
|
163
|
+
"base": { "color": [0.1, 0.3, 0.06], "roughness": 0.6, "metallic": 0, "alpha": 0 },
|
|
164
|
+
"layers": [{ "mask": { "type": "shape", "shape": "leaf" }, "alpha": 1 }] },
|
|
165
|
+
"blend": "cutout", "doubleSided": true },
|
|
166
|
+
"mist": { "color": [0.8, 0.85, 0.9], "roughness": 1, "blend": "alpha", "opacity": 0.3 }
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
- `"cutout"`: drawn where the alpha is above `alphaCutoff` (default 0.5)
|
|
170
|
+
and nowhere else, with depth and with a shadow of the same outline. A
|
|
171
|
+
recipe's alpha is its `base.alpha` and its layers' `alpha`; the `shape`
|
|
172
|
+
mask (`disc`, `leaf`, `blade`, `petal`) is one outline filling the tile, so
|
|
173
|
+
the card it is on spans one tile (`tileMeters`), from the mesh's UV origin.
|
|
174
|
+
- `"alpha"` blends over what is behind and `"additive"` adds its light; a
|
|
175
|
+
flat colour's `opacity` is how solid it is. Blended surfaces write no depth
|
|
176
|
+
and are drawn after the solid ones, sorted by their mesh, not by their
|
|
177
|
+
triangles: a prop merged into one mesh is one thing to the sort.
|
|
178
|
+
- `"doubleSided": true` draws both faces: a leaf or a blade of grass is one
|
|
179
|
+
sheet, not two back to back, and half the triangles. How the far face is
|
|
180
|
+
lit was not looked at.
|
|
181
|
+
|
|
182
|
+
A recipe material may carry fine `detail` for close range:
|
|
183
|
+
|
|
184
|
+
```json
|
|
185
|
+
"rock": { "recipe": "cliff", "size": 1024,
|
|
186
|
+
"detail": { "recipe": "rock-grain", "meters": 1.5, "albedo": 0.5, "normal": 1 } }
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
A recipe that tiles at 40 m is right from the main camera and a blur from a
|
|
190
|
+
metre away (a texel is centimetres wide). The detail is a second recipe laid
|
|
191
|
+
over it, repeating every `meters`: its colour moves the surface's about its
|
|
192
|
+
own mean by `albedo` (0..1), so the surface keeps its overall colour, and its
|
|
193
|
+
relief is added at `normal` (0..2). Far away its small mip levels are its
|
|
194
|
+
mean and it changes nothing, so there is no distance to set. It is the
|
|
195
|
+
material's one detail map: `detail` and `variation` cannot both be given.
|
|
196
|
+
|
|
197
|
+
A material may be a picture among the scene's assets (a photographed or
|
|
198
|
+
generated tile) in place of a recipe:
|
|
199
|
+
|
|
200
|
+
```json
|
|
201
|
+
"wall": { "picture": "textures/red-brick/albedo-512.png",
|
|
202
|
+
"normal": "textures/red-brick/normal-512.png",
|
|
203
|
+
"tileMeters": [2, 2], "roughness": 0.85 }
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
The picture is the surface's colour, repeated every `tileMeters` (the width
|
|
207
|
+
and height in metres one repeat covers). `normal` is its normal map, read as
|
|
208
|
+
`"normalConvention": "opengl"` (green up, as glTF and most texture libraries
|
|
209
|
+
write it) unless told `"directx"`; `normalStrength` (0..2) is its relief. A
|
|
210
|
+
picture carries no roughness: `roughness` (default 0.8) and `metallic`
|
|
211
|
+
(default 0) are the whole surface's. `tint`, `blend`, `alphaCutoff` and
|
|
212
|
+
`doubleSided` are as for a recipe; a picture with alpha and `"blend":
|
|
213
|
+
"cutout"` is a leaf or a fence. Pictures are assets: the MCP server needs
|
|
214
|
+
`--film-assets <dir>` and a program `loadZhudaFilmScene` with an assets
|
|
215
|
+
library. Each picture is decoded once and uploaded with mip levels; a 1024
|
|
216
|
+
picture is 5.6 MB on the graphics card, so use the 512 one unless the camera
|
|
217
|
+
comes close. Not with `variation`, `detail` or `projection`: those are a
|
|
218
|
+
recipe's.
|
|
219
|
+
|
|
220
|
+
A recipe material may be laid on by place instead of by the mesh's texture
|
|
221
|
+
coordinates:
|
|
222
|
+
|
|
223
|
+
```json
|
|
224
|
+
"rock": { "recipe": "cliff-stone", "projection": "triplanar",
|
|
225
|
+
"top": { "recipe": "moss", "from": 0.55, "to": 0.8 } }
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
`"projection": "triplanar"` projects the recipe along the three world axes and
|
|
229
|
+
mixes them by which way the surface faces, so a steep slope, a cone or a rock
|
|
230
|
+
shows it at its true size instead of squeezed or stretched, and two meshes
|
|
231
|
+
that meet carry one pattern across the join. `top` lays a second recipe where
|
|
232
|
+
the surface faces up (moss on a stone's top, snow on a ledge, dust on a
|
|
233
|
+
shelf): `from` and `to` are the upward share of the surface normal, 1 level
|
|
234
|
+
and 0 a wall, between which it comes in. It reads each map three times a
|
|
235
|
+
pixel (and the top's once more), so use it where the stretching shows. Not
|
|
236
|
+
with `variation`, `detail`, `blend` or `doubleSided`. In a program:
|
|
237
|
+
`createZhudaTriplanarMaterial(set, { top })`.
|
|
238
|
+
|
|
239
|
+
A `terrain` node is ground with heights:
|
|
240
|
+
|
|
241
|
+
```json
|
|
242
|
+
{ "id": "hills", "type": "terrain", "position": [0, 0, 0],
|
|
243
|
+
"size": [80, 80], "cells": [96, 96], "material": "rock",
|
|
244
|
+
"noise": { "seed": 5, "heightM": 14, "scaleM": 30,
|
|
245
|
+
"flatten": [{ "minX": -6, "maxX": 6, "minZ": -6, "maxZ": 6, "y": 3, "marginM": 6 }] } }
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
A grid of `cells` (1..254 a side) over `size` metres centred on `position`,
|
|
249
|
+
each corner at its own height above `position`'s. `noise` makes fractal hills
|
|
250
|
+
up to `heightM` high and about `scaleM` across, the same for the same `seed`
|
|
251
|
+
(`ridged: true` folds them into ridges), with up to 32 `flatten` rectangles
|
|
252
|
+
pressed level at `y` for a plot or a road, in the piece's own metres, eased in
|
|
253
|
+
over `marginM`. Or give `heights`: `(cells[0] + 1) * (cells[1] + 1)` numbers,
|
|
254
|
+
row by row from -Z, each row from -X. It is drawn, lit and shadowed like a
|
|
255
|
+
box, and `film_scene_query` gives its height anywhere. Its texture
|
|
256
|
+
coordinates are metres seen from above: give it a triplanar material where it
|
|
257
|
+
is steep. One mesh; no caves or overhangs (those are meshes of their own),
|
|
258
|
+
and for ground that is streamed or edited use `ZhudaTerrain3D` in a program.
|
|
259
|
+
|
|
260
|
+
An `effect` node is a ready particle effect:
|
|
261
|
+
|
|
262
|
+
```json
|
|
263
|
+
{ "id": "fire", "type": "effect", "preset": "campfire", "position": [2, 0, -1] },
|
|
264
|
+
{ "id": "blast", "type": "effect", "preset": "explosion", "position": [0, 1, 0],
|
|
265
|
+
"startSec": 2.5, "scale": 1.5 }
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
| Preset | What it is | Runs |
|
|
269
|
+
| --- | --- | --- |
|
|
270
|
+
| `campfire` | Flames, a thread of smoke, a few embers | on |
|
|
271
|
+
| `torch` | A small steady flame | on |
|
|
272
|
+
| `smoke-column` | Grey smoke rising and spreading | on |
|
|
273
|
+
| `steam` | White vapour that rises and is gone | on |
|
|
274
|
+
| `sparks` | A spray of sparks falling under gravity | on |
|
|
275
|
+
| `explosion` | A flash, a ball of fire, debris, smoke left behind | once, 3.5 s |
|
|
276
|
+
| `hit` | A flash, a ring and a few sparks | once, 0.6 s |
|
|
277
|
+
| `magic-aura` | Motes rising round a figure, a ring on the ground | on |
|
|
278
|
+
| `heal` | Green lights and small stars drifting up | on |
|
|
279
|
+
| `portal` | A ball of violet light with motes round it | on |
|
|
280
|
+
| `fireflies` | Slow points of light near the ground | on |
|
|
281
|
+
| `rain` | Rain over a 16 m square from 9 m: place it over the camera | on |
|
|
282
|
+
| `snow` | Snow over a 14 m square from 7 m: place it over the camera | on |
|
|
283
|
+
| `dust-motes` | Fine dust hanging in still air | on |
|
|
284
|
+
| `falling-leaves` | Leaves turning as they fall, over 10 m | on |
|
|
285
|
+
| `petals` | Blossom petals on a light wind, over 10 m | on |
|
|
286
|
+
| `bubbles` | Bubbles rising and wobbling | on |
|
|
287
|
+
| `embers` | Embers lifted on warm air over 8 m | on |
|
|
288
|
+
|
|
289
|
+
`position` is its origin (the foot of a fire, the top of rain), `yawDeg` turns
|
|
290
|
+
it, `scale` (0.05 to 50) multiplies every length, `seed` makes two copies move
|
|
291
|
+
differently. It begins at `startSec` of shot time: before that nothing is
|
|
292
|
+
drawn; one that runs once is over after its time. The effect is stepped at
|
|
293
|
+
120 Hz from its start, so a frame at the same shot time is the same frame
|
|
294
|
+
whichever frames were drawn before it. Particles are drawn unlit over the
|
|
295
|
+
scene: they cast no shadow, take none, and light nothing; put a point light
|
|
296
|
+
in a fire or an explosion. Nothing is loaded: the sprites are made by a
|
|
297
|
+
program (`bakeZhudaEffectSprite`). At most 32 effect nodes a scene; the
|
|
298
|
+
largest preset holds 900 particles (rain). In a game:
|
|
299
|
+
|
|
300
|
+
```ts
|
|
301
|
+
const fire = new ZhudaEffect3D(scene3D, 'campfire', { position: [2, 0, -1] });
|
|
302
|
+
// each frame:
|
|
303
|
+
fire.update(deltaSeconds);
|
|
304
|
+
fire.render(camera);
|
|
305
|
+
// at the end:
|
|
306
|
+
fire.dispose();
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
A preset is data (`ZHUDA_EFFECT_PRESETS_3D[id].effect`, a
|
|
310
|
+
`ParticleEffectSpec3D`): copy one and change it for an effect of your own,
|
|
311
|
+
and pass it in place of the id. The particle system itself is described in
|
|
312
|
+
[particles](../packages/core/particles/README.md).
|
|
313
|
+
|
|
314
|
+
A `grass` node is grass a camera can walk through ([grass](grass.md)), on
|
|
315
|
+
level ground, or on a terrain node with `"on": "hills"` in place of `y`:
|
|
316
|
+
|
|
317
|
+
Grass is the one node that can add hundreds of draws by itself. It is kept
|
|
318
|
+
as meshes for every patch of land within `distanceM` of the eye **over the
|
|
319
|
+
ground**: a camera 40 m above a field is as near to it as one standing in
|
|
320
|
+
it. A 72 by 42 m field with `distanceM` 70 measured 525 draws a frame
|
|
321
|
+
against 45 without it (SwiftShader, 960x540). Advice names it
|
|
322
|
+
(`grass.draws`, above 150 meshes, with a reach that is under it), and
|
|
323
|
+
`zhudaGrassMeshCount(options, eye)` gives the count for any eye. For a
|
|
324
|
+
camera too far to show blades, leave the node out.
|
|
325
|
+
|
|
326
|
+
```json
|
|
327
|
+
{ "id": "meadow", "type": "grass",
|
|
328
|
+
"area": { "minX": -40, "maxX": 40, "minZ": -60, "maxZ": 12 }, "y": 0,
|
|
329
|
+
"clear": [{ "minX": -7, "maxX": -4, "minZ": -60, "maxZ": 12 }],
|
|
330
|
+
"density": 400, "heightM": [0.14, 0.34], "distanceM": 60,
|
|
331
|
+
"tip": [0.46, 0.6, 0.22], "dryness": 0.3, "wind": { "strength": 0.4 } }
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
Blades in clumps over turf, moved by the wind with shot time, lit and shadowed
|
|
335
|
+
like the ground, thinned with distance and gone beyond `distanceM`. Nothing
|
|
336
|
+
grows on a `clear` rectangle, nor under what stands on the ground (the boxes
|
|
337
|
+
of props and of `box`, `lathe`, `extrude` and `sweep` nodes that reach down to
|
|
338
|
+
`y`; `"avoidSolids": false` lets it). It is grown for where the camera is
|
|
339
|
+
whenever the camera is set. With `y` the ground it stands on is level; with `on` it
|
|
340
|
+
follows the terrain node's heights and stops at its edge.
|
|
341
|
+
|
|
342
|
+
A prop node may say how it behaves with distance, like a model node:
|
|
343
|
+
|
|
344
|
+
```json
|
|
345
|
+
{ "id": "crowd", "type": "prop", "prop": "people", "position": [0, 0, -20],
|
|
346
|
+
"castShadow": false,
|
|
347
|
+
"lod": [{ "fromMeters": 15, "params": { "detail": 0.5 } },
|
|
348
|
+
{ "fromMeters": 40, "params": { "detail": 0 } }],
|
|
349
|
+
"cullMeters": 120 }
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
- `castShadow: false`: it casts no shadow and still takes them. For grass,
|
|
353
|
+
petals, pebbles: a prop is drawn again in every split of the shadow map.
|
|
354
|
+
- `lod` (at most four levels, `fromMeters` rising): from that distance the
|
|
355
|
+
prop is built with `params` laid over its own. Every level is built when
|
|
356
|
+
the scene is mounted and one is drawn, chosen by the distance from the
|
|
357
|
+
camera to the node's `position` whenever the camera is set.
|
|
358
|
+
- `cullMeters`: beyond it the prop is not drawn.
|
|
359
|
+
|
|
360
|
+
A prop with `lod` or `cullMeters` is a mesh of its own for each of its
|
|
361
|
+
materials, not part of the merged ones: give them to the few props that are
|
|
362
|
+
worth it.
|
|
363
|
+
|
|
364
|
+
A patch has `camera` and `look` (merged), `materials` (a `null` value removes
|
|
365
|
+
one), `remove` (node ids, applied first) and `upsert` (nodes replaced by id or
|
|
366
|
+
added). The whole result is validated before it is accepted.
|
|
367
|
+
|
|
368
|
+
## Colour values
|
|
369
|
+
|
|
370
|
+
Every colour a look, a material or a node gives is a display value: written
|
|
371
|
+
as a colour picker shows it (sRGB) and decoded to light the way LayaAir
|
|
372
|
+
decodes its own colours. Intensities are linear. Measured on the scene-linear
|
|
373
|
+
picture before tone mapping:
|
|
374
|
+
|
|
375
|
+
| Field | 0.5 gives |
|
|
376
|
+
| --------------------------------------------------------- | --------- |
|
|
377
|
+
| a flat material's `color`, a recipe material's `tint` | 22 % |
|
|
378
|
+
| `look.sun.color`, a light's `color` | 21 % |
|
|
379
|
+
| `look.ambient`, alone or beside `ambientGround`; that too | 21 % |
|
|
380
|
+
| `lightFog.color`, a water node's `color` | 21 % |
|
|
381
|
+
| `emission` | 21 % |
|
|
382
|
+
| `sun.intensity`, a light's `intensity` | 50 % |
|
|
383
|
+
|
|
384
|
+
Halving a colour does not halve its light; halve the intensity for that. The
|
|
385
|
+
same number is the same light everywhere: a lamp's glow in the fog has the
|
|
386
|
+
colour its light has on the ground, and fog of `[0.5, 0.5, 0.5]` matches a
|
|
387
|
+
sky of `[0.5, 0.5, 0.5]`. The colours inside a texture recipe are the one
|
|
388
|
+
exception, as their type `ZhudaLinearColor` says: the baker writes them into
|
|
389
|
+
an sRGB texture as light.
|
|
390
|
+
|
|
391
|
+
Until this version `ambient` beside `ambientGround`, `ambientGround`
|
|
392
|
+
itself, `lightFog.color`, a water node's `color` and the glow of lamps in the
|
|
393
|
+
fog were read as light. A scene written for that draws darker now (0.5 gave
|
|
394
|
+
50 %); `zhudaEncodeColor(old)` gives the display value that draws what `old`
|
|
395
|
+
drew. The day, dawn, dusk and overcast presets give sky light from above and
|
|
396
|
+
ground light from below (day: `[0.62, 0.64, 0.7]` and `[0.5, 0.47, 0.42]`,
|
|
397
|
+
about a third of the sun's light on the ground); `"ambientGround": false`
|
|
398
|
+
returns to one flat colour. The night preset keeps its flat, dim ambient.
|
|
399
|
+
|
|
400
|
+
`emission` is decoded like a colour, and above 1 the decoding is a 2.4th
|
|
401
|
+
power: 1 is white, 2 is 5.3 times white, 3 is 14, 4 is 28, 5.4 is 57 and 8 is 147. The grade shows up to 56 after exposure; a brighter value is scaled down
|
|
402
|
+
to that limit with its hue kept, which the grade draws near-white. Tone
|
|
403
|
+
mapping takes any bright colour toward white: a red lamp is red on the lamp
|
|
404
|
+
itself up to about 2, pale orange at 3, and cream above; its colour then
|
|
405
|
+
lives in its bloom and its halo in the fog.
|
|
406
|
+
|
|
407
|
+
## Look: time of day, shadows, sky, fog and lights
|
|
408
|
+
|
|
409
|
+
`look.preset` picks a time of day (`day`, `dawn`, `dusk`, `night`,
|
|
410
|
+
`overcast`). Every other look field overrides the preset. A scene that gives
|
|
411
|
+
no `look` at all is drawn with the day preset; a `look` without a preset is
|
|
412
|
+
the bare look (flat sky colour, no shadows, sky or fog), kept for tests.
|
|
413
|
+
|
|
414
|
+
```json
|
|
415
|
+
"look": {
|
|
416
|
+
"preset": "night",
|
|
417
|
+
"sun": { "elevationDeg": 30 },
|
|
418
|
+
"shadows": { "softness": "soft", "distance": 60 },
|
|
419
|
+
"atmosphere": { "thickness": 0.6, "exposure": 0.4 },
|
|
420
|
+
"fog": { "color": [0.05, 0.065, 0.11], "start": 25, "end": 170 }
|
|
421
|
+
}
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
| Field | Native Laya 3.4.2 feature |
|
|
425
|
+
| --------------------------------------- | --------------------------------------------------------------------------------------- |
|
|
426
|
+
| `shadows` (`false` to turn off) | `DirectionLightCom` shadow maps, 1, 2 or 4 cascades; every mesh casts and receives |
|
|
427
|
+
| `shadows.update`, `shadows.interval` | How often the maps are drawn: `every` frame, every `interval` frames, or `manual` |
|
|
428
|
+
| `atmosphere` (`false` for a flat `sky`) | `SkyProceduralMaterial` on a `SkyDome`; the sun disk follows the sun |
|
|
429
|
+
| `fog` (`false` to turn off) | Linear scene fog |
|
|
430
|
+
| `grade` (off unless given) | The existing `ZhudaFilmicPipeline`: HDR, ACES tone mapping, bloom and ambient occlusion |
|
|
431
|
+
| `light` nodes | `PointLightCom` / `SpotLightCom` (up to 128; a game passes `maxLights` to `boot`) |
|
|
432
|
+
| `emission` on a flat material | PBR emission, for lamp heads and signs |
|
|
433
|
+
|
|
434
|
+
```json
|
|
435
|
+
{ "id": "lamp", "type": "light", "kind": "point", "position": [4, 2.5, 6],
|
|
436
|
+
"color": [1, 0.45, 0.2], "intensity": 2.6, "range": 9 }
|
|
437
|
+
{ "id": "spot", "type": "light", "kind": "spot", "position": [0, 6, 4],
|
|
438
|
+
"target": [0, 0, 2], "spotAngleDeg": 40 }
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
```json
|
|
442
|
+
"grade": { "exposure": 1.7, "contrast": 1.06, "saturation": 0.96, "bloom": 0.3, "ao": 1.1 }
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
`grade` also takes what a real camera adds, each 0..1 and off by default:
|
|
446
|
+
`grain` (film grain, the same for a frame however often it is rendered),
|
|
447
|
+
`vignette` (darker corners) and `fringe` (colour fringing toward the
|
|
448
|
+
corners). A rendered frame without them is cleaner than any photograph.
|
|
449
|
+
|
|
450
|
+
A grade also names how the picture is finished (see
|
|
451
|
+
[post quality](post-quality.md)):
|
|
452
|
+
|
|
453
|
+
```json
|
|
454
|
+
"grade": { "toneMapping": "agx", "temperature": 15, "gain": [1.05, 1, 0.95],
|
|
455
|
+
"antialias": "smaa", "aoMethod": "gtao",
|
|
456
|
+
"bloomThreshold": 1.1, "bloomAnamorphic": 0.6,
|
|
457
|
+
"lut": { "asset": "looks/dusk.cube", "intensity": 0.8 } },
|
|
458
|
+
"lensFlare": { "strength": 0.8 }
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
- `toneMapping`: `aces` (default), `agx`, `neutral` or `none`.
|
|
462
|
+
- `temperature`, `tint` (-100..100) and `lift`, `gamma`, `gain` (three
|
|
463
|
+
numbers each).
|
|
464
|
+
- `antialias`: `msaa` (default), `fxaa`, `smaa` or `none`.
|
|
465
|
+
- `aoMethod`: `sao` (default) or `gtao`, which leaves open ground and the
|
|
466
|
+
sky as they are; `ao` is then a power and 1 unless given. `sao` has the
|
|
467
|
+
whole scene drawn once more each frame for its normals (a scene of 380,000
|
|
468
|
+
triangles drew 380,000 more with it); `gtao` reads the depth picture only
|
|
469
|
+
and takes six passes fewer. Where triangles or draws are the budget, a phone
|
|
470
|
+
above all, use `gtao`. The two do not look the same: compare before changing
|
|
471
|
+
a scene that is already approved.
|
|
472
|
+
- `bloomThreshold`, `bloomSoftKnee`, `bloomAnamorphic`, `bloomDiffusion`.
|
|
473
|
+
- `lut`: a `.cube` colour table by asset id, loaded with the scene.
|
|
474
|
+
- `dither`: `true` adds about one step of eight bits of noise where the
|
|
475
|
+
finished picture is written for the screen, so that slow gradients show
|
|
476
|
+
no bands ([dither](filmic-rendering.md#dither)); off unless given.
|
|
477
|
+
- `lensFlare` (beside `grade`, which it needs): the sun's flare, as strong
|
|
478
|
+
as the share of the sun that nothing stands in front of; `true` takes the
|
|
479
|
+
defaults.
|
|
480
|
+
|
|
481
|
+
All but `antialias`, `aoMethod`, the table's asset and whether there is a
|
|
482
|
+
flare can change while a look runs.
|
|
483
|
+
|
|
484
|
+
Lamps and the sun's shadow take more than LayaAir's own (see
|
|
485
|
+
[lighting depth](lighting-depth.md)): `"lightFalloff": "physical"` makes a
|
|
486
|
+
light's `intensity` its brightness at one metre, a quarter of it at two (up
|
|
487
|
+
to 2000); a spot light takes `"penumbra"` 0..1; and
|
|
488
|
+
`"shadows": { "spread": 2, "blend": true, "contact": 0.3 }` widens the soft
|
|
489
|
+
edge, blends the cascades and fades the shadow out at its end, and shades
|
|
490
|
+
the last centimetres under thin things from the depth picture.
|
|
491
|
+
|
|
492
|
+
With a grade, lamps and lit windows can be brighter than white and glow
|
|
493
|
+
instead of clipping; without one the render is the plain SDR output. The film
|
|
494
|
+
host uses the `3d-gltf` browser bundle, which carries the post-process module.
|
|
495
|
+
|
|
496
|
+
`lightFog` adds fog that sits near the ground and is lit by the scene's
|
|
497
|
+
lights: halos around lanterns, a glow in a candle-lit room, streets that sink
|
|
498
|
+
into haze. It needs `grade` and is off unless given.
|
|
499
|
+
|
|
500
|
+
```json
|
|
501
|
+
"lightFog": { "density": 0.015, "falloffMeters": 6, "baseY": 0, "color": [0.16, 0.19, 0.25], "scatter": 1.5 }
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
`maxDistance` (default 600 m) is how far along a view ray the fog is
|
|
505
|
+
gathered. The fog is laid by the depth of each pixel, and things drawn
|
|
506
|
+
without depth (particles: rain, smoke, stars) take the depth of what lies
|
|
507
|
+
behind them: in front of the sky they are fogged as if they were as far as
|
|
508
|
+
the sky, and a thick fog hides them. A short `maxDistance` (tens of metres)
|
|
509
|
+
keeps haze round the scene and its beams of light, and leaves far things
|
|
510
|
+
clear: a sea of cloud below (`clouds.baseMeters` under the eye), stars, rain
|
|
511
|
+
against the sky.
|
|
512
|
+
|
|
513
|
+
- Shapes without a prop: `box`; `lathe`, a body of revolution about the
|
|
514
|
+
vertical axis from its outline as `[radius, height]` pairs listed from the
|
|
515
|
+
bottom up (`"profile": [[0.12, 0], [0.12, 0.8], [0.09, 0.95], [0, 1]]` is a
|
|
516
|
+
bollard; barrels, domes, columns, bowls); `extrude`, a flat outline of
|
|
517
|
+
`[x, z]` pairs raised to `height` (kerbs, steps, signs, wall pieces; the
|
|
518
|
+
outline may be concave and must not cross itself); `sweep`, a
|
|
519
|
+
cross-section of `[across, up]` pairs carried along a `path` of
|
|
520
|
+
`[x, y, z]` points (a kerb round a bend, a rail, a cornice, a wall that
|
|
521
|
+
follows a street; `"closed": true` for a ring). The section stays upright
|
|
522
|
+
and keeps its width through a corner; corners are not rounded, and a path
|
|
523
|
+
must not turn back on itself. Each takes `position`, `yawDeg` and a
|
|
524
|
+
`material`, and meshes of one material are merged.
|
|
525
|
+
- Marks on surfaces: `decal`, a stain, a wet patch, a scorch or a painted
|
|
526
|
+
line laid on a floor or a wall. `"position"` is its centre on the surface,
|
|
527
|
+
`"size"` its width and length, `"normal"` the way the surface faces
|
|
528
|
+
(`[0, 1, 0]`, a floor, when left out). `"shape"` is `blob` (an oval with a
|
|
529
|
+
broken edge; `ragged` and `seed` choose it), `patch` (a rectangle) or
|
|
530
|
+
`ring`; `"color"`, `"opacity"`, `"edge"` (how soft) and `"roughness"` (low
|
|
531
|
+
reads as wet) do the rest. It is lit and shadowed like the surface under
|
|
532
|
+
it and takes no `material`. It lies on a plane: it does not wrap round a
|
|
533
|
+
corner or follow a bump.
|
|
534
|
+
- `density` is how much light a metre of fog takes away at `baseY`;
|
|
535
|
+
`falloffMeters` is the height over which the fog thins to about a third.
|
|
536
|
+
- `color` is what the fog adds by itself; the value above is moonlight in
|
|
537
|
+
the air. Left out, it is the colour the look's sky has near the horizon
|
|
538
|
+
(measured for each preset; `look.sky` for a flat or panoramic sky), so the
|
|
539
|
+
fog melts into the sky by day and by night. `scatter` scales the glow from
|
|
540
|
+
lights.
|
|
541
|
+
- Every point `light` node shines into the fog, out to its `range` (default
|
|
542
|
+
12 m): a view ray that passes farther from the light gets no glow from it,
|
|
543
|
+
so many lamps do not add up to a wash over the sky. A light with
|
|
544
|
+
`"fogOnly": true` lights only the fog and no surface: use it for lamps
|
|
545
|
+
whose light is already in a lightmap. Fog-only lights do not count against
|
|
546
|
+
the real-time lights; a scene holds up to 128 point lights (the ones that
|
|
547
|
+
shine into the fog) in all. Spot lights do not shine into the fog.
|
|
548
|
+
- The glow of lamps is not shadowed: a wall beside a lamp does not cut its
|
|
549
|
+
halo; only what the camera's own ray hits ends it. The mirrored view of a
|
|
550
|
+
`reflector` has no fog.
|
|
551
|
+
- `shafts` lets the sun or moon (`look.sun`) shine into the fog, cut by
|
|
552
|
+
whatever stands in the light: beams between trees, under eaves and through
|
|
553
|
+
window bars.
|
|
554
|
+
|
|
555
|
+
```json
|
|
556
|
+
"lightFog": { "density": 0.02, "falloffMeters": 12, "shafts": { "strength": 2, "anisotropy": 0.7, "distance": 80 } }
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
`strength` scales the beams; `anisotropy` (0..0.95) makes them brightest
|
|
560
|
+
when the camera looks toward the light; `distance` is how far from the
|
|
561
|
+
camera they are drawn (the depth picture of the light covers that stretch,
|
|
562
|
+
so a shorter distance gives sharper edges); `steps` (8..96) trades speed
|
|
563
|
+
for smoothness. Final stills average the step noise away over their
|
|
564
|
+
samples; a one-sample preview shows it as fine grain. The beams use their
|
|
565
|
+
own depth picture, so they work with `shadows: false` as well. `scale`
|
|
566
|
+
(0.25..1, default 0.5) is the size they are marched at against the
|
|
567
|
+
picture: below 1 the steps run for a quarter (or fewer) of the pixels, are
|
|
568
|
+
smoothed, and are brought up by depth so they do not spill over the edges
|
|
569
|
+
of what stands in front; 1 marches every pixel.
|
|
570
|
+
|
|
571
|
+
`panorama` draws a photograph as the sky instead of the procedural one:
|
|
572
|
+
|
|
573
|
+
```json
|
|
574
|
+
"panorama": { "asset": "sky/night.jpg", "exposure": 1, "rotationDeg": 0 }
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
The picture is a 2:1 panorama (equirectangular: the top row is straight up,
|
|
578
|
+
the bottom row straight down) in the asset directory, `.png` or `.jpg`.
|
|
579
|
+
`rotationDeg` turns it about the vertical axis to put the moon or the sun
|
|
580
|
+
where the shot wants it. It is a backdrop: it does not light the scene by
|
|
581
|
+
itself, but an `environment` probe sees it and reflects it. The picture is
|
|
582
|
+
read without mip levels or anisotropic filtering (either one draws a line down
|
|
583
|
+
the meridian where its left and right edges meet): a picture much larger than
|
|
584
|
+
the frame is not filtered down first, and its smallest stars can flicker as
|
|
585
|
+
the camera turns (not measured).
|
|
586
|
+
|
|
587
|
+
`environment` captures the scene around one point when the scene is loaded
|
|
588
|
+
and uses it as the environment of the whole scene:
|
|
589
|
+
|
|
590
|
+
```json
|
|
591
|
+
"environment": { "position": [0, 1.5, -40], "reflection": 1, "ambient": 1 }
|
|
592
|
+
```
|
|
593
|
+
|
|
594
|
+
- Glossy and metallic surfaces reflect what is around the probe: roof tiles
|
|
595
|
+
catch the lanterns, lacquer and brass get highlights. This also works on
|
|
596
|
+
lightmapped models, which otherwise have no highlights at all.
|
|
597
|
+
- Surfaces without a lightmap (characters, props, boxes) get ambient light
|
|
598
|
+
with the colour and direction of the surroundings instead of the flat
|
|
599
|
+
`ambient` colour. `"reflectionOnly": true` keeps the flat `ambient` colour
|
|
600
|
+
and takes only reflections from the capture: under a canopy or between
|
|
601
|
+
walls the captured ambient light is as dark as the surroundings.
|
|
602
|
+
- `ambientGround` (a look field beside `ambient`) gives the ambient light a
|
|
603
|
+
direction without a capture: `ambient` shines from above as sky light and
|
|
604
|
+
`ambientGround` from below as the light the ground throws back. Shadows
|
|
605
|
+
and undersides then take the colour of the ground instead of one flat
|
|
606
|
+
tone. With `reflectionOnly` the probe keeps this ambient light.
|
|
607
|
+
- There is one probe. Reflections are right at `position` and approximate
|
|
608
|
+
elsewhere, so put it near the subject of the shot. It is captured once:
|
|
609
|
+
things that move during a shot are in it where they were at time 0.
|
|
610
|
+
- A reflector's mirrored view and the fog are not in the capture.
|
|
611
|
+
|
|
612
|
+
`resolveZhudaFilmLook(look)` returns the values a scene will actually use.
|
|
613
|
+
|
|
614
|
+
## Your own props and recipes
|
|
615
|
+
|
|
616
|
+
The host ships the neutral starter set. The person who starts the server can
|
|
617
|
+
add packs: modules that export `props` (prop definitions) and `recipes`
|
|
618
|
+
(texture recipes), written against the public API.
|
|
619
|
+
|
|
620
|
+
```sh
|
|
621
|
+
npx zhuda-laya-mcp --film-output ./films --film-pack ./my-city/pack.mjs
|
|
622
|
+
```
|
|
623
|
+
|
|
624
|
+
```js
|
|
625
|
+
// my-city/pack.mjs
|
|
626
|
+
import { createZhudaBoxMesh } from 'zhuda-laya-engine';
|
|
627
|
+
export const recipes = {
|
|
628
|
+
'stone-paving': {/* ZhudaTextureRecipe */},
|
|
629
|
+
};
|
|
630
|
+
export const props = [
|
|
631
|
+
{
|
|
632
|
+
id: 'lamp-post',
|
|
633
|
+
size: [0.4, 3, 0.4],
|
|
634
|
+
defaults: {},
|
|
635
|
+
build() {
|
|
636
|
+
/* … */
|
|
637
|
+
},
|
|
638
|
+
},
|
|
639
|
+
];
|
|
640
|
+
```
|
|
641
|
+
|
|
642
|
+
Packs are trusted like server code; an agent only names what they provide,
|
|
643
|
+
and `film_scene_create` lists every prop and recipe the host can build. In the
|
|
644
|
+
page, `zhuda-laya-engine` resolves to the loaded browser SDK, so a pack adds no
|
|
645
|
+
second engine copy. Duplicate ids across packs are refused.
|
|
646
|
+
|
|
647
|
+
A pack is read from disk again when it has changed: the host notes every file
|
|
648
|
+
a pack is built from (its own and what it imports) and, when one of them is
|
|
649
|
+
written, starts its page again with the new pack before the next session or
|
|
650
|
+
the next scene it mounts. `film_scene_create` and `film_scene_preview` report
|
|
651
|
+
`packs: { fingerprint, files, loadedAt }`, the first sixteen hex digits of a
|
|
652
|
+
SHA-256 over those files, so a measurement can say which pack it was taken
|
|
653
|
+
with. A scene mounted before the change is not drawn again until it is asked
|
|
654
|
+
for again.
|
|
655
|
+
|
|
656
|
+
## Models and baked global illumination
|
|
657
|
+
|
|
658
|
+
A `model` node places a self-contained `.glb` by logical asset id. The person
|
|
659
|
+
who starts the server chooses the directory the ids resolve in:
|
|
660
|
+
|
|
661
|
+
```sh
|
|
662
|
+
npx zhuda-laya-mcp --film-output ./films --film-assets ./my-city/assets
|
|
663
|
+
```
|
|
664
|
+
|
|
665
|
+
```json
|
|
666
|
+
{
|
|
667
|
+
"id": "street",
|
|
668
|
+
"type": "model",
|
|
669
|
+
"asset": "city/street.glb",
|
|
670
|
+
"position": [0, 0, 0],
|
|
671
|
+
"yawDeg": 0,
|
|
672
|
+
"scale": 1,
|
|
673
|
+
"lightmap": "city/street.hdr",
|
|
674
|
+
"lightmapIntensity": 1
|
|
675
|
+
}
|
|
676
|
+
```
|
|
677
|
+
|
|
678
|
+
`film_scene_create` lists the `.glb` and `.hdr` files in the directory; a
|
|
679
|
+
scene that names anything else is refused, and without `--film-assets` model
|
|
680
|
+
nodes are refused. Ids never contain a path outside the directory, a URL or a
|
|
681
|
+
query. Models load through the engine's model library and asset provider, so
|
|
682
|
+
an edited scene does not download or parse an unchanged model again; a file
|
|
683
|
+
rewritten on disk is picked up by the next mount. Up to 64 models per scene.
|
|
684
|
+
A model keeps the transforms, materials and textures in its file. A clip
|
|
685
|
+
plays only where the node asks for one (see
|
|
686
|
+
[characters](#characters-clips-movement-and-lights-that-follow)).
|
|
687
|
+
|
|
688
|
+
`lightmap` is how a film scene gets global illumination. It is a Radiance
|
|
689
|
+
`.hdr` picture of the diffuse light that reaches the model's surfaces, both
|
|
690
|
+
direct and bounced, baked offline (for example with Blender's Cycles, bake
|
|
691
|
+
type Diffuse with Direct and Indirect and without Color). The engine draws it
|
|
692
|
+
with Laya's native lightmap path:
|
|
693
|
+
|
|
694
|
+
- Every mesh in the model needs a second UV set (`TEXCOORD_1`) that does not
|
|
695
|
+
overlap; glTF's convention applies, so UV (0, 0) is the picture's top-left
|
|
696
|
+
texel. One picture covers the whole model.
|
|
697
|
+
- Values are scene-linear. They are stored as 8-bit RGBM, so light above
|
|
698
|
+
about 34 is clamped and very dark texels lose precision; keep the bake's
|
|
699
|
+
exposure sensible and use `lightmapIntensity` (0..16) to scale it.
|
|
700
|
+
- A lightmap replaces the flat `ambient` on that model. The sun and `light`
|
|
701
|
+
nodes still add their own direct light on top, so a light that is already
|
|
702
|
+
in the bake should not also be a `light` node (or it counts twice). For a
|
|
703
|
+
fully baked scene set the sun intensity to 0.
|
|
704
|
+
- The picture holds diffuse light only. Glossy highlights from baked lights
|
|
705
|
+
and reflections of the surroundings are not part of it.
|
|
706
|
+
|
|
707
|
+
Props, boxes and the ground are not lightmapped; they keep the flat ambient.
|
|
708
|
+
|
|
709
|
+
**Mixed lighting.** A lightmap does not have to hold all the light. Laya adds
|
|
710
|
+
real-time lights on top of a lightmap, so the usual split is: bake what
|
|
711
|
+
bounces and what is far away, and keep as real-time lights what should cast
|
|
712
|
+
sharp shadows and make highlights. The sun (or moon) with `shadows` gives
|
|
713
|
+
crisp shadows and highlights everywhere; `shadows.cascades: 4` keeps them
|
|
714
|
+
sharp near the camera over a long `distance`. One spot light and up to eight
|
|
715
|
+
point lights per scene may cast shadows (`"castsShadow": true`). A point
|
|
716
|
+
light's surroundings are drawn once from the lamp, out to its `range`, and
|
|
717
|
+
again when its `range` or something that moves with time changes (six more
|
|
718
|
+
draws of the scene for each lamp); nothing closer to it than 0.5 m casts, so
|
|
719
|
+
the lamp's own head does not shade the scene. The shadow's edge is soft, and
|
|
720
|
+
widens with distance from the lamp. A scene
|
|
721
|
+
may hold up
|
|
722
|
+
to 128 real-time lights when the runtime was booted with `maxLights` (the MCP
|
|
723
|
+
film host is; Laya's own default is 32, and a scene asking for more than the
|
|
724
|
+
runtime has is refused when it is mounted). A light that is both baked and
|
|
725
|
+
real-time counts twice: lower one of the two.
|
|
726
|
+
|
|
727
|
+
The main directional light, the one whose shadow is drawn and whose
|
|
728
|
+
direction and colour the sky's sun takes, is the brightest directional
|
|
729
|
+
light that casts a shadow; when none does, the brightest of them, as in
|
|
730
|
+
LayaAir. A rim light a game adds beside the look's sun, brighter than the
|
|
731
|
+
sun and casting no shadow, no longer takes the shadow from it (WP22; LayaAir
|
|
732
|
+
alone chose by `intensity`, so the shadow went to the rim light). LayaAir's
|
|
733
|
+
main spot and point lights are chosen the same way. Two directional lights
|
|
734
|
+
that both cast shadows still draw only one: the brighter.
|
|
735
|
+
|
|
736
|
+
A lightmap alone lights every pixel as if the surface were flat, so normal
|
|
737
|
+
maps show nothing and stone or brick looks smooth. `lightmapDirection` fixes
|
|
738
|
+
that: a second `.hdr` picture, on the same UV set, whose RGB is the
|
|
739
|
+
world-space unit vector toward the dominant light as `d * 0.5 + 0.5`. The
|
|
740
|
+
engine then lights a pixel with `lightmap * (0.5 * max(0, n . d) + 0.5)`,
|
|
741
|
+
where `n` includes the normal map (Laya's native directional lightmap). So
|
|
742
|
+
that flat surfaces stay as baked, the baker stores
|
|
743
|
+
`light / (0.5 * max(0, N . d) + 0.5)` in the colour picture, `N` being the
|
|
744
|
+
geometric normal. Directions are in world space: a model with a direction
|
|
745
|
+
picture must keep `yawDeg` 0. This is a half-Lambert response, not a
|
|
746
|
+
physically exact one.
|
|
747
|
+
|
|
748
|
+
## Bounce light
|
|
749
|
+
|
|
750
|
+
`look.bounceLight` lights props, boxes, shapes and the ground with light
|
|
751
|
+
bounced once off the scene:
|
|
752
|
+
|
|
753
|
+
```json
|
|
754
|
+
"bounceLight": { "spacing": 3, "strength": 1 }
|
|
755
|
+
```
|
|
756
|
+
|
|
757
|
+
- When the scene is mounted, probes on a grid over its objects and lights
|
|
758
|
+
(`spacing` metres apart; `min` and `max` set the box yourself) each capture
|
|
759
|
+
their surroundings, lit as the scene is lit. LayaAir's volumetric GI then
|
|
760
|
+
lights every pixel of a physically based material from the eight probes
|
|
761
|
+
around it, in place of the ambient light: a sunlit red wall tints what
|
|
762
|
+
faces it, shaded sides take the sky's blue from above and the ground's
|
|
763
|
+
colour from below.
|
|
764
|
+
- It costs six small draws per probe at mount (a yard takes about a hundred
|
|
765
|
+
probes). Nothing is drawn per frame.
|
|
766
|
+
- Captured once: what moves afterwards keeps the light it had, and `setLook`
|
|
767
|
+
does not update it (mount the scene again).
|
|
768
|
+
- Probes that fall inside a prop, a box or a shape are switched off. Light can
|
|
769
|
+
still leak through a wall thinner than the spacing when no probe falls
|
|
770
|
+
inside it.
|
|
771
|
+
- What glows lights what is round it: a material's `emission` is drawn into
|
|
772
|
+
the probes like everything else, so a pool of lava, a furnace mouth or a
|
|
773
|
+
lit window colours the walls near it, falling off with distance. Without
|
|
774
|
+
bounce light a glowing surface is only drawn bright and lights nothing
|
|
775
|
+
(the advice rule `emission.lights-nothing` says so for a large one). The
|
|
776
|
+
light is as coarse as the probes: `spacing` 2 gives a glow that changes
|
|
777
|
+
over a couple of metres, no sharp pool of light and no shadow of its own;
|
|
778
|
+
for that add point lights along the glow. In a dark scene the borders
|
|
779
|
+
between probe cells show as thin lines on walls and floor (seen at night
|
|
780
|
+
with a strong glow; not looked into).
|
|
781
|
+
- `strength` scales the whole ambient light in the volume, sky included.
|
|
782
|
+
- Blinn-Phong and unlit materials are not lit by it. Quality level 0 drops it.
|
|
783
|
+
- In a game: `new ZhudaProbeVolume(scene3D, { min, max, solids })` and
|
|
784
|
+
`await volume.bake()` after the level has drawn a frame.
|
|
785
|
+
|
|
786
|
+
## Characters: clips, movement and lights that follow
|
|
787
|
+
|
|
788
|
+
A `model` node can play one of the clips in its file and move during a shot.
|
|
789
|
+
Both are functions of shot time, so a frame is the same however often it is
|
|
790
|
+
rendered.
|
|
791
|
+
|
|
792
|
+
```json
|
|
793
|
+
{
|
|
794
|
+
"id": "watchman",
|
|
795
|
+
"type": "model",
|
|
796
|
+
"asset": "characters/watchman.glb",
|
|
797
|
+
"position": [0, 0, -60],
|
|
798
|
+
"yawDeg": 180,
|
|
799
|
+
"animation": { "clip": "Walk", "loop": true, "speed": 1, "offsetSec": 0 },
|
|
800
|
+
"motion": [
|
|
801
|
+
{ "time": 0, "position": [0, 0, -60] },
|
|
802
|
+
{ "time": 6, "position": [0, 0, -56.4] }
|
|
803
|
+
]
|
|
804
|
+
}
|
|
805
|
+
```
|
|
806
|
+
|
|
807
|
+
- `animation.clip` names an animation in the GLB; `film_scene_create` does
|
|
808
|
+
not know the clips, so an unknown name is refused when the scene is first
|
|
809
|
+
drawn, with the names the model has. The clip time is
|
|
810
|
+
`offsetSec + time * speed`; `loop` (default true) repeats it, otherwise the
|
|
811
|
+
last frame is held. One clip at a time: no blending and no events.
|
|
812
|
+
- `motion` moves the model in straight lines between keys (the first at
|
|
813
|
+
time 0) and turns it the short way; it holds the last key afterwards. The
|
|
814
|
+
clip does not move the model: match the walking speed to the clip yourself.
|
|
815
|
+
A model with a lightmap cannot move.
|
|
816
|
+
- A point light with `"follows": { "node": "watchman", "offset": [0.3, 0.4, 0.5] }`
|
|
817
|
+
stays at that offset in the model's own frame (+Z is its front), turning
|
|
818
|
+
with it: a lantern that lights the character and the ground around it. It
|
|
819
|
+
also shines into `lightFog`.
|
|
820
|
+
- Previews, review shots and stills take `time` (seconds) to look at a
|
|
821
|
+
moment of the shot; video jobs run time from 0. Final renders sample
|
|
822
|
+
several times inside each frame, so moving things blur slightly.
|
|
823
|
+
|
|
824
|
+
Characters are lit by real-time lights and the flat `ambient`; a lightmap
|
|
825
|
+
lights only the model it was baked for. A character in a baked scene needs a
|
|
826
|
+
light of its own (the lantern it carries, or a `light` node near it).
|
|
827
|
+
|
|
828
|
+
## Reflections: wet ground and still water
|
|
829
|
+
|
|
830
|
+
A `reflector` node is a horizontal rectangle that mirrors the scene above it:
|
|
831
|
+
lanterns, lit windows, buildings and the sky appear in wet paving or a pond.
|
|
832
|
+
|
|
833
|
+
```json
|
|
834
|
+
{
|
|
835
|
+
"id": "wet-street",
|
|
836
|
+
"type": "reflector",
|
|
837
|
+
"position": [0, 0.065, -38],
|
|
838
|
+
"size": [15, 100],
|
|
839
|
+
"strength": 1,
|
|
840
|
+
"wetness": 0.45,
|
|
841
|
+
"roughness": 0.35,
|
|
842
|
+
"ripple": 0.4,
|
|
843
|
+
"patternMeters": 3,
|
|
844
|
+
"resolution": 1024,
|
|
845
|
+
"hides": ["street", "earth"]
|
|
846
|
+
}
|
|
847
|
+
```
|
|
848
|
+
|
|
849
|
+
- `position` is the centre; its `y` is the mirror height. Put it a
|
|
850
|
+
centimetre above the surface it covers: in the same plane the two flicker.
|
|
851
|
+
- The reflection is added on top of what is under it, so the paving keeps
|
|
852
|
+
its material and lightmap. It is strongest at grazing angles (Fresnel).
|
|
853
|
+
- `wetness` is the share that is standing water and mirrors sharply; the
|
|
854
|
+
rest is damp, dimmer, blurred by `roughness` and broken up by `ripple`.
|
|
855
|
+
`patternMeters` sizes the puddles.
|
|
856
|
+
- What lies below the mirror is cut from the mirrored view, so the ground a
|
|
857
|
+
reflector covers (a `ground` node, a box, a prop or a model) does not block
|
|
858
|
+
the reflection. `hides` lists `model` nodes above it that the mirror must
|
|
859
|
+
not draw.
|
|
860
|
+
- One reflector per scene. It is a second render of the scene for every
|
|
861
|
+
sample of every frame, at `resolution` pixels wide.
|
|
862
|
+
|
|
863
|
+
This is how a scene lit only by lightmaps gets highlights: a lightmap holds
|
|
864
|
+
diffuse light, and the reflector adds the mirror image of the lights.
|
|
865
|
+
|
|
866
|
+
## Clouds
|
|
867
|
+
|
|
868
|
+
`look.clouds` draws a layer of clouds with depth; `true` takes the defaults.
|
|
869
|
+
It needs `grade`.
|
|
870
|
+
|
|
871
|
+
```json
|
|
872
|
+
"clouds": { "coverage": 0.5, "baseMeters": 1500, "thicknessMeters": 900, "sizeMeters": 2600, "wind": [8, 0] }
|
|
873
|
+
```
|
|
874
|
+
|
|
875
|
+
- The look's sun lights them and its `ambient` fills their shade: a low red
|
|
876
|
+
sun gives red clouds. They drift with shot time (`time` of a preview,
|
|
877
|
+
frames of a video), and the same time draws the same sky.
|
|
878
|
+
- What is solid stands in front of them. They cast no shadow on the ground
|
|
879
|
+
and are mirrored only by `screenReflections`.
|
|
880
|
+
- `density` is how dark and hard-edged they are; `steps` (8..64) trades
|
|
881
|
+
smoothness for cost.
|
|
882
|
+
|
|
883
|
+
## Reflections on everything on screen
|
|
884
|
+
|
|
885
|
+
`look.screenReflections` adds reflections of what is on screen to every
|
|
886
|
+
surface: wet walls, props, ground beyond a `reflector`. It needs `grade`.
|
|
887
|
+
|
|
888
|
+
```json
|
|
889
|
+
"screenReflections": { "strength": 1, "wetness": 0.6, "distance": 30, "steps": 32 }
|
|
890
|
+
```
|
|
891
|
+
|
|
892
|
+
- The whole view reflects alike and by Fresnel: strongly at grazing angles,
|
|
893
|
+
faintly head-on (`wetness` is how much shows head-on): the look of rain
|
|
894
|
+
and of polished places, not a property of one material. With
|
|
895
|
+
`"surfaces": true` each surface reflects by its own normal and roughness
|
|
896
|
+
where its material says them (PBR and glTF materials do): a rough wall
|
|
897
|
+
reflects little, a polished floor much, and `wetness` then polishes
|
|
898
|
+
everything ([GPU depth](gpu-depth.md)).
|
|
899
|
+
- Only what is on screen is reflected: nothing from behind the camera or
|
|
900
|
+
from behind another object. The sky is not, unless `"sky": 1` is given:
|
|
901
|
+
then a ray that finds nothing and points upward shows the sky's colour
|
|
902
|
+
near the horizon (`skyColor` to choose it). For wet ground under an open
|
|
903
|
+
sky; indoors and under cover leave it at 0, since nothing tells such a ray
|
|
904
|
+
that a roof off screen is in its way. A `reflector` stays the tool
|
|
905
|
+
for a floor that must mirror sky and lamps exactly; the two work together.
|
|
906
|
+
- The rays are followed at half size and the result is blurred, taking
|
|
907
|
+
depth into account: the reflections are soft, like wet asphalt or a
|
|
908
|
+
polished but not mirror-flat floor. A small bright thing (a lamp head)
|
|
909
|
+
reflects as two or three soft spots; for a crisp lamp on wet ground, and
|
|
910
|
+
for the long streaks that ripples draw under lamps, use a `reflector`.
|
|
911
|
+
- Quality level 2 halves the steps; level 1 switches the reflections off.
|
|
912
|
+
- In a game `ZhudaSceneLook` takes the same field; `look.update(...)` every
|
|
913
|
+
frame keeps it aligned with the camera.
|
|
914
|
+
|
|
915
|
+
## Nature: many copies, leaves and running water
|
|
916
|
+
|
|
917
|
+
A `model` node can stand in many places at once. `placements` lists one
|
|
918
|
+
`[x, y, z, yawDeg, scale]` per copy, relative to the node's `position`: a
|
|
919
|
+
forest floor of ferns, stones along a bank, trees. The copies share the
|
|
920
|
+
model's meshes and materials. A node holds up to 20 000 copies and a scene
|
|
921
|
+
60 000; a model with placements has no lightmap, animation or motion.
|
|
922
|
+
|
|
923
|
+
```json
|
|
924
|
+
{
|
|
925
|
+
"id": "ferns",
|
|
926
|
+
"type": "model",
|
|
927
|
+
"asset": "nature/fern.glb",
|
|
928
|
+
"position": [0, 0, 0],
|
|
929
|
+
"translucent": true,
|
|
930
|
+
"placements": [
|
|
931
|
+
[4.2, 0.31, -7.5, 130, 0.9],
|
|
932
|
+
[5.0, 0.28, -6.1, 15, 1.2]
|
|
933
|
+
]
|
|
934
|
+
}
|
|
935
|
+
```
|
|
936
|
+
|
|
937
|
+
`"instanced": true` beside `placements` draws the copies in groups, one draw
|
|
938
|
+
a group instead of a node tree a copy ([instanced meshes](instanced-meshes.md)):
|
|
939
|
+
for thousands of ferns or stones. The picture is the same. Only for a model
|
|
940
|
+
of plain meshes (no bones, no morph targets).
|
|
941
|
+
|
|
942
|
+
`"cellMeters"` beside `"instanced": true` is the side of the squares of
|
|
943
|
+
ground the copies are grouped by (default 32 m, 0.5..100000). Copies spread
|
|
944
|
+
over kilometres want squares of their size: a group is one draw, and a square
|
|
945
|
+
that holds a single copy is one draw a copy again (a town, pines and lamps
|
|
946
|
+
over 8 km drew 54,698 times a frame at 32 m).
|
|
947
|
+
|
|
948
|
+
`"castShadow": false` on a model node: it casts no shadow and still takes
|
|
949
|
+
them. For ground, paving and what is too small for its shadow to show; a
|
|
950
|
+
model is drawn again in every split of the shadow map it reaches.
|
|
951
|
+
|
|
952
|
+
`"cullMeters"` on a model node: beyond that distance from the camera the
|
|
953
|
+
model is not drawn (each copy of `placements`, each group of instanced
|
|
954
|
+
copies by the middle of its box). Chosen again whenever the camera is set.
|
|
955
|
+
Not with a lightmap.
|
|
956
|
+
|
|
957
|
+
`"emission": 0` on a model node puts out what its materials give off by
|
|
958
|
+
themselves (lit windows, lanterns), and other values scale it (0..8): a
|
|
959
|
+
town built for night can stand in a daytime shot without a second copy.
|
|
960
|
+
|
|
961
|
+
`"translucent": true` lets light through leaves: the cut-out (alpha-tested)
|
|
962
|
+
materials of the model glow in their own colour when the sun or a lamp is
|
|
963
|
+
behind them, instead of going black. Bark and other opaque materials of the
|
|
964
|
+
same model are unchanged. Leaves in the shadow of other leaves stay dark.
|
|
965
|
+
|
|
966
|
+
A `water` node is clear running water on a horizontal rectangle:
|
|
967
|
+
|
|
968
|
+
```json
|
|
969
|
+
{
|
|
970
|
+
"id": "river",
|
|
971
|
+
"type": "water",
|
|
972
|
+
"position": [0, 0, 0],
|
|
973
|
+
"size": [170, 130],
|
|
974
|
+
"flow": [0.9, 0.15],
|
|
975
|
+
"color": [0.19, 0.58, 0.55],
|
|
976
|
+
"clarity": 1.1,
|
|
977
|
+
"waveMeters": 0.8,
|
|
978
|
+
"waves": 0.4,
|
|
979
|
+
"foamDepth": 0.1
|
|
980
|
+
}
|
|
981
|
+
```
|
|
982
|
+
|
|
983
|
+
- `position[1]` is the water level. The ground and stones are ordinary
|
|
984
|
+
models that cross the rectangle; water shows only where it lies above them.
|
|
985
|
+
- The bed is seen through the water, bent by the waves (`refraction`) and
|
|
986
|
+
fading into `color` with depth: `clarity` is the depth in metres at which
|
|
987
|
+
about a third of the bed's light is left. `glow` (0..4, default 0.25) is how
|
|
988
|
+
much deep water shines in that colour by itself: raise it for luminous jade
|
|
989
|
+
water, lower it for a dark pool.
|
|
990
|
+
- The surface mirrors the scene above it (`reflection`, softened as moving
|
|
991
|
+
water does), glints in the sun of `look.sun` and carries trains of waves
|
|
992
|
+
along `flow` (metres per second, driven by shot time). A soft line of foam
|
|
993
|
+
follows banks and stones where the water is shallower than `foamDepth`.
|
|
994
|
+
- The mirrored view is cut at the water level, so the bed and the sunk part
|
|
995
|
+
of stones do not show in it. `hides` takes models out of it if needed.
|
|
996
|
+
- Water needs `grade`. A scene has one mirror: one `water` or one
|
|
997
|
+
`reflector`. The rectangle is flat and level: no waterfalls or slopes.
|
|
998
|
+
- `ripples` lists up to four bodies in the water (a swimmer, a boat), each
|
|
999
|
+
`{ "position": [x, z], "radius": 0.4, "strength": 1, "velocity": [0, -1.5] }`:
|
|
1000
|
+
- Rings spread from each body, and froth gathers at its waterline.
|
|
1001
|
+
- A body with a `velocity` (metres per second) also leaves a V behind it.
|
|
1002
|
+
The two arms open at atan(0.5 / speed): a faster body leaves a narrower V.
|
|
1003
|
+
Between them are waves across the path, 2πv²/g apart.
|
|
1004
|
+
- `radius` is the body's size at the waterline; nothing is drawn under its middle.
|
|
1005
|
+
- `strength` runs 0..2; 1 suits a swimmer or a small boat.
|
|
1006
|
+
- The ripples move with shot time. They tilt the surface only: the mirror,
|
|
1007
|
+
the bent bed and the sun's glint follow them, but the water level does not change.
|
|
1008
|
+
|
|
1009
|
+
In a game, `ZhudaWaterSurface.setRipples([{ x, z, radius, strength, velocity }])`
|
|
1010
|
+
does the same; call it each frame the bodies move. With no bodies the water
|
|
1011
|
+
draws exactly as before. On an Apple M4, a 1280×720 view of water costs about
|
|
1012
|
+
0.2–0.5 ms more with one still body, and about 1.4 ms more with four moving ones.
|
|
1013
|
+
|
|
1014
|
+
## Under water
|
|
1015
|
+
|
|
1016
|
+
`look.underwater` puts the camera in water (record
|
|
1017
|
+
`docs/plans/records/underwater-look/`; drawn on WebGL and WebGPU on a
|
|
1018
|
+
desktop, not on a phone). `true` takes the defaults; it needs `grade`.
|
|
1019
|
+
|
|
1020
|
+
```json
|
|
1021
|
+
"underwater": {
|
|
1022
|
+
"surfaceY": 7,
|
|
1023
|
+
"color": [0.17, 0.33, 0.38],
|
|
1024
|
+
"extinction": [0.42, 0.11, 0.075],
|
|
1025
|
+
"maxDistance": 150,
|
|
1026
|
+
"caustics": { "strength": 1.2, "waveMeters": 2.5, "waves": 1, "fadeDepth": 10, "fadeDistance": 40 },
|
|
1027
|
+
"surface": true
|
|
1028
|
+
}
|
|
1029
|
+
```
|
|
1030
|
+
|
|
1031
|
+
- **The view.** While the eye is below `surfaceY`, what it sees is dimmed
|
|
1032
|
+
per colour channel by the water between (`extinction`, per metre: red
|
|
1033
|
+
goes first, blue last, so far things turn blue-green) and replaced by
|
|
1034
|
+
`color` (a display value), the light the water scatters, itself dimmer the
|
|
1035
|
+
deeper the eye is. Only the water up to the surface counts: past it the
|
|
1036
|
+
view is in air. Above the surface nothing changes (byte for byte).
|
|
1037
|
+
- **The light.** Sunlight on a lit surface below the surface is dimmed by
|
|
1038
|
+
the water it came through and gathered into caustics, the bright net the
|
|
1039
|
+
waves focus onto the floor: worked out from four wave trains where the
|
|
1040
|
+
ray crossed the surface, strongest a few metres down, fading with
|
|
1041
|
+
`fadeDepth` and with `fadeDistance` from the eye, moving with shot time.
|
|
1042
|
+
It is LayaAir's PBR and Blinn-Phong lighting, taught at boot
|
|
1043
|
+
(`installLaya342Underwater`); a scene without water compiles as before.
|
|
1044
|
+
`caustics: false` keeps the dimmed sun without the net.
|
|
1045
|
+
- **The surface from below** (`surface`, default true): the sky through the
|
|
1046
|
+
window overhead (within 48.6° of straight up), the sun in it, and the
|
|
1047
|
+
water's own colour beyond it where light is totally reflected; its edge
|
|
1048
|
+
wobbles with the same waves. It is left out of light shafts' depth
|
|
1049
|
+
picture, so `lightFog` with `shafts` still shows sunbeams under water;
|
|
1050
|
+
the water dims and tints them like everything else.
|
|
1051
|
+
- **Behind the water** there is only water. The plane of the surface ends
|
|
1052
|
+
at `maxDistance` from the eye; beyond it, and below the horizon, a sphere
|
|
1053
|
+
just inside the camera's far plane carries the still surface on above
|
|
1054
|
+
level and the water's own light below it. In clear water (an `extinction`
|
|
1055
|
+
of 0.01 or 0.02 a metre) the sky used to show past the plane's edge as a
|
|
1056
|
+
line across the frame; `maxDistance` no longer has to be raised for it.
|
|
1057
|
+
Things that are drawn beyond `maxDistance` are still seen through
|
|
1058
|
+
`maxDistance` of water and no more, and nothing is drawn in the last
|
|
1059
|
+
twentieth of the camera's range. Open water is counted to `maxDistance`
|
|
1060
|
+
on both sides of the horizon, so `lightFog` under water (sunbeams) is
|
|
1061
|
+
dimmed alike above and below it; toward the horizon the surface runs into
|
|
1062
|
+
the water's own colour.
|
|
1063
|
+
- **Quality.** Level 1 drops the caustics; level 0 has no HDR chain and no
|
|
1064
|
+
water (use `fog` for a cheap stand-in there).
|
|
1065
|
+
- **In place.** `setLook` changes the colour, extinction, surface height,
|
|
1066
|
+
reach and the caustics' values in place; switching the water, its
|
|
1067
|
+
caustics or its surface on or off rebuilds the look.
|
|
1068
|
+
- **In a game.** `ZhudaSceneLook` takes the same `underwater`; its `update`
|
|
1069
|
+
moves the waves with the game's frame time.
|
|
1070
|
+
- An example scene: `tests/fixtures/film/underwater.json`, checked by
|
|
1071
|
+
`npm run verify:film-underwater`.
|
|
1072
|
+
|
|
1073
|
+
## The same look in a game
|
|
1074
|
+
|
|
1075
|
+
`ZhudaSceneLook` puts a film look on a game's own `Scene3D` and camera: the
|
|
1076
|
+
sun and its shadows, sky and ground light, the procedural sky, distance fog,
|
|
1077
|
+
ground fog with beams, and the HDR grade.
|
|
1078
|
+
|
|
1079
|
+
```ts
|
|
1080
|
+
import { ZhudaSceneLook, ZhudaQualityGovernor, type ZhudaLookQuality } from 'zhuda-laya-engine';
|
|
1081
|
+
|
|
1082
|
+
const look = new ZhudaSceneLook(scene, camera, {
|
|
1083
|
+
preset: 'day',
|
|
1084
|
+
ambient: [0.9, 0.94, 1],
|
|
1085
|
+
ambientGround: [0.58, 0.58, 0.45],
|
|
1086
|
+
shadows: { distance: 60, resolution: 4096, cascades: 4 },
|
|
1087
|
+
grade: { exposure: 1.15, bloom: 0.3, ao: 0.55 },
|
|
1088
|
+
lightFog: { density: 0.006, shafts: { strength: 0.8, distance: 60 } },
|
|
1089
|
+
});
|
|
1090
|
+
const governor = new ZhudaQualityGovernor({ budgetMs: 1000 / 60 });
|
|
1091
|
+
|
|
1092
|
+
runtime.start((dt) => {
|
|
1093
|
+
// ... move the camera ...
|
|
1094
|
+
look.update(eye, target, fieldOfViewDeg, aspect);
|
|
1095
|
+
const level = governor.sample(dt * 1000);
|
|
1096
|
+
if (level !== undefined) look.setQuality(level as ZhudaLookQuality);
|
|
1097
|
+
});
|
|
1098
|
+
```
|
|
1099
|
+
|
|
1100
|
+
- `setQuality(3)` is the look as authored. Level 2 drops ambient occlusion,
|
|
1101
|
+
halves the steps of the beams and caps shadow maps at 2048; level 1 drops
|
|
1102
|
+
the beams and the lens finish, smooths edges in one pass instead of multisampling and uses two shadow cascades; level 0 drops
|
|
1103
|
+
the HDR chain altogether and draws one small shadow map. Sky, ground light
|
|
1104
|
+
and distance fog stay at every level. `zhudaLookForQuality` is that table
|
|
1105
|
+
as a pure function.
|
|
1106
|
+
- `ZhudaQualityGovernor` holds a frame budget: it steps down as soon as a
|
|
1107
|
+
window of frames averages over the budget, tries the next level up after a
|
|
1108
|
+
calm stretch, and waits twice as long before retrying a level that failed.
|
|
1109
|
+
It decides; the caller applies the level, to the look and to whatever else
|
|
1110
|
+
it wants to scale.
|
|
1111
|
+
- The depth picture of the beams follows the camera in steps and is redrawn
|
|
1112
|
+
only when the camera has left its box, since a game's scenery stands still.
|
|
1113
|
+
Call `ZhudaLightFog.invalidateShafts()` (through your own handle) when
|
|
1114
|
+
scenery changes; things that move do not cut the beams until the next redraw.
|
|
1115
|
+
- A panorama sky and `environment` need assets or a capture and are refused.
|
|
1116
|
+
- `look.setLook(next)` changes the look while it runs, with the same rules as
|
|
1117
|
+
a film stage (below); the level set by `setQuality` still applies to it.
|
|
1118
|
+
- With water: `ZhudaWaterSurface` takes `mirrorShadows: false` so the mirror
|
|
1119
|
+
draws no shadow maps of its own (its picture is then drawn without the
|
|
1120
|
+
sun's shadows), and its `render()` is called once per frame by the game
|
|
1121
|
+
(the engine's loop no longer draws the mirror itself). With
|
|
1122
|
+
`shadows.update` (below) a water left at its defaults does better: its
|
|
1123
|
+
mirror reads the maps kept for the main view.
|
|
1124
|
+
|
|
1125
|
+
### Shadows drawn less often, a smaller picture
|
|
1126
|
+
|
|
1127
|
+
Two levers for a device that cannot afford every pixel and every shadow map
|
|
1128
|
+
each frame (record `docs/plans/records/frame-cost/`; drawn on desktop WebGL
|
|
1129
|
+
and WebGPU, not yet measured on a phone):
|
|
1130
|
+
|
|
1131
|
+
- `shadows.update`: `'every'` frame (default); `'interval'` with
|
|
1132
|
+
`shadows.interval` (2..30 frames, default 3): the maps are drawn on one
|
|
1133
|
+
frame in that many and the receivers keep them in between, so a moving
|
|
1134
|
+
caster's shadow follows it in steps; `'manual'`: drawn when the game calls
|
|
1135
|
+
`look.redrawShadows()` and when `setLook` changes the sun or the shadow
|
|
1136
|
+
settings, for a still camera over still casters (a game that turns
|
|
1137
|
+
`look.sun` itself calls `redrawShadows()` after it). Stills and videos of
|
|
1138
|
+
a film draw them for every sample whatever this says. LayaAir's own
|
|
1139
|
+
`Scene3D.shadowMapFrequency` loses frames on WebGPU and breaks shaders
|
|
1140
|
+
compiled on a skipped frame on WebGL; `ZhudaShadowUpdates` (which the look
|
|
1141
|
+
uses) repairs both and should be used instead.
|
|
1142
|
+
- The maps are kept for the look's camera only. LayaAir has one set of maps
|
|
1143
|
+
for the sun, fitted to the camera that drew them last, so any other camera
|
|
1144
|
+
that draws the scene with shadows on takes them:
|
|
1145
|
+
- A water or wet surface left at its defaults reads the kept maps instead
|
|
1146
|
+
of drawing its own (its mirror then shows the main view's shadows):
|
|
1147
|
+
nothing more is drawn and nothing is taken.
|
|
1148
|
+
- `mirrorShadows: true` (and `shadows: true` on a `ZhudaPlanarReflection`)
|
|
1149
|
+
draws the mirror's own maps, after which the main view has to draw its
|
|
1150
|
+
maps again on its next frame: the picture is right, and with a mirror
|
|
1151
|
+
drawn every frame nothing is saved. `mirrorShadows: false` draws none.
|
|
1152
|
+
- A probe or bounce-light capture, and a camera of your own drawn into a
|
|
1153
|
+
target, draw maps of their own as always; the look's camera draws its
|
|
1154
|
+
maps again on the frame after.
|
|
1155
|
+
- `look.shadowStats` says what happens: `frames` drawn, how many of them
|
|
1156
|
+
`drawn` the maps, and how many of those were `taken`, drawn only
|
|
1157
|
+
because another camera had drawn maps since. `taken` rising with
|
|
1158
|
+
`frames` means the rule saves nothing in that scene.
|
|
1159
|
+
- A render scale: `new ZhudaSceneLook(scene, camera, look, { scale: 0.67 })`
|
|
1160
|
+
or `look.setRenderScale(0.67)` draws the 3D picture (and every effect of
|
|
1161
|
+
the chain) at 0.67 of the canvas, 45 % of the pixels; the 2D interface
|
|
1162
|
+
over it keeps the canvas's size. `upscale: 'fsr'` (default) brings it up
|
|
1163
|
+
with AMD FSR 1 (EASU, then RCAS sharpening, `sharpness` 0..1, default
|
|
1164
|
+
0.8); `'bilinear'` filters and sharpens in one pass; `'plain'` is LayaAir's
|
|
1165
|
+
own stretch. FSR is sharper than the plain stretch (26 to 34 % in the four
|
|
1166
|
+
looks drawn); how near the full-size picture it comes depends on the look
|
|
1167
|
+
(nearer in two of the four, slightly further in the others). The scale is
|
|
1168
|
+
LayaAir's `Config3D.pixelRatio`, one for the stage: one look at a time may
|
|
1169
|
+
hold it; a look disposed, or its scene destroyed, gives it back.
|
|
1170
|
+
- `zhudaQualitySteps()` is a ladder of look levels and render scales for the
|
|
1171
|
+
governor, cheapest first: the picture shrinks to 0.85 and 0.7 before any
|
|
1172
|
+
effect goes, then the levels drop at 0.7 down to level 1, then level 1 is
|
|
1173
|
+
drawn at 0.5 (the last rung with the HDR chain: bloom, fog and the grade
|
|
1174
|
+
stay; `effectsAtLowest: false` leaves it out), then level 0 at 0.7 and at
|
|
1175
|
+
0.5. Measured on a vivo V40, an iPhone 14 and a desktop in one synthetic
|
|
1176
|
+
scene (`docs/plans/records/quality-tiers`): where a phone is bound by its
|
|
1177
|
+
pixels, level 1 at 0.5 holds 60 frames a second where level 1 at 0.7 reads
|
|
1178
|
+
57; where it is bound by its draws (an iPhone's Safari), a smaller picture
|
|
1179
|
+
gains little.
|
|
1180
|
+
- **Frame-rate tiers.** `ZHUDA_FRAME_TIERS` names three bands by the frames a
|
|
1181
|
+
second a device holds: `low` 60 and over, `high` 45 to 60, `extreme` 10 to
|
|
1182
|
+
45 (for taking pictures). `zhudaTierBudgetMs(tier)` is the budget that holds
|
|
1183
|
+
one, `zhudaFrameTier(fps)` the tier a measured rate falls in:
|
|
1184
|
+
|
|
1185
|
+
```ts
|
|
1186
|
+
const governor = new ZhudaQualityGovernor({
|
|
1187
|
+
levels: steps.length,
|
|
1188
|
+
budgetMs: zhudaTierBudgetMs('high'), // steps down while frames run over 22.2 ms
|
|
1189
|
+
});
|
|
1190
|
+
```
|
|
1191
|
+
|
|
1192
|
+
`node scripts/measure-quality-tiers.mjs` (in the engine repository) reads
|
|
1193
|
+
what each rung gives on a device.
|
|
1194
|
+
- **Many draws.** `zhudaFrameLoadAdvice({ drawCalls })` says what to do about
|
|
1195
|
+
a frame of more than 500 draws (`ZhudaRuntimeProfiler`'s samples carry
|
|
1196
|
+
`drawCalls`, and on WebGL `renderTargets`, how often a frame went to
|
|
1197
|
+
another render target): on an iPhone's Safari such a frame is bound by
|
|
1198
|
+
issuing its draws, not by its pixels.
|
|
1199
|
+
|
|
1200
|
+
```ts
|
|
1201
|
+
const steps = zhudaQualitySteps();
|
|
1202
|
+
const governor = new ZhudaQualityGovernor({ levels: steps.length, budgetMs: 1000 / 60 });
|
|
1203
|
+
// each frame:
|
|
1204
|
+
const level = governor.sample(dt * 1000);
|
|
1205
|
+
if (level !== undefined) look.setStep(steps[level]);
|
|
1206
|
+
```
|
|
1207
|
+
|
|
1208
|
+
### Draw distance, GPU time and the next visit
|
|
1209
|
+
|
|
1210
|
+
Record `docs/plans/records/quality-governor-memory/` (desktop WebGL and
|
|
1211
|
+
WebGPU; no phone yet).
|
|
1212
|
+
|
|
1213
|
+
- **Detail rungs.** `zhudaQualitySteps({ details: [0.7, 0.4] })` adds rungs
|
|
1214
|
+
that keep the authored look and the picture size and cut `detail`, the
|
|
1215
|
+
share of its own distances the scene keeps. The default order is the one
|
|
1216
|
+
Abyssal Garden uses: the picture shrinks to the middle scale (0.85), then
|
|
1217
|
+
the distances are cut, then the rest of the scales and the look levels go.
|
|
1218
|
+
`detailAt: 1` cuts distances before any pixel goes; `detailAt: 0.7` after
|
|
1219
|
+
every one. Every rung carries `detail` (1 without `details`). The engine
|
|
1220
|
+
does not apply it: the scene multiplies it into what it owns (its draw
|
|
1221
|
+
distance, `ZhudaGrassField`'s `distanceM`, the `cullMeters` of its models,
|
|
1222
|
+
how far it scatters small things).
|
|
1223
|
+
- **GPU time.** `governor.sample(frameMs, gpuMs)` with
|
|
1224
|
+
`ZhudaRuntimeProfiler.takeGpuMs()` (WebGPU timestamps; WebGL 2 where the
|
|
1225
|
+
browser has `EXT_disjoint_timer_query_webgl2`, as desktop Chrome on this
|
|
1226
|
+
Mac does): the governor holds the GPU time inside a band round the budget
|
|
1227
|
+
(`gpuBand`, default 0.84..1.16): above it a level down, below it for a calm
|
|
1228
|
+
stretch a level up, inside it nothing. A frame interval sits at the
|
|
1229
|
+
display's refresh however little the GPU does, so only GPU time shows the
|
|
1230
|
+
room left. When fewer than half the frames of a window brought a GPU time
|
|
1231
|
+
the frame-time rule decides; `governor.basis` says which did. Single GPU
|
|
1232
|
+
readings spike (17 ms against a median of 6 on this desktop): keep the
|
|
1233
|
+
default window of 30 frames.
|
|
1234
|
+
- **Warm start.** `governor.warm()` behind a start screen decides on windows
|
|
1235
|
+
of 12 frames and tries a level up after a quarter of the usual calm, so
|
|
1236
|
+
the level has settled when play starts; `governor.warm(false)` then. It is
|
|
1237
|
+
fed the same frame times from the game's clock and has no timer.
|
|
1238
|
+
- **The next visit.** `ZhudaQualityMemory` keeps the level (and the scale and
|
|
1239
|
+
detail drawn at) in a storage the game passes, under a key it names; a
|
|
1240
|
+
storage that throws, is empty, or holds another version or another ladder
|
|
1241
|
+
length reads as nothing kept. Its load sentinel: `beginLoad()` before the
|
|
1242
|
+
heavy build, `endLoad()` on the first frame and on `visibilitychange` to
|
|
1243
|
+
hidden; still set at the next start means that load ended the tab, and
|
|
1244
|
+
`startLevel` starts one level lower (and keeps that level, so a load that
|
|
1245
|
+
fails again goes lower again).
|
|
1246
|
+
|
|
1247
|
+
```ts
|
|
1248
|
+
const steps = zhudaQualitySteps({ details: [0.7, 0.4] });
|
|
1249
|
+
let storage: Storage | null = null;
|
|
1250
|
+
try {
|
|
1251
|
+
storage = localStorage;
|
|
1252
|
+
} catch {}
|
|
1253
|
+
const memory = new ZhudaQualityMemory({ key: 'my-game', storage, levels: steps.length });
|
|
1254
|
+
const governor = new ZhudaQualityGovernor({
|
|
1255
|
+
levels: steps.length,
|
|
1256
|
+
start: memory.startLevel(steps.length - 1),
|
|
1257
|
+
budgetMs: 1000 / 60,
|
|
1258
|
+
});
|
|
1259
|
+
memory.beginLoad();
|
|
1260
|
+
// ... build the scene, then on its first frame:
|
|
1261
|
+
memory.endLoad();
|
|
1262
|
+
document.addEventListener('visibilitychange', () => document.hidden && memory.endLoad());
|
|
1263
|
+
governor.warm(); // while the start screen shows; governor.warm(false) when play starts
|
|
1264
|
+
|
|
1265
|
+
// each frame, with a ZhudaRuntimeProfiler that has enableGpuTiming:
|
|
1266
|
+
const level = governor.sample(dt * 1000, profiler.takeGpuMs());
|
|
1267
|
+
if (level !== undefined) {
|
|
1268
|
+
look.setStep(steps[level]);
|
|
1269
|
+
myScene.setDrawDistance(baseDistance * steps[level].detail);
|
|
1270
|
+
memory.write({ level, renderScale: steps[level].renderScale, detail: steps[level].detail });
|
|
1271
|
+
}
|
|
1272
|
+
```
|
|
1273
|
+
|
|
1274
|
+
## Changing the look while it runs
|
|
1275
|
+
|
|
1276
|
+
`stage.setLook(look)` (on a mounted film stage) and `ZhudaSceneLook.setLook`
|
|
1277
|
+
take a whole new `look` and return what they had to do:
|
|
1278
|
+
|
|
1279
|
+
```ts
|
|
1280
|
+
const day = scene.look;
|
|
1281
|
+
const dusk = {
|
|
1282
|
+
...day,
|
|
1283
|
+
sun: { elevationDeg: 8, azimuthDeg: 70, intensity: 0.7, color: [1, 0.55, 0.3] },
|
|
1284
|
+
ambient: [0.12, 0.1, 0.14],
|
|
1285
|
+
fog: { ...day.fog, color: [0.35, 0.25, 0.25] },
|
|
1286
|
+
grade: { ...day.grade, exposure: 0.8 },
|
|
1287
|
+
};
|
|
1288
|
+
stage.setLook(dusk); // 'updated': nothing was rebuilt
|
|
1289
|
+
stage.setLook({ ...dusk, lightFog: false }); // 'rebuilt'
|
|
1290
|
+
```
|
|
1291
|
+
|
|
1292
|
+
- **Updated in place** (cheap enough for every frame of a day passing or of
|
|
1293
|
+
weather turning, about 0.04 ms on a desktop GPU): the sun's direction,
|
|
1294
|
+
colour and intensity; sky and ambient colour; shadow distance, strength,
|
|
1295
|
+
softness, resolution and cascades; the procedural sky's tint, thickness,
|
|
1296
|
+
sun size and exposure; fog colour, start and end; the strengths of the
|
|
1297
|
+
grade (exposure, contrast, saturation, bloom, ambient occlusion, grain,
|
|
1298
|
+
vignette, fringe); the light fog's density, falloff, base height, colour,
|
|
1299
|
+
scatter and reach, and the strength and spread of its beams; the direction
|
|
1300
|
+
and colour of the beams; and the sun that water reflects. The HDR chain and
|
|
1301
|
+
the sky material stay the same objects. With `ambientGround` set, the
|
|
1302
|
+
sky/ground light is recoloured in its existing texture
|
|
1303
|
+
(`prefilterZhudaHemisphere` mixes two prefiltered bases), about 0.2 ms.
|
|
1304
|
+
- **Rebuilt**: turning shadows, the procedural sky, fog, `ambientGround`,
|
|
1305
|
+
`grade` or `lightFog` on or off; switching bloom, ambient occlusion, the
|
|
1306
|
+
lens finish (grain, vignette and fringe all zero, or not) or the beams on
|
|
1307
|
+
or off; and the beams' distance, resolution or step count. Only the look
|
|
1308
|
+
is rebuilt; nodes, models and lights stay. Resources do not grow over
|
|
1309
|
+
repeated rebuilds.
|
|
1310
|
+
- **Refused**: a different `panorama` or `environment` (mount the scene
|
|
1311
|
+
again), and any look that would not validate with the scene's nodes (for
|
|
1312
|
+
example water without `grade`). A refused look throws and leaves the frame
|
|
1313
|
+
as it was; a rebuild that fails puts the previous look back.
|
|
1314
|
+
- `stage.look` and `stage.scene` report the look now on the stage.
|
|
1315
|
+
|
|
1316
|
+
### Quality on a stage
|
|
1317
|
+
|
|
1318
|
+
`stage.setQuality(level)` draws the authored look at a lower cost, with the
|
|
1319
|
+
levels of `zhudaLookForQuality` (3 as authored, down to 0), and returns
|
|
1320
|
+
`'updated'`, `'rebuilt'` or `'unchanged'`. `setLook` keeps taking the authored
|
|
1321
|
+
look: the level stays on top of it, so a day-night cycle and a quality
|
|
1322
|
+
governor do not have to know about each other. A scene with a water surface
|
|
1323
|
+
keeps a bare HDR chain at level 0 (tone mapping only; no bloom, ambient
|
|
1324
|
+
occlusion or lens finish), because the water draws in HDR. `stage.look` is
|
|
1325
|
+
the look in use at the current level; `stage.quality` is the level.
|
|
1326
|
+
|
|
1327
|
+
What was fixed when the scene was mounted stays at every level: the bounce
|
|
1328
|
+
light is captured once and is neither removed at level 0 nor added on the way
|
|
1329
|
+
up, and the colour table loaded with the scene goes with the grade at level 0
|
|
1330
|
+
and comes back with it. So a governor may take any scene down to 0 and up
|
|
1331
|
+
again. (In 2.0.0 `setQuality(0)` threw `setLook cannot change the bounceLight`
|
|
1332
|
+
on a scene with bounce light, and `cannot change the colorTable` on a scene
|
|
1333
|
+
with a colour table and no water; a page on 2.0.0 keeps such a scene at level
|
|
1334
|
+
1 or above.) An authored look still cannot change them: `setLook` with another
|
|
1335
|
+
`bounceLight`, panorama, environment, or a colour table that was not loaded
|
|
1336
|
+
with the scene throws and leaves the stage as it was; a look may stop using
|
|
1337
|
+
the table and name it again later.
|
|
1338
|
+
|
|
1339
|
+
### Lights that change
|
|
1340
|
+
|
|
1341
|
+
`stage.setLight(id, { enabled, intensity, color, range })` changes a `light`
|
|
1342
|
+
node while the stage runs: a lamp switched on or off, a flame that flickers.
|
|
1343
|
+
Values left out stay as they are. The light's glow in the light fog follows.
|
|
1344
|
+
A light that is off gives no light but keeps its place, so switching it does
|
|
1345
|
+
not rebuild anything.
|
|
1346
|
+
|
|
1347
|
+
## Camera paths
|
|
1348
|
+
|
|
1349
|
+
A video job takes `cameraPath`: two or more keys `{ time, camera }`, the first
|
|
1350
|
+
at 0 and times increasing. The camera eases in and out between keys
|
|
1351
|
+
(smoothstep) and holds the last key afterwards. `durationSec` defaults to the
|
|
1352
|
+
last key time; `durationSec × fps` must be a whole number of frames, and a job
|
|
1353
|
+
is limited to 1800 frames. Frames pass the existing film gate before encoding,
|
|
1354
|
+
so the MP4 has exactly the frames that were rendered.
|
|
1355
|
+
|
|
1356
|
+
## In code
|
|
1357
|
+
|
|
1358
|
+
The same pieces are public:
|
|
1359
|
+
|
|
1360
|
+
```ts
|
|
1361
|
+
import {
|
|
1362
|
+
validateZhudaFilmScene,
|
|
1363
|
+
applyZhudaFilmScenePatch,
|
|
1364
|
+
sampleZhudaFilmCameraPath,
|
|
1365
|
+
mountZhudaFilmScene,
|
|
1366
|
+
loadZhudaFilmScene,
|
|
1367
|
+
ZhudaFilmAssets,
|
|
1368
|
+
ZhudaFilmRenderer,
|
|
1369
|
+
composeZhudaFilmReview,
|
|
1370
|
+
} from 'zhuda-laya-engine';
|
|
1371
|
+
import { ZHUDA_STARTER_PROPS, ZHUDA_STARTER_TEXTURES } from 'zhuda-laya-engine/demo';
|
|
1372
|
+
|
|
1373
|
+
const stage = mountZhudaFilmScene(context.rootScene, scene, {
|
|
1374
|
+
props: ZHUDA_STARTER_PROPS,
|
|
1375
|
+
recipes: ZHUDA_STARTER_TEXTURES,
|
|
1376
|
+
});
|
|
1377
|
+
const renderer = new ZhudaFilmRenderer(stage, context.runtime); // pauses the runtime
|
|
1378
|
+
const frame = await renderer.render({ width: 1920, height: 1080, samples: 16 });
|
|
1379
|
+
const sheet = await composeZhudaFilmReview([
|
|
1380
|
+
{ label: 'Wide', frame },
|
|
1381
|
+
{ label: 'Close', frame: await renderer.render({ camera: close, width: 1920, height: 1080 }) },
|
|
1382
|
+
]); // Laya 2D sheet, top-left RGBA
|
|
1383
|
+
renderer.dispose(); // restores the pause state
|
|
1384
|
+
stage.dispose();
|
|
1385
|
+
```
|
|
1386
|
+
|
|
1387
|
+
A game passes its own props and recipes; the starter set is a neutral sample.
|
|
1388
|
+
|
|
1389
|
+
### On a page, every frame
|
|
1390
|
+
|
|
1391
|
+
The same stage is drawn live by a game or a viewer. Three calls a frame, in this order:
|
|
1392
|
+
|
|
1393
|
+
```ts
|
|
1394
|
+
const stage = mountZhudaFilmScene(context.rootScene, scene, { props, recipes });
|
|
1395
|
+
let seconds = 0;
|
|
1396
|
+
context.runtime.start((dt) => {
|
|
1397
|
+
seconds += dt;
|
|
1398
|
+
stage.setTime(seconds); // clips, moving models, the lights that follow them
|
|
1399
|
+
stage.setCamera(view); // { eye, target, focalLengthMm }: a preset, or an orbit worked out this frame
|
|
1400
|
+
stage.prepare(container.clientWidth / Math.max(1, container.clientHeight)); // the lens, mirrors, fog, shadows that are due
|
|
1401
|
+
});
|
|
1402
|
+
```
|
|
1403
|
+
|
|
1404
|
+
`prepare(aspect)` gives the camera the field of view of the focal length last set (17 mm is
|
|
1405
|
+
70.4 degrees high, 50 mm is 27.0), so nothing else is needed for the lens. In 2.0.0 it did not:
|
|
1406
|
+
a page that only called `setCamera` and `prepare` drew every focal length at the camera's
|
|
1407
|
+
default angle and had to call `stage.lens.apply(aspect)` before `prepare` itself (the call is
|
|
1408
|
+
still allowed). To show another state of the scene (a wall cut away, other furniture), call
|
|
1409
|
+
`stage.dispose()` and mount the new scene in the same frame callback before the next
|
|
1410
|
+
`setCamera`: a disposed stage throws on every call. The whole path, with what goes wrong:
|
|
1411
|
+
[a film scene shown live](routes/interactive-film-viewer.md).
|
|
1412
|
+
|
|
1413
|
+
Scenes with `model` nodes load assets first, through any `AssetProvider`:
|
|
1414
|
+
|
|
1415
|
+
```ts
|
|
1416
|
+
const assets = new ZhudaFilmAssets(provider); // one per host; the provider is borrowed
|
|
1417
|
+
const stage = await loadZhudaFilmScene(context.rootScene, scene, { assets, signal });
|
|
1418
|
+
// … render …
|
|
1419
|
+
stage.dispose(); // releases its model instances and lightmap textures
|
|
1420
|
+
assets.dispose(); // after every stage
|
|
1421
|
+
```
|
|
1422
|
+
|
|
1423
|
+
Cancelling `signal`, a timeout or a failed asset rejects, releases what was
|
|
1424
|
+
already loaded and adds nothing to the scene. `decodeRadianceHdr`,
|
|
1425
|
+
`encodeZhudaLightmapRgbm` and `createZhudaLightmap` are public for tools.
|
|
1426
|
+
|
|
1427
|
+
## Edge smoothing
|
|
1428
|
+
|
|
1429
|
+
`grade.antialias` is `msaa` unless set otherwise: the HDR target is
|
|
1430
|
+
multisampled, so edges are smooth in a frame that is drawn once (a preview, a
|
|
1431
|
+
running game). `fxaa` smooths edges in one pass over the finished picture
|
|
1432
|
+
instead: nine reads a pixel and no extra memory, a little softer on fine
|
|
1433
|
+
texture, and it cannot bring back a line thinner than a pixel. On a phone
|
|
1434
|
+
(vivo V40) multisampling the HDR target was 7 to 9 ms of a frame. `none`
|
|
1435
|
+
leaves edges as they fall. Stills and video also average their samples, with
|
|
1436
|
+
any value. Quality level 1 uses `fxaa` where the look asked for `msaa`; level
|
|
1437
|
+
0 has no smoothing.
|
|
1438
|
+
|
|
1439
|
+
## Verification and limits
|
|
1440
|
+
|
|
1441
|
+
`npm run verify:film` drives the real MCP stdio server through create,
|
|
1442
|
+
preview, refused changes, apply with preview, a four-shot review, two
|
|
1443
|
+
identical still jobs (byte-identical PNGs) and an MP4, and checks the MP4 with
|
|
1444
|
+
`ffprobe`. See the [verification record](plans/records/film-scene-loop/verification.md).
|
|
1445
|
+
|
|
1446
|
+
`npm run verify:film-look` switches each look feature on and off on a real GPU
|
|
1447
|
+
and asserts the pixel change (shadows darken and never brighten, the sky has a
|
|
1448
|
+
vertical gradient, fog and a point light change the frame), remounts nine
|
|
1449
|
+
looks in a row and draws a prop from a pack. See the
|
|
1450
|
+
[look verification record](plans/records/film-look/verification.md).
|
|
1451
|
+
|
|
1452
|
+
`npm run verify:film-model` generates a GLB and an HDR lightmap, draws them on
|
|
1453
|
+
a real GPU and checks that the lit regions follow the second UV set at the
|
|
1454
|
+
encoded brightness, that scale and yaw apply, that a missing asset and a model
|
|
1455
|
+
without `TEXCOORD_1` are refused, that a direction picture scales the light
|
|
1456
|
+
by the stated factor, that a panorama sky shows its top above and turns with
|
|
1457
|
+
`rotationDeg`, that 30 mounts leave one instance and that a
|
|
1458
|
+
rewritten lightmap is picked up. See the
|
|
1459
|
+
[model verification record](plans/records/film-model-gi/verification.md).
|
|
1460
|
+
|
|
1461
|
+
`npm run verify:film-reflector` puts a lit box above a reflector on a real GPU
|
|
1462
|
+
and checks that its mirror image appears at the projected pixel with the same
|
|
1463
|
+
colour and nowhere else, that strength and dampness scale it, that a ground
|
|
1464
|
+
model blocks it unless hidden and that the frame is identical after 30 mounts.
|
|
1465
|
+
See the [reflector verification record](plans/records/film-reflector/verification.md).
|
|
1466
|
+
|
|
1467
|
+
`npm run verify:film-fog` puts a fog-only light in a dark scene on a real GPU
|
|
1468
|
+
and checks that it glows at its projected pixel in its own colour and fades
|
|
1469
|
+
with distance, that nothing changes without `lightFog`, that a far wall takes
|
|
1470
|
+
more fog than a near one, that a wall on the ray cuts the glow and that the
|
|
1471
|
+
frame is identical after 30 mounts. See the
|
|
1472
|
+
[light fog verification record](plans/records/film-light-fog/verification.md).
|
|
1473
|
+
|
|
1474
|
+
`npm run verify:film-animation` generates a skinned GLB with one clip and
|
|
1475
|
+
checks on a real GPU that the pose follows shot time (and speed and offset),
|
|
1476
|
+
that an unknown clip is refused with the model's clip names, that a moving
|
|
1477
|
+
model is where its keys say and that a following light moves and turns with
|
|
1478
|
+
it. See the
|
|
1479
|
+
[animation verification record](plans/records/film-animation/verification.md).
|
|
1480
|
+
|
|
1481
|
+
`npm run verify:film-environment` checks on a real GPU that a mirror-like box
|
|
1482
|
+
shows a lamp exactly where a mirror would (behind the camera, to the side,
|
|
1483
|
+
above, straight up, from the east) and never one placed at the mirrored-wrong
|
|
1484
|
+
side, and that a rough white box is lit by a coloured lamp on the side that
|
|
1485
|
+
faces it. See the
|
|
1486
|
+
[environment verification record](plans/records/film-environment/verification.md).
|
|
1487
|
+
|
|
1488
|
+
Not yet: several probes or box projection, blending between clips, shadowed halos of point lights in the fog,
|
|
1489
|
+
animated look or light tracks, reflection probes, real-time
|
|
1490
|
+
global illumination (`bounceLight` is captured once), spline camera paths, shot lists, path
|
|
1491
|
+
tracing and audio in render jobs. Previews and renders are desktop evidence (WebGL, and WebGPU on
|
|
1492
|
+
Apple Metal hardware); mobile is not covered.
|
|
1493
|
+
|
|
1494
|
+
## Baking textures ahead of a mount
|
|
1495
|
+
|
|
1496
|
+
`mountZhudaFilmScene` takes `bakeCache`, a map of baked texture sets. To bake before mounting (in a worker, or behind a progress bar), store each result under `zhudaBakeKey(recipe, size)`:
|
|
1497
|
+
|
|
1498
|
+
```ts
|
|
1499
|
+
import { bakeZhudaTextureSet, zhudaBakeKey } from 'zhuda-laya-engine';
|
|
1500
|
+
const cache = new Map();
|
|
1501
|
+
cache.set(zhudaBakeKey(recipe, 256), bakeZhudaTextureSet(recipe, { size: 256 }));
|
|
1502
|
+
```
|
|
1503
|
+
|
|
1504
|
+
The key does not depend on the order of a recipe's properties.
|