feat(standard): opt-in deform features (skeleton/vertex-color/uv-offset) + dynamic fog#338
Draft
PatrickRyanMS wants to merge 2 commits into
Draft
feat(standard): opt-in deform features (skeleton/vertex-color/uv-offset) + dynamic fog#338PatrickRyanMS wants to merge 2 commits into
PatrickRyanMS wants to merge 2 commits into
Conversation
…code scene231 (port onto upstream BabylonJS#300) Reuses the validated integration of the Standard skeleton, vertex-color and uvOffset deform features onto the current upstream base (0a556d3, BabylonJS#300), plus the in-code scene231 parity scene (programmatic bone animation, MAD 0.000). Branches cleanly off upstream (yesterday's local commit is not an ancestor). Byte-neutrality: the enableStandard* opt-ins are exposed via the deep module path (babylon-lite/material/standard/enable-standard-mesh-features.js), NOT re-exported through the index.ts barrel. Re-exporting through the barrel perturbed Rollup/terser export-name mangling in shared chunks, adding ~10 bytes to every scene (incl. non-Standard scenes); the deep import keeps index.ts byte-identical to upstream so non-feature scenes don't shift. The remaining ~0.1KB shift on a few Standard scenes is the inherent terser shift from the in-pipeline hooks (folds the feature code, but the source edit nudges mangling) and is offset by the fog optimization in the next commit. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…o fog bytes Ports the dynamic fog gating from the prior Branch A onto upstream BabylonJS#300, mirroring the PBR fog path (pbr-fog-wgsl.ts). The fog `calcFogFactor` helper + blend block move out of the always-included standard-template into a new std-fog-wgsl module that standard-group-builder dynamic-imports ONLY when scene.fog is set; the strings are threaded through the renderable into composeStandardShader (_fogHelper/_fogBlock, "" for non-fog scenes). Effect vs a fresh upstream build (same env): 80+ scenes smaller, total -86 KB; the deform-hook terser shift on non-fog Standard scenes is now offset (the ex-boundary scenes are ~1 KB smaller). Fog scenes pay the dynamic-fog chunk-wrapper overhead (~+0.3 KB), the same tradeoff PBR makes; scene3's ceiling is bumped 54 -> 54.5 to cover it (user-approved). Full visual parity unchanged (418 passed; scene3 fog MAD 0.000); only the 3 machine-sensitive Havok scenes fail as usual. Regenerates the tracked per-scene bundle baseline (lab/public/bundle/manifest/<scene>.json) for the 84 scenes whose raw size or runtime chunks moved on this branch, and adds scene231's manifest, per docs/lite/architecture/38-bundle-size-tooling.md ("Commit the regenerated files for any scene whose size or runtime chunks moved"). Removes the accidentally-committed aggregate lab/public/bundle/manifest.json — a gitignored generated artifact that PR BabylonJS#294 replaced with the per-scene files and that must never be committed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
API ChangesAPI Extractor detected public API changes for No removed public API lines were detected; this appears to be additive. API Extractor diffdiff --git a/home/vsts/work/1/s/test-results/api-report/target/temp/babylon-lite.api.md b/home/vsts/work/1/s/test-results/api-report/current/temp/babylon-lite.api.md
index 873e78f3..285a0a39 100644
--- a/home/vsts/work/1/s/test-results/api-report/target/temp/babylon-lite.api.md
+++ b/home/vsts/work/1/s/test-results/api-report/current/temp/babylon-lite.api.md
@@ -5331,6 +5331,7 @@ export interface StandardMaterialProps extends Material {
specularTexture: Texture2D | null;
stencil?: StencilState;
useLightmapAsShadowmap: boolean;
+ uvOffset?: [number, number];
uvScale: [number, number];
} |
Bundle Size ChangesDecreases
Sizes rounded to nearest KB. Run |
Lab - Static SiteBuild 20260629.11 - merge @ 9eee93c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two related, fully tree-shakable additions to
StandardMaterial:enableStandardVertexColor/enableStandardSkeleton/enableStandardUvOffset). They add zero bytes to scenes that do not import them.scene.fogis set, mirroring the existing PBR fog path (pbr-fog-wgsl).Why fold fog away, and how it affects every Standard scene
Until now the Standard material's fog code (the
calcFogFactorhelper + the fog blend block) lived in the always-includedstandard-template, so every Standard scene shipped the fog shader — including the large majority that render no fog at all. PBR already gates its fog behind a dynamic import; this brings Standard in line.The helper/block move into a new
std-fog-wgslmodule thatstandard-group-builderdynamic-imports only whenscene.fogis set, threading the strings through the renderable intocomposeStandardShader(empty string for non-fog scenes, so the shader compiles identically). The net result is that fog bytes now ride only on scenes that actually use fog.Bundle impact (measured against a fresh
masterbuild in the same environment)scene3) now loads the dynamic-fog chunkThe one small increase
scene3is a fog scene, so it now pulls in the dynamic-fog chunk, which carries ~0.3 KB of chunk-wrapper overhead versus inlining — the identical tradeoff PBR's fog path already makes.scene3had zero ceiling headroom (54.0 KB), so itsmaxRawKBis raised 54 -> 54.5. Even after that bump, the branch is a net -86 KB reduction across the suite.New parity scene
scene231is a new in-code (no glTF) parity scene that exercises all three deform features together — skinning + per-vertex color + UV offset — with programmatically animated bones frozen at a deterministic frame. It renders pixel-identical to Babylon.js (MAD 0.000). (This adds new test-scene bundle content; it is not an engine-size change.)Byte-neutrality note
The
enableStandard*opt-ins are imported via their deep module path rather than re-exported through theindex.tsbarrel. Re-exporting them through the barrel perturbed terser export-name mangling in shared chunks and added bytes to every scene (including non-Standard scenes); the deep import keepsindex.tsbyte-identical tomaster.Validation
scene3fog MAD 0.000,scene231MAD 0.000; only the 3 machine-sensitive Havok physics scenes fail locally (environmental, unrelated to this change).lab/public/bundle/manifest/<scene>.json) is regenerated for the 84 scenes whose size or runtime chunks moved, plus scene231, perdocs/lite/architecture/38-bundle-size-tooling.md.