-
-
Notifications
You must be signed in to change notification settings - Fork 36k
Examples: Add WebGPU HDR Example #31893
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Wrap `damp` into `nodeObject()`.
Can we then remove the HDR usage from |
examples/webgpu_hdr.html
Outdated
// Enable Extended sRGB output color space for HDR presentation | ||
THREE.ColorManagement.define( { [ ExtendedSRGBColorSpace ]: ExtendedSRGBColorSpaceImpl } ); | ||
THREE.ColorManagement.workingColorSpace = ExtendedSRGBColorSpace; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RenaudRohlinger The working color space will need to remain Linear-sRGB (the default value). If this causes other issues I think we can work that out! You're correct that we do need to register Extended sRGB and assign it as the output color space, though.
Conceptually, you can think of Extended sRGB as a color space that pre-supposes some fixed representation of "white" relative to the display, and then provides a mechanism for output at greater wattage than this "white". There are technical/conceptual/perceptual issues with that approach, but it's what WebGPU HDR gives us today, so we'll use it as the output space.
In our working color space, prior to image formation (exposure, tone mapping), we can think of the RGB values as stimulus received by the camera. There's no image yet formed, nothing is relative to any display or viewing environment, and without such a reference to anchor perceptual interpretation there is no "white". So Extended sRGB has no practical meaning as a working color space in a lit rendering pipeline.
Additionally, Extended sRGB uses a non-linear transfer encoding that isn't valid for the PBR rendering process.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, thanks for the great explanations @donmccurdy!
Thanks for the reviews, should be good now! |
@RenaudRohlinger How would you feel about renaming this example to |
That’s definitely more pertinent, but I’m not sure the concept of |
Well, that is what the demo is about.... I think your |
My feeling is that the "Extended sRGB" space is a necessary evil to access the capabilities of the display at this point — if WebGPU were to expose Rec 2100 HLG (or similar) I would prefer to switch the example over to that as the output color space. |
I have some questions about this example. (I have a silicon iMac.)
|
Ah, this line is incorrect:
Instead we want to be checking the color space's defined tone mapping mode... three.js/examples/jsm/math/ColorSpaces.js Line 133 in 3220e98
... so that use of outputType=HalfFloat does not send output beyond [0,1] as it does here.
This how "Extended sRGB" is defined, and so unfortunately necessary under the current WebGPU HDR spec. Similar to my comment above, I think this is a problematic choice in the spec, and I'd be glad to drop support for Extended sRGB given any other option. It is, indeed, a non-linear sRGB encoding on the [0, ∞] domain.
I believe there are two mechanisms operating under the name "tone mapping" here, confusingly. The first is three.js' own tone mapping, which we haven't yet implemented for HDR output. I think it's important that we add that, even if the Extended sRGB output space is not sufficient for us to design it correctly, if only to understand the limitations better. The second is WebGPU's (or the OS's?) own "tone mapping" to adapt the formed image to the display. That behavior is visible in this example in the form of increasing/decreasing contrast when changing the brightness of the laptop display on macOS. Available HDR "headroom" decreases as the laptop brightness increases. |
Hm, if I set a breakpoint at WebGPUBackend.js#L258, I'm seeing |
We don't have an About the concept of extended, the API seems very declarative to me; I think Three.js should make things easier for this. Using We could warn when a tone mapping and output color space configuration isn’t compatible with HDR instead of recreating an public |
Related issue: #29573 (comment)
Description
Add a basic example to test and demonstrate Extended SRGB ColorSpace via High Dynamic Range in WebGPU.
Heavily inspired by @greggman's HDR demo https://github.com/greggman/HDR-draw
Example:
https://raw.githack.com/renaudrohlinger/three.js/utsubo/feat/hdr-example/examples/webgpu_hdr.html
IMG_1211.MOV
This contribution is funded by Utsubo