drei icon indicating copy to clipboard operation
drei copied to clipboard

Updating Effects + disableGamma for recent three.js versions

Open donmccurdy opened this issue 2 years ago • 2 comments

Context:

  • https://discourse.threejs.org/t/i-still-dont-get-how-unrealbloompass-works/57843/2

  • three version: r158

  • @react-three/drei version: v9.88.11

Problem description:

By default <Effects /> adds a GammaCorrectionShader. In recent versions of three.js it would be preferable to use OutputPass, and it may confuse users who intentionally use OutputPass or GammaCorrectionShader that they have to do disableGamma={true} to avoid redundancy.

Relevant code:

https://github.com/pmndrs/drei/blob/1169c02fcfd1151fa08effb4ca7215f91b140f53/src/core/Effects.tsx#L92-L93

Suggested solution:

Perhaps Effects.tsx could scan its passes, and append GammaCorrectionShader or OutputPass only if neither is present? Would it also be reasonable to replace GammaCorrectionShader with OutputPass in a future release?

donmccurdy avatar Nov 07 '23 02:11 donmccurdy

I realize I haven't implemented OutputPass in pmndrs/three-stdlib yet. I'll do that now.

Is it breaking to switch from GammaCorrectionShader to OutputPass? We're not pulling from three.js so it would be strictly behavioral. I'd need to add fallbacks for older color-management/encoding workflows if we go this way.

CodyJasonBennett avatar Nov 08 '23 07:11 CodyJasonBennett

The differences are:

  • GammaCorrectionShader applies the Linear-sRGB to sRGB transform unconditionally
  • OutputPass applies color space and tone mapping according to the current values of renderer.outputColorSpace and renderer.toneMapping

Strictly that is a breaking change. The impact should be fairly limited in the newer three.js versions, where .outputColorSpace / .outputEncoding defaults to sRGB, as R3F has done by default for a while. OutputPass was added in r153, and I don't think it is currently compatible with three.js versions before r152.

donmccurdy avatar Nov 08 '23 13:11 donmccurdy