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

After the 171 version used in the postprocessing the renderer. ToneMappingExposure affect the background #30202

Closed
lwaier opened this issue Dec 25, 2024 · 2 comments
Milestone

Comments

@lwaier
Copy link

lwaier commented Dec 25, 2024

Description

After the 171 version used in the postprocessing the renderer. ToneMappingExposure affect the background
image
image

To solve this problem and keep the background intact I implemented a version using shaderPass
The idea is:
The background is hidden and stored in renderTarget before outputPass processing and then merged with baseTexture through shaderPass that I wrote after outputPass processing
image

But the effect of this fusion is still not as transparent as the good feeling of the previous version of 151
The following is the actual effect comparison diagram in the project: the top is 151 and the bottom is 171 (after using the above ideas).
image
image

Is there a better way to solve the impact of renderer. ToneMappingExposure on the background

Reproduction steps

  1. Find any webgl_postprocessing page in the examples 。Refer to webgl_postprocessing_outline
  2. Add a background and change renderer. ToneMappingExposure
  3. Then you will find that the background follows changes

Code

const texture = new THREE.TextureLoader().load('./textures/2294472375_24a3b8ef46_o.jpg')
scene.background = texture
renderer. ToneMappingExposure = 10 //OR renderer. ToneMappingExposure = 0

Live example

https://github.com/mrdoob/three.js/blob/dev/examples/webgl_postprocessing_outline.html
https://threejs.org/examples/?q=outlin#webgl_postprocessing_outline

Screenshots

No response

Version

r171

Device

Desktop

Browser

Chrome

OS

Windows

@lwaier
Copy link
Author

lwaier commented Dec 25, 2024

shaderPass source code:

const outputPass = new OutputPass();
composer.addPass(outputPass);

window.finalPass = new ShaderPass(
new THREE.ShaderMaterial({
uniforms: {
baseTexture: { value: null },
background: { value: null }
},
vertexShader: `varying vec2 vUv;

      void main() {

        vUv = uv;

        gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );

      }`,
				fragmentShader: `
      
      #include <common>

      uniform sampler2D baseTexture;
      uniform sampler2D background;
      varying vec2 vUv;

      void main() {
			vec4 baseColor = texture2D(baseTexture, vUv);
			vec4 backgroundColor = texture2D(background, vUv);

			gl_FragColor = mix(backgroundColor, baseColor, baseColor.a);
		
      }`,
				defines: {}
			}),
			"baseTexture"
		)

		composer.addPass(finalPass)

@Mugen87
Copy link
Collaborator

Mugen87 commented Jan 4, 2025

The title is a bit misleading since no issue has been introduced with r171. If you upgrade from r151, then you will notice OutputPass which has been added with r153. This module fixed color space conversion and tone mapping in the post processing pipeline.

What you see is the expected behavior. Tone mapping should affect the entire image including the background. The same holds for the output color space conversion. Even if earlier versions of three.js looked "better" from your point of view it must be noted that the post processing pipeline was incorrect.

If you are not happy how the default works, you can use any custom pass setup as you like.

@Mugen87 Mugen87 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 4, 2025
@Mugen87 Mugen87 added this to the r173 milestone Jan 4, 2025
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

2 participants