Add native cube render target support (re-enables 2 shadow-with-instances tests)#1750
Draft
bkaradzic-microsoft wants to merge 1 commit into
Draft
Conversation
This was referenced Jun 11, 2026
bkaradzic-microsoft
added a commit
to BabylonJS/Babylon.js
that referenced
this pull request
Jun 17, 2026
Addresses review: cube RT adds isCube/layer params that old native silently ignores (2D RT with aliased faces, no error). Bumping the protocol version makes any JS<->Native version skew fail loudly at engine init via the existing strict-equality check, instead of rendering incorrectly. Pairs with the native-side bump in BabylonJS/BabylonNative#1750 (landed together with the babylonjs pin bump).
Member
Author
|
TODO at landing: bump the native This must land in the same change that bumps the |
bkaradzic-microsoft
added a commit
to BabylonJS/Babylon.js
that referenced
this pull request
Jun 18, 2026
Paired native PR: BabylonJS/BabylonNative#1750 ## What Adds cube render target support to the Babylon Native engine. Previously the native engine had no `createRenderTargetCubeTexture` override and `bindFramebuffer(faceIndex)` threw, so any feature that renders into a cube map — `ReflectionProbe`, point-light cube shadow maps — fell through to the WebGL code path and dereferenced the null `_gl` context (`TEXTURE_CUBE_MAP undefined`). ## Changes (`packages/dev/core/src/Engines`) - `thinNativeEngine.pure.ts` - `createRenderTargetCubeTexture`: creates a native cube color texture and one framebuffer per face (the native side binds the matching cube layer). - `bindFramebuffer`: binds the per-face framebuffer for cube render targets. - `generateMipMapsForCubemap`: no-op on Native — bgfx auto-generates the mip chain on render-target resolve, the same way 2D RTTs get their mips. - `Native/nativeRenderTargetWrapper.ts`: tracks per-face framebuffers and releases them on dispose. - `Native/nativeInterfaces.ts`: threads the cube/layer params through `initializeTexture` and `createFrameBuffer`. ## Paired native change Requires the matching BabylonNative C++ change (cube color texture + per-face attachment). Draft until both land. ## Testing Built `babylon.max.js` and ran the BabylonNative Playground validation suite (D3D11). The "Shadows with instances" tests (left/right handed), which previously crashed, now pass; the ReflectionProbe and point-light-shadow scenes render with correct geometry and orientation. --- ## Related PRs & landing order - **Babylon.js (engine / TS):** #18561 - **BabylonNative (C++ engine + test re-enable):** BabylonJS/BabylonNative#1750 Co-dependent; land in this order: 1. **Babylon.js #18561 first** — adds the cube render-target TS overrides; no WebGL behavior change. 2. A **`babylonjs` npm release** ships that TS change. 3. **BabylonNative #1750 last** — bumps the bundled `babylonjs` and re-enables the 2 `Shadows with instances` (left/right handed) validation tests, which only pass once the paired JS is present in the bundled engine. --------- Co-authored-by: Branimir Karadzic <branimirkaradzic@gmail.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…nces tests) Render-to-cubemap on the native engine so ReflectionProbe and point-light cube shadow maps render instead of dereferencing the null WebGL context. - InitializeTexture: optional isCube param -> Texture::CreateCube. - CreateFrameBuffer: optional layer param so the color attachment targets a single cube face (bgfx::Attachment layer); the JS side creates one framebuffer per face and binds the matching one per face. Re-enables the "Shadows with instances in left/right handed system" validation tests that previously crashed/hung. Requires the paired Babylon.js change (native cube render target JS overrides); CI stays red until a babylonjs npm with that change is published and the dep bumped here. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
77c4f66 to
f7da119
Compare
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.
Paired engine PR: BabylonJS/Babylon.js#18561
What
Implements cube render targets on the native engine so
ReflectionProbeandpoint-light cube shadow maps render instead of crashing on the null WebGL
context. Pairs with the Babylon.js change that adds the JS-side overrides.
Changes
Plugins/NativeEngine/Source/NativeEngine.cppInitializeTexture: optionalisCubeparam →Texture::CreateCube.CreateFrameBuffer: optionallayerparam so the color attachment targetsa single cube face (
bgfx::Attachmentlayer). The JS side creates oneframebuffer per face and binds the matching one per face.
Apps/Playground/Scripts/config.json: re-enables "Shadows with instances inleft/right handed system" (previously excluded as crash/hang).
CI
The validation suite uses the published
babylonjsnpm, which does not yetcontain the paired JS overrides, so the re-enabled tests stay red until a
babylonjsrelease with the Babylon.js change ships and the dependency isbumped here. Draft until then.
Verified locally
Built against a local
babylon.max.jswith the paired change: the twore-enabled tests pass and there are no regressions in post-process / 2D
render-target tests.
Related PRs & landing order
Co-dependent; land in this order:
babylonjsnpm release ships that TS change.babylonjsand re-enables the 2Shadows with instances(left/right handed) validation tests, which only pass once the paired JS is present in the bundled engine.