pmndrs / drei

🥉 useful helpers for react-three-fiber
https://docs.pmnd.rs/drei
MIT License
8.27k stars 682 forks source link

SSAA / TAA postprocessing makes scene darker #1601

Open Russo-creation opened 1 year ago

Russo-creation commented 1 year ago

Hi,

I tried to add SSAA and TAA to the project but I noticed that the more Sample Level I'm setting the screen is getting darker - this happens with the fresh version of r3f. in three.js examples it works good TAA https://threejs.org/examples/webgl_postprocessing_taa.html and SSAA https://threejs.org/examples/?q=ssaa#webgl_postprocessing_ssaa

Here is the codesanbox fiber 8.13.3: https://codesandbox.io/s/enter-portals-forked-5vpqtn?file=/src/postProccesing.js:456-457

image

and to compare code sandbox fiber 8.12.0: https://codesandbox.io/s/blazing-fire-mz5fgs?file=/src/postProccesing.js:531-532

image
CodyJasonBennett commented 1 year ago

That is coming from Drei which you can find by updating Drei in the latter demo. R3F does not change how three.js works. I found that exactly version 9.65.0 and up could reproduce this behavior on CSB, but I'd try offline since they don't handle dependencies well to begin with.

Russo-creation commented 1 year ago

hmm... from what I see in codesanbox it looks like it works below 9.65.0 but when I done this locally for drei below 9.65.0 (for instance I cheked: 9.59.1, 9.57.3) behaves same - screen is darker. @CodyJasonBennett maybe it comes form three-stdlib instead of drei?

Russo-creation commented 1 year ago

Here I prepared repository to reproduce https://github.com/Russo-creation/ssaa-bug with dependency list

Russo-creation commented 1 year ago

After couple of tests with three-stdlib (local version)- it looks like screen is not going darker depending on the Sample Level with "three-stdlib": "^2.22.5" I can't test versions 2.23.X because I'm getting an errors. Also other Post-proccesing effects like unreal bloom is not working with mentioned version of three-stdlib

it's still Darker (SSAA have inpact on colors but differently) as it not suppose to be - antyaliasing should not affect on the colors

with SSAA

image

Without postprocessing

image
CodyJasonBennett commented 1 year ago

Thanks for the thorough reproduction, I'll take a look.

CodyJasonBennett commented 1 year ago

I released three-stdlib@2.24.2 with https://github.com/pmndrs/three-stdlib/pull/277 which should address darkening. Remaining banding I can only attribute to undersampling and/or lack of precision. I don't believe we use fp16 there yet.

Russo-creation commented 1 year ago

Thanks for the fix- sampleLevel it's not affecting on scene darkening, but SSAA is still affecting on the colors (is adding more contrast or something as in screenshots above) along with unrealBloom scene is glowing a lot even when threshold is set above 1.

It would be cool to have it fixed because it makes impossible to smooth Alpha hash (feature from three r 154) https://threejs.org/examples/?q=has#webgl_materials_alphahash for improving quality and react-three/postprocessing (vanruesc) does not support this type of antyaliasing.