I have an issue using SMMAPass with a renderer set with alpha: true.
The borders between solid/transparency have white edges when drawn over a light color background (does not happen over a black background). I found that SMMAShader line 442 does gamma correction and commenting that part seems to resolve my issue
Is it correct to comment those lines since i’m already using OutputPass?
The strange thing is that if I remove SMAAPass and use a multisampled render target in EffectComposer, I get again the white edges (and quality is lower that default canvas antialiasing)
I don’t see a difference in color with and without these lines.
According to the comments of the original HLSL source file, SMAA works in gamma space. So the lines seem to apply gamma, perform the mix and then undo the gamma.
So the unmodified SMAAShader does require OutputPass.
Okay, there is actually an issue in SMAAPass that I have fixed in the following PR.
You can apply the same fix now by setting the needsSwap property of SMAAPass to true. You should then use the same pass order like in the example (meaning OutputPass comes last).
By setting needsSwap = true I can use SMMAPass before OutputPass. However I still get a white outline around objects adjacent to transparent webgl background (grey background is set in html):
Unfortunately no, I get the same result of the first image with a white edge between objects and background.
To summarize:
When SMAA shader input data is sRGB (smaa is lat pass) and inline gamma conversion is removed result is better and transparency seems to work
When SMAA shader input data is linear (output pass is last) there is a white outline and result is worse, even when commenting the inline gamma conversion
I’ve updated the SMAA example in the dev branch so it is easier to debug the technique. If you disable auto-rotate and toggle SMAA, you can better see the effect of the anti-aliasing. After the last PR, SMAA definitely works like when it was originally added in 2016. That said, the implementation might have an issue right from the beginning.
SMAA is a multi-pass technique and the first two passes should operate on non-sRGB data. If you put SMAAPass last, this isn’t true anymore since the read buffer for SMAA (the result of the previous output pass) is in sRGB color space.
The original author of SMAAShader added the inline color space conversion in SMAANeighborhoodBlendingPS() to make SMAA work with linear input.
At default it doesn’t show up, but if I stop rotation at the following angles:
child.rotation.x = 0.24;
child.rotation.y = 0.49;
I can see intense aliasing artifacts:
And I have set needsSwap = true in the SMAAPass.js to be sure.
EDIT:
In order to be able to see the artifacts, I think it would be better to orbit slowly in the examples (and stop at will) around the object using the mouse, instead of having them rotating.
https://jsfiddle.net/b8yw57vr/
It seems the relevant line is renderer.setClearColor(0, 0);
Creating the renderer with { alpha: true|false} does not make any difference
@dllb Thin white lines on a black background is challenging for any AA technique to process. It’s not surprising that SMAA does not produce good results.
I tried copy/paste your lines but I got a compile error. So I substituted sRGBTransferOETF with its implementation and got this image (alpha is better but antialias still not good):
I’m using postprocessing (ssao) and my goal is to have a good antialias without affecting performance too much. I first tried using a multisampled render target (4 samples) with this result:
The white outline is present here too, and antialias is worse than when using the renderer without effect composer. Should I open another thread for this topic?
@dllb Keep in mind that SSAA renders the entire scene multiple times (depending on how many samples you use) whereas SMAA as FXAA requires only one beauty pass. So it’s always a tradeoff between quality and performance.