Skip to content
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

WebGLRenderTarget and scene.background has tonemapping issues #29096

Open
drcmda opened this issue Aug 9, 2024 · 5 comments
Open

WebGLRenderTarget and scene.background has tonemapping issues #29096

drcmda opened this issue Aug 9, 2024 · 5 comments

Comments

@drcmda
Copy link
Contributor

drcmda commented Aug 9, 2024

Description

scene.background = new THREE.Color("white")
...
gl.render(scene, camera)

produces a white background, i don't think three applies tm here

but the same thing on a fbo (mapped to a mesh-material) produces a gray background, presumably because threejs then tonemapps the result

state.gl.setRenderTarget(fbo)
state.gl.render(scene, camera)
state.gl.setRenderTarget(null)
...
const plane = new THREE.PlaneGeometry/(
const material = new THREE.MeshBasicMaterial({ map: fbo.texture })
const mesh = new THREE.Mesh(plane, material)

in this image you have the rendertarget in the middle, with a white scene.background just like the rest of the scene, but it appears gray, not white.
Screenshot 2024-08-09 at 12 05 01

tonemapping with envmap background is fine

Screenshot 2024-08-09 at 12 33 13

tonemapping with a background white plane instead of scene.background is fine

Screenshot 2024-08-09 at 12 35 38

Live example

Screenshots

No response

Version

r0.167.0

Device

Desktop

Browser

Chrome

OS

MacOS

@hybridherbst
Copy link
Contributor

@drcmda
Copy link
Contributor Author

drcmda commented Aug 17, 2024

thanks for the context @hybridherbst this at least explains what is going on.

@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 18, 2024

I'm not sure it was ever discussed before but maybe it would be a solution for WebGLRenderer: Instead of using gl.clear(), couldn't we apply a clear color similar to a textured background by rendering a colored (full screen) quad? In this way, background colors behave like textured backgrounds or skyboxes.

The colored plane mesh would be pushed at the very beginning of the opaque render list and writes no depth. In this way, subsequent render items shouldn't be affected. Does somebody see an obvious flaw compared to gl.clear()?

There is also a related issue with fog: #26857 (comment)

At least with WebGPURenderer all of these issues are already solved. Hopefully we get this fixed in WebGLRenderer as well.

@hybridherbst
Copy link
Contributor

Rendering a full screen quad is usually slower than gl.clear() on tiled GPUs (so, mobile), this would probably reduce framerate.

@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 18, 2024

I wonder if the performance degradation would actually be noticeable as a lower frame rate. This is something that should be tested if the approach is given a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants