Skip to content

Add linear PBR output and shared tone-mapping operators - #4351

Merged
borisbat merged 2 commits into
masterfrom
boris/hdr-color-output
Oct 23, 2026
Merged

borisbat merged 2 commits into
masterfrom
boris/hdr-color-output

Conversation

@borisbat

@borisbat borisbat commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Behavior change: linear_to_SRGB now uses the correct linear-segment threshold for dark values. The glTF renderer keeps its existing output by default.

Why. HDR composition needs radiance before display encoding. Tone operators were duplicated across tutorials.

What changes.

  • Add optional scene-linear PBR output and shared Reinhard, ACES-fit and PBR Neutral operators.
  • Reuse the corrected sRGB encoder and document the transfer boundaries.
  • Include operator attribution and its license in SDK installs and bundled tools.

Observable behavior.

  • Linear PBR mode retains emissive values above one.
  • Encoding linear 0.001 now returns 0.01292.

Where to look. color_mapping.das, gltf_pbr.das, and the CPU/shader/readback regressions.

Validation, claims, ledger

Validation

  • Installed-SDK probes pass outside the source tree: color helpers run with dynamic modules disabled, and PBR defaults instantiate using bundled SDK modules.
  • Full native test_aot build and sweep passed. The one full preflight stopped on added line lengths; after wrapping, targeted lint and every skipped runtime/utility lane passed. Post-review focused tests also pass; the Windows x86 precision adjustment is described below.
  • All 27 repository REVIEW gates pass after adding the license to the SDK server bundle manifest; that consumer-specific gate failed before the entry and passed after.
  • All 59 release-profile bundle checks passed. The permanent license check additionally passes with COLOR_MAPPING.LICENSE, fails when it is removed, and passes when restored; installed bytes match the source.
  • All reference generators and Sphinx HTML passed with warnings treated as errors. Vulkan bindings were built locally for documentation; both changed Vulkan tutorial shader files also compile.
  • Native OpenGL float-target readback covers default mode, switching back, above-white emission, both fog conversions, tint and alpha. Disabling linear output or either fog branch fails the regression.
  • The sRGB regression fails on the old threshold. CPU controls distinguish the Neutral toe, chromatic shoulder, RGB lanes and negative-input policy.
  • Windows x86 deliberately uses estimated pow. A native 32-bit probe reproduced the three CI precision failures; tests now use measured allowances of 2.5e-5 for their round-trip inputs and 1e-4 for their HDR decode vector on that platform only. Other targets retain their original bounds. The Windows 32-bit CI lane passes with the correction. All 14 negative controls still fail with the wider limits; no assertions were removed.
  • GLSL suite: 125/125; SPIR-V suite: 430/430 with external validators. Generated fixtures use GLSL 330, GLSL ES 3.00, and a SPIR-V 1.3 fragment entry point with one runtime color input and four written outputs. The census checks its newly exercised OpUnreachable in both directions.
  • All seven names newly listed by the color_mapping generator resolve in daslib/color_mapping.das; checked against those declarations and generated doc/source/stdlib/generated/color_mapping.rst using bin/daslang -documentation doc/reflections/das2rst.das.
  • The new color-output-boundaries architecture section was checked against both cited operators (tone_reinhard, tone_aces_fit) and the named OpenGL/Vulkan tutorial consumers.
  • Independent Sol audits and two external Sol review rounds completed; final external round found no actionable correctness defect.

Claims - stated, not tested

  • Vulkan GPU execution was not run on this host. Shader compilation, SPIR-V generation and spirv-val do not establish device rendering or presentation behavior.

Not done

  • Nightly CI is not requested.
  • Background tint remains a multiplier in the selected output domain; linear mode does not promise the legacy display-space appearance. The documented behavior is covered by readback.
  • Kept concrete RGB wrappers rather than adding generic lifting machinery. The existing example-local aces_tonemap remains unchanged because its negative-input policy differs.
  • No new guarantees for extreme floating-point magnitudes beyond the reference operators.

Copilot AI balanced review requested due to automatic review settings October 23, 2026 08:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

It changes a public stdlib function's output and adds a renderer output path affecting GLSL/SPIR-V/Vulkan shaders whose rendering correctness cannot be exercised in this automated environment, so it warrants human sign-off.

1 open issue
What changed in this PR

This PR extracts the tone-mapping/sRGB helpers that were duplicated across the OpenGL and Vulkan tutorials into a new shared daslib/color_mapping module, adds an optional scene-linear output path to the glTF PBR renderer, and corrects the sRGB linear-segment threshold in linear_to_SRGB. It fits into the stdlib/shader-tutorial surface: the same operators now feed GLSL, SPIR-V and Vulkan consumers, with matching documentation, license attribution, and CPU/shader/readback regression tests.

Changes:

  • New daslib/color_mapping module with tone_reinhard / tone_aces_fit / tone_pbr_neutral and color_srgb_encode/decode (+ per-channel forms); tutorials and gltf shaders now call the shared operators instead of local copies.
  • Fixes linear_to_SRGB to use the correct 0.0031308 linear-segment threshold (was 0.00031308), with a dedicated transfer regression test.
  • Adds GltfPbrRenderer.linearOutput (scene-linear radiance + fog decode) plus license/notice wiring (THIRD_PARTY_NOTICES, CMake install, bundle smoke test) and docs/architecture/tests.
File Description
daslib/​color_mapping.das New shared module: tone operators + sRGB transfer functions
daslib/​math_boost.das Corrects linear_to_SRGB linear-segment threshold
daslib/​color_mapping.LICENSE Apache-2.0 + ACES attribution for the new operators
daslib/​ARCHITECTURE_SHADER.md New #color-output-boundaries section cited by the operators
modules/​dasGLTF/​gltf/​gltf_pbr.das Adds u_linear_output uniform, linear output + fog decode, linearOutput field
modules/​dasGLTF/​tests/​test_render_targets.das GL readback regression for linear/legacy/fog/tint
modules/​dasGLTF/​README.md Documents linear output + shared operators
tutorials/​opengl/​{03_sdf,11_hdr,12_gltf} Replace local tonemap/aces_fit with shared operators
modules/​dasVulkan/​tutorials/​{03_sdf,11_hdr}/​*_shaders.das Same operator migration for Vulkan
tests/​math/​test_color_mapping.das, test_srgb_transfer.das CPU reference-value and transfer coverage
tests/​glsl/​test_color_mapping.das, tests/​spirv/​{_color_mapping_shader,test_color_mapping,test_census}.das GLSL/SPIR-V shader compilation + census coverage
tests/​aot/​CMakeLists.txt Registers the new SPIR-V shader module for AOT
doc/​* , skills/​daslang/​references/​everything.md, THIRD_PARTY_NOTICES.md, CMakeLists.txt, ci/​smoke_test_bundle.sh, tests/​README.md Docs digest, toctree, license install, and bundle/test bookkeeping

Review effort: Balanced

Comment thread tests/spirv/test_census.das

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

It spans a public-API behavior change (linear_to_SRGB), the glTF renderer, and GPU shader/SPIR-V/GLSL paths whose device-rendering and golden-fixture claims cannot be verified here, so it warrants human review.

3 open issues

Review effort: Balanced

Comment thread daslib/color_mapping.das Outdated
Comment thread doc/source/stdlib/handmade/module-color_mapping.rst
Copilot AI balanced review requested due to automatic review settings October 23, 2026 09:20
@borisbat
borisbat force-pushed the boris/hdr-color-output branch from 81a705d to b9a9d76 Compare October 23, 2026 09:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

It changes a shared, widely-used color function's output and spans stdlib, renderer HDR behavior, cross-API shader emission, and license/install wiring, which warrants human sign-off despite the code appearing correct.

1 open issue
3 resolved since last review

Review effort: Balanced

Comment thread daslib/color_mapping.das
@borisbat
borisbat force-pushed the boris/hdr-color-output branch from b9a9d76 to 3424887 Compare October 23, 2026 10:02
Copilot AI balanced review requested due to automatic review settings October 23, 2026 10:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

It changes a shared public color function's behavior, adds a new public stdlib module and a glTF renderer output mode, and spans shader codegen across GLSL/SPIR-V/Vulkan whose device-rendering path the PR itself states was not executed, warranting human final sign-off.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@borisbat
borisbat merged commit d14c44b into master Oct 23, 2026
50 checks passed
@borisbat
borisbat deleted the boris/hdr-color-output branch October 23, 2026 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants