Skip to content

Optimizations for LUT readback#18306

Merged
RaananW merged 2 commits intoBabylonJS:masterfrom
kircher1:atmo-sampling-opts
Apr 14, 2026
Merged

Optimizations for LUT readback#18306
RaananW merged 2 commits intoBabylonJS:masterfrom
kircher1:atmo-sampling-opts

Conversation

@kircher1
Copy link
Copy Markdown
Contributor

Motivation is to do all the conversion up front, then any follow up sampling is cheaper.

Copilot AI review requested due to automatic review settings April 14, 2026 01:39
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR optimizes CPU-side LUT sampling in the atmosphere add-on by converting GPU readback data into normalized Float32Array buffers up front, so subsequent sampling avoids per-texel conversion work.

Changes:

  • Convert transmittance + diffuse sky irradiance LUT readback data into normalized Float32Array buffers during readPixelsAsync().
  • Update LUT sampling call sites to sample float data without passing a normalization function.
  • Adjust Sample2DRgbaToRef / texel fetch to allow skipping normalization when the input data is already normalized.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
packages/dev/addons/src/atmosphere/transmittanceLut.ts Stores LUT readback as normalized Float32Array and samples without per-sample normalization.
packages/dev/addons/src/atmosphere/sampling.ts Makes normalizeFunc optional and adds a fast path that returns raw channel values when omitted.
packages/dev/addons/src/atmosphere/diffuseSkyIrradianceLut.ts Stores LUT readback as normalized Float32Array and samples without per-sample normalization.

Comment thread packages/dev/addons/src/atmosphere/sampling.ts
Comment thread packages/dev/addons/src/atmosphere/sampling.ts
Comment thread packages/dev/addons/src/atmosphere/transmittanceLut.ts Outdated
@Popov72
Copy link
Copy Markdown
Contributor

Popov72 commented Apr 14, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 14, 2026

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 14, 2026

Snapshot stored with reference name:
refs/pull/18306/merge

Test environment:
https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/refs/pull/18306/merge/index.html

To test a playground add it to the URL, for example:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/refs/pull/18306/merge/index.html#WGZLGJ#4600

Links to test your changes to core in the published versions of the Babylon tools (does not contain changes you made to the tools themselves):

https://playground.babylonjs.com/?snapshot=refs/pull/18306/merge
https://sandbox.babylonjs.com/?snapshot=refs/pull/18306/merge
https://gui.babylonjs.com/?snapshot=refs/pull/18306/merge
https://nme.babylonjs.com/?snapshot=refs/pull/18306/merge

To test the snapshot in the playground with a playground ID add it after the snapshot query string:

https://playground.babylonjs.com/?snapshot=refs/pull/18306/merge#BCU1XR#0

If you made changes to the sandbox or playground in this PR, additional comments will be generated soon containing links to the dev versions of those tools.

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 14, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 14, 2026

@bjsplat
Copy link
Copy Markdown
Collaborator

bjsplat commented Apr 14, 2026

@RaananW RaananW merged commit 06df5ec into BabylonJS:master Apr 14, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants