-
-
Notifications
You must be signed in to change notification settings - Fork 35.3k
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
MSAA does not always work when doing RTT. #26954
Comments
Just to clarify: There are no issues when setting The problem is the title of the issue is a bit misleading since RTT with multisampled render targets should work (see https://threejs.org/examples/webgl2_multisampled_renderbuffers). |
Wait, I can see there is aliasing when using Here is a simplified version of your fiddle reproducing the issue: https://jsfiddle.net/n41advb2/1/ What I can see is that when reducing the ambient light intensity to a more common value, the aliasing on the right cube disappears: https://jsfiddle.net/n41advb2/2/ So this is maybe some sort of precision related issue 🤔 . BTW: The aliasing is unrelated to |
It is a bit subtle but switching to standard material shows something even in the official example: The lines on the right seem to me a bit "fatter", also red color seems slightly different |
The color differences you see is related to fog and color spaces. It is discussed in #24362. |
Interesting! The aliasing also disappears when using My theory is that what you see is a special case related to value ranges that MSAA can't handle. You don't see it when rendering to the default framebuffer because values get clamped (the default framebuffer is RGBA8). When using render targets with higher precision (FP16 or FP32), the clamping does not happen and MSAA can't mitigate the aliasing. |
Good catch! I changed the original fiddle to use Notable changes : |
Using MSAA when values can be large can be problematic. One very bright sample can dominate the result. See https://mynameismjp.wordpress.com/2012/10/24/msaa-overview/, particularly the section "Working with HDR and Tone Mapping" |
The other problem in this topic is related to premultiplied alpha. Similar to @WestLangley We have discussed this topic in the past so I want to ask if it's okay with you to keep both passes consistent and premultiply alpha (see #26179). |
@Mugen87. Agreed, we should be consistent. Also, I always prefer adding an inline comment for clarity in such cases. |
@LR17 In your fiddle, you have added premultiplied alpha right after the sampling of the texture. Meaning before tone mapping and sRGB color space conversion. Shouldn't premultiplied alpha be the last step in the fragment shader? |
I did find that aliasing was going away only if premultiplying alpha before tonemapping and color space conversion. Here the same advice is given, although I really don't know :) |
After tonemapping and before colorspace conversion seem slightly better in the project I'm working on |
This needs more investigation especially since enabling premultiplied alpha in |
@WestLangley Something still confuses me. In this issue and in #28331 you only get a visual correct result when premultiplying alpha happens at a specific place. In the built-in shaders, the Premultiplying alpha before tone mapping and color space conversion produce the expected result: https://jsfiddle.net/Lwsavq7e/ Do you know why this happens? |
The input to In any event, I don't think you are getting "the expected result"; I think application of the OETF is just making the color lighter, and thus obfuscating the issue. I think application of the OETF to RGB values premultiplied by alpha is not correct. |
@Mugen87 I have another question. But if use using EffectComposer + RenderPass + OuputPass, the output color is rgb(104,104,104) ,see https://jsfiddle.net/trigger0607/ars47no9/7/ |
see #27184 |
Description
I would expect to have same output image when rendering to screen with
antialias: true
or when using EffectComposer + RenderPass + OuputPass and a render target with 4 samplesReproduction steps
Open https://jsfiddle.net/5kczseda/1/.
The left cube is rendered to screen while the right cube uses postprocessing and has aliasing
However I found that this behaviour changes depending on material type and clear color opacity. You can reproduce the conditions by using the checkboxes in the gui. The "appyPatch" checkbox premultiplies alpha inside OutputPass shader, before tonemapping and colorspace conversion.
I would also like to point out that setting the clear color on the RenderPass produces a different color
Code
See the live example
Live example
Screenshots
Version
157
Device
No response
Browser
No response
OS
No response
The text was updated successfully, but these errors were encountered: