Replies: 2 comments
-
|
I'm trying to focus on general rendering improvements but I'm probably out of my depth here. I'm using these as a starting point:
An easy win might be to use HDRI image textures for lighting. @tsherif says this is the most straightforward way to “plus” a render in Deck. It will give more naturalistic light and make the colors more interesting. Deck supports HDRIs in ScenegraphLayer with _imageBasedLightingEnvironment and the pbr _lighting option |
Beta Was this translation helpful? Give feedback.
-
|
For one point of reference, three.js added color management and a linear workflow incrementally, both enabled by default with release r152. The roadmap issue and migration guide give some idea of the changes involved, and results before/after:
The color management guide in Blender is a good resource as well. Essentially, every color going into deck.gl would need a defined color space (this could be as simple as documenting that all inputs are assumed to be "sRGB", which they effectively are today), converted to some working color space (probably "Linear-sRGB") for use in lit material shaders, then tone mapped and converted from the working color space to an output color space (typically "sRGB") before writing to the canvas drawing buffer. Ideally the "working color space" and "output color space" are configurable, where setting both to "sRGB" should be identical to what deck.gl does today, and no conversions are needed. Also see:
Very workable on WebGL 2; no particular need for WebGPU-specific features. It isn't necessary to render to an intermediate float16 or float32 framebuffer, unless you want to do the final tonemapping and working-to-output color space conversion in a separate pass. That said, most of the linear workflow's benefits are oriented toward illuminated scenes and shading models. Many of deck.gl's common use cases don't involve a shading model, and while there might be some benefit for these unlit scenes too... I think those effects would be difficult to notice. So that may be a consideration on the cost/benefit side of things. Aside - opacity is only related as historical accident of #8972. Normally a linear workflow does not need to change how opacity works at all, opacity does not need to be gamma corrected or converted between color spaces. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Forgive the AI slop but it worded it better than I could. Basically I want to be able to render out layers and passes individually to EXR files, and do color correction later in external programs like DaVinci Resolve, Nuke, etc.
Taking a page from Blender and other renderers (and after a conversation this morning with @donmccurdy), we can get rendering appearance benefits by keeping math in linear color space and then applying sRGB correction when rendering to the screen.
Background
deck.gl currently renders in gamma-encoded sRGB color space. This is evident in several places throughout the codebase:
Opacity gamma correction (
modules/core/src/shaderlib/misc/layer-uniforms.ts):This applies gamma correction to opacity values to make them appear perceptually linear on screen.
Texture handling: Textures are loaded and processed assuming sRGB encoding.
Color blending: All color operations happen in gamma-encoded space.
While this works well for standard web visualization, it creates challenges for professional workflows that require physically accurate rendering.
The Problem
When deck.gl outputs are composited with other 3D content (film/VFX pipelines, architectural visualization, scientific visualization), the gamma-encoded output leads to:
For physically-based rendering workflows (like those using
ScenegraphLayerwith PBR materials), rendering in sRGB space undermines the physical accuracy that PBR is designed to provide.Use Cases
Proposed Solution
Add opt-in linear color space rendering support:
New layer prop:
_linearColorSpace: boolean(underscore prefix for experimental API)true, skip gamma correction on opacityColor space conversion utilities: GLSL/WGSL functions for
sRGBToLinear()andlinearToSRGB()using the official IEC 61966-2-1 transfer functionFloat framebuffer rendering: Leverage existing
rgba16float/rgba32floatsupport in luma.gl for HDR outputHDR export utilities (optional): Helper classes for exporting to HDR formats
Questions for Discussion
API Design: Should this be a per-layer prop (
_linearColorSpace) or a global deck option? Per-layer offers flexibility but may cause inconsistencies when layers mix color spaces.Default Behavior: Should we consider making linear color space the default in a future major version (v10)? The current gamma-corrected opacity was likely a pragmatic choice that may not age well.
WebGPU Considerations: WebGPU has better support for sRGB texture formats and automatic gamma correction. Should we design the API with WebGPU's capabilities in mind?
Scope: Should the initial implementation focus narrowly on "opt-in linear output" or attempt to handle input textures (converting sRGB textures to linear on load)?
Interaction with existing PBR: The
ScenegraphLayeralready uses PBR through luma.gl. How should linear color space mode interact with existing PBR materials?Prior Art
renderer.outputColorSpace = THREE.LinearSRGBColorSpacescene.imageProcessingConfiguration.toneMappingEnabledI'd love to hear thoughts from the maintainers and community on the best approach here.
Beta Was this translation helpful? Give feedback.
All reactions