-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
Renderer: Use output color space conversion only when rendering to screen. #28909
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
@Mugen87 (edited) Can you please summarize the policy for both Which renderer properties should only apply when rendering to the screen -- in your view? |
At some point, I would be interested in making this configurable. Users may need to do these transforms when drawing to a render target, without the cost of an additional pass. Would something like |
@@ -457,7 +457,7 @@ class Renderer { | |||
const { currentColorSpace } = this; |
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.
currentColorSpace
already does that, I was thinking of renaming it to targetColorSpace
, currenty this resolve #28909 (comment) issue too.
When a render target is marked as If you want to force a color space conversion when rendering into a render target, it's maybe best to introduce a new property and don't use |
Yes, I think the current behavior for color space conversion is probably enough, no need for a property to force that. But we need tone mapping to happen before the color space conversion, and that's hard-coded off for render targets. EDIT: I suppose we could just ... respect tone mapping if the target is SRGB8_ALPHA8, no option needed? That's more or less what Blender does – applying the output transforms automatically to PNG exports but not EXR exports, for example. |
I'm afraid this could have side effects. Think of an app that configures tone mapping on renderer level and now loads an sRGB equirectangular texture. The renderer should automatically convert it to the cube map format. If the cube map render target is marked as RGBA8 + sRGB, there should be no tone mapping in place since the source is RGBA8 + sRGB. I don' think it's possible to figure out an automatism that selectively applies tone mapping whenever rendering to |
Good example, and I agree that we can't and shouldn't try to automatically handle every case. I guess I was thinking of that suggestion as making it "less automatic" than it is now, automatically disabling tone mapping only for floating point render targets, rather than for all render targets. The caller in the cube map scenario would need to do this... three.js/src/nodes/lighting/AnalyticLightNode.js Lines 224 to 232 in ffef510
... which I'm inclined to say should be best practice anyway, rather than assuming that render targets will always ignore the tone mapping setting. But without that, I suppose an explicit option would be required. |
I'm okay with revisiting this topic and maybe define a new policy when tone mapping and color space conversion is applied for render targets. But this is something I would discuss in a separate issue. Would that be okay for everyone? This PR is just intended to make |
Yes, sorry for side-tracking – that's fine with me, I'll follow up elsewhere, and thank you! |
@Mugen87 I do not think there is an existing policy that is being adhered to consistently by either the code or the docs. But I would like to check. If you would answer my question above, I would be grateful, and I will continue the discussion in another thread if needed. |
I thought I did in #28909 (comment). Is there something missing from your point of view? |
OK, I'll state what I think your policy is... WebGLRenderer
WebGPURenderer I assume you want the behavior to be the same as it is for WebGLRender. // Classes such as |
This statement in the docs is wrong. When a render target is set, the output color space is always three.js/src/renderers/webgl/WebGLPrograms.js Line 201 in 460efde
In other words, |
Minor: I think we'd like this to be
I think it's OK for particular classes to make different decisions than the renderer defaults ... but whether classes like Reflector are making the decisions we'd prefer, currently, I'm not sure. |
The internal render target of reflector is In |
Fixed #28826.
Description
This PR ensures output tone mapping and color space conversion follow the same policy. They are only used when rendering to screen.