NativeEngine: load single-file .dds/.ktx/.ktx2 cubemaps + spherical harmonics (re-enables 6 PBR tests)#1748
Draft
bkaradzic-microsoft wants to merge 1 commit into
Conversation
…armonics loadCubeTexture now accepts a single self-contained cubemap container (all six faces + mips), decoded via bimg::imageParse, and uploads sides 0-5 x mips. ComputeCubeSphericalPolynomial derives the diffuse-IBL spherical harmonics from the top-mip faces (port of CubeMapToSphericalPolynomialTools) and returns the polynomial coefficients to JS. This is done natively because the WebGL upload and cube-readback paths are unimplemented on native and .dds stores no SH. Re-enables 6 prefiltered-environment PBR validation tests. Pairs with BabylonJS/Babylon.js#18560 (native createCubeTexture dispatch for single-URL containers). Depends on a babylonjs dependency bump including it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
NativeEngine: load single-file
.dds/.ktx/.ktx2cubemaps + compute spherical harmonicsWhat
Adds native support for loading a self-contained cubemap container (
.dds/.ktx/.ktx2,the format produced by
CubeTexture.CreateFromPrefilteredData(...)) and re-enables six PBRenvironment validation tests.
Plugins/NativeEngine/Source/NativeEngine.cpp:loadCubeTexturenow accepts a single buffer (all six faces + mips in one container).ParseCubeImageruns it throughbimg::imageParse(which decodes DDS/KTX/KTX2 cubemaps), andLoadCubeTextureFromContaineruploads sides 0–5 × mips.ComputeCubeSphericalPolynomialderives the diffuse-IBL spherical harmonics from the top-mipfaces (a port of Babylon's
CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial)and returns the 9×3 polynomial coefficients to JS.
Apps/Playground/Scripts/config.json: re-enables the six tests this unblocks (NMEGLTF,Anisotropic,Clear Coat,PBRMetallicRoughnessMaterial,PBRSpecularGlossinessMaterial,PBR).Why this shape
These scenes load a prefiltered environment via a single
.dds. WebGL gets the cube faces andcomputes the spherical harmonics on the CPU through the texture-loader path. On native that path
is unavailable:
_uploadDataToTextureDirectly/_uploadCompressedDataToTextureDirectlyand cube_readTexturePixelsare unimplemented stubs. The.ddsalso stores no SH (Babylon computes it fromthe faces). So the SH must be computed from the decoded faces, in native C++, alongside the upload —
no
.envswap, no JS polyfill, no GPU readback.Paired Babylon.js change
createCubeTexturedispatch for single-URL containersand sets
_sphericalPolynomialfrom the returned coefficients.Verification (local)
--include-excluded) and pass, matching theirreference images. The SH integration is correct (total solid angle = 4π).
Prepass SSAO + depth of fieldalso references a.ddsenv — its cube now loads, but itstill fails on unrelated SSAO/DoF/prepass differences, so it remains excluded (separate issue).