-
-
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
Temporal Anti Aliasing (TAA) rounding errors over accumulation #9051
Comments
Using |
Yes. Yes. And don't forget lower memory usage (by 2x or 4x compared to half / float.) :) |
BTW the bug that is causing this behavior is because of the way the intermediate TAA accumulated frame is blending with the final frame. It should be using the sampleWeight that is computed from the accumulated weights. I suspect you didn't update this line of code to use actually assumulated weights -- if you blend in the intermediate frame with a weight that isn't representative of the accumulated weights you used to create it, then it will be wrong: |
To be clear, this line here: Assumes that the accumulatedWeight is not created by weights that vary on a per frame basis. Thus it needs to use what is truely accumulated by the varying weights that are used to avoid the rounding errors. |
I also tried that. I deactivated the weighting in the inner loop therefore since it should also be possible to do it in the "outer" loop, meaning over several frames. My code is
Note that the conditions are related to the accumulateIndex, rather than relying on accumulationWeight like it was done before... So, how to modify the accumulationWeight in an unbiased fashion? |
The rounding happens in the inner loop. |
I reassembled the TAARenderPass to work around the biasing problem. It now copies a new sample with
Have a look here: Let me know what you think, this can be turned into a pull request then |
This is nice and I guess you adapted it to the new clearColor, clearAlpha support at I added in ManualMSAARenderPass just recently? Sweet. |
I'm referring to this recent modification of ManualMSAARenderPass: #9124 |
Thanks. I tried to incorporate clearColor support, but it doesn't work out as i think it should work. Look at the refreshed example. In CSS, i load an image and the clearColor i've set is red with 0.5 alpha. I think, the meshes should have a color not influenced by clearColor, whilst the parts that are not shaded would turn slightly red. Doesn't work... Full code is here, the essential part is here:
|
@bhouston any clues? |
Setting blending mode to NormalBlending did the deal for me: now the clearColor and clearAlpha given to the renderer is used. The refreshed example can be visited here.
|
@throni3git Nice! BTW if we want to have unlimited number of sampels or break out of the fixed pre-set number of MSAA samples we are using, we could convert to using Halton sampling: #9256 |
This does not seem to work when the Pass is used in a EffectComposer chain with other effects following. Any idea? |
You would have to jitter the camera through the whole effect composer chain and accumulate. I've been meaning to implement this for a while but haven't had the time or a paying client ask for this effort. |
I didn't test it for a more complex effect chain. What effect are you trying to use? Do you have a fiddle for that? |
See https://jsfiddle.net/rayfoundry/jxku52re/ Took me a while to assemble something. It's basically ThreeJS r79 with the stock examples + your TAA implementation. I've added two posteffects after the TAA step. The issue is that irrespective of which effect is first after TAA it "bleeds". P.S.: The cube rotates after 2 seconds, which deactivates the TAA accumulation. It's still sampling at level 2 though and using TAA. Just without accumulate. The display is correct then. |
I found that the issue with stacking effects using the TAARenderPass by @throni3git is fixed if the holdRenderTarget is copied always to the writeBuffer, not just when it is accumulating samples, so the other effects in the stack are always applied on top of the clean accumulated image, instead of the result of the prev frame stack. I have tested it in a complex scene with RGBShift and the new UnrealBloom and works perfectly. Here is a quick fiddle based on @Rayfoundry 's fiddle and the original TAA example: |
Rounding errors should not happen anymore because half float render targets are now the default in |
Description of the problem
I've discovered there is an implementation of MSAA accumulating over several frames, which is a nice thing. The example to this (webgl_postprocessing_taa) shows the beauty of this.
When i applied it to an application i work on, the surpression of the accumulated rounding errors didn't seem to work, when i use MeshPhongMaterial with it. That is because it is not implemented in the accumulating version of TAARenderPass. So i decided to integrate it myself, but unluckily there is still an issue when the accumulation is going on. The rendered frames go darker inbetween and recover light when the accumulateIndex reaches 32. Please check out my version here.
The inner loop of THREE.TAARenderPass.render in my version is
By the way, can we further surpress the rounding error artifacts? The sphere looks somewhat quantized in the darker areas.
Greetings, Thomas
Three.js version
The text was updated successfully, but these errors were encountered: