Optimizations for LUT readback#18306
Conversation
There was a problem hiding this comment.
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
Float32Arraybuffers duringreadPixelsAsync(). - 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. |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s). |
|
Snapshot stored with reference name: Test environment: 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 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. |
|
Visualization tests for WebGPU |
|
WebGL2 visualization test reporter: |
Motivation is to do all the conversion up front, then any follow up sampling is cheaper.