-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Implement support for FSAA in combination with post-processing #15392
Conversation
8210583
to
1ee73c1
Compare
oh nice. Going to try today. |
Mostly works, but some weird flashes as you move around.
Here's a video: Happen with bloom enabled and easier to see a bit further away distances (300+ or so) Update: happens with NVidia and Intel on Linux with GLX or SDL. A nice feature of this is that MSAA finally works with SDL. |
I'll note that now it makes sense to enable MSAA (for geometry aliasing) and FXAA (for texture aliasing) |
The code looks "right". I had started down that rabbit hole a few months ago, and about 70% as far as you got (all the enum/API changes in Irrlicht). |
Can reproduce. With some testing code to compare the bloom texture and the color texture (2868e92): 1st screenshot color texture, 2nd screenshot bloom texture, 3rd screenshot final rendered result If you zoom in, you can see that there are a few #ffffff and #00000 pixels sprinkled across the color texture. The bloom then goes crazy on the #ffffff pixels. I have no idea 1) where the #ffffff pixels are coming from or 2) why the bloom reacts like that |
I see nothing wrong with the code, especially the blitting. I tried gl.LINEAR (with only the color texture), but the effect remains the same. It's almost like there's something wrong with the sampling. I wonder if these black and white pixels are there without PP as well, or the way MSAA is enabled with GLX, we just do not notice them without bloom. The fact that these artifacts vanish with MSAA = 16 seems to point in that direction too. |
Also... When you use SDL (which does not support start-up MSAA in Irrlicht), MSAA now depends on PostProcessing. |
One more. I tried the on-start MSAA with GLX... It produces the same weird pixels. See also: https://stackoverflow.com/questions/49063871/deferred-msaa-artifacting |
SDL with normal MSAA works fine for me, also on the "master" branch (obviously only as long as post-processing is disabled, 3d_mode is "none" and undersampling is 0) Fedora Workstation 40, "NVIDIA GeForce GTX 1080 Ti" |
Weird. Also Fedora 40, Luanti build from master today. With this PR MSAA work with NVidia, only when PP is enabled. What's nice is that I can switch MSAA at runtime. So two suggestions:
|
8c1b033
to
04d59de
Compare
No, MSAA is not inherently a part of the post-processing pipeline nor does it belong into the "Effects" section. It not working without post-processing on your setup doesn't justify moving it into the post-processing section.
Sounds reasonable in general, but not something I want to do in this PR (to keep the scope reasonable) |
This PR should now be ready for review. |
The bloom flashing is still there. Should we document that bloom is incompatible with MSAA (in settings other than 16)? |
Sure, can't hurt to document it. 4d4e455 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
As I said I got about 70% there (without ChatGPT :) ), and had made most of the same interface changes.
The main step I was missing how to do the actual resolve myself.
And works fine on my box (with Intel or NVidia drivers)
@grorp did you see my comment about avoiding the flashing? |
Hmm yes, but I still don't think a change to the bloom stuff should be included in this PR. |
I've noticed those white spots before (without this PR) with flat surfaces, I do not think that's new. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
works
Oh yay, on my phone it's broken when I remove this code and post-processing and MSAA are enabled: with
It works again if I remove this code too: and results in a significant performance improvement over the current version of this PR. Anyway, not something I want to investigate now. |
https://docs.gl/es3/glTexStorage2DMultisample
https://registry.khronos.org/OpenGL/extensions/EXT/EXT_texture_format_BGRA8888.txt: |
diff --git a/irr/src/OpenGLES2/Driver.cpp b/irr/src/OpenGLES2/Driver.cpp
index 3c034522c..f33bc61d1 100644
--- a/irr/src/OpenGLES2/Driver.cpp
+++ b/irr/src/OpenGLES2/Driver.cpp
@@ -64,7 +64,7 @@ void COpenGLES2Driver::initFeatures()
TextureFormats[ECF_D24S8] = {GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8};
if (FeatureAvailable[IRR_GL_EXT_texture_format_BGRA8888])
- TextureFormats[ECF_A8R8G8B8] = {GL_BGRA, GL_BGRA, GL_UNSIGNED_BYTE};
+ TextureFormats[ECF_A8R8G8B8] = {BGRA8_EXT, GL_BGRA, GL_UNSIGNED_BYTE};
else if (FeatureAvailable[IRR_GL_APPLE_texture_format_BGRA8888])
TextureFormats[ECF_A8R8G8B8] = {BGRA8_EXT, GL_BGRA, GL_UNSIGNED_BYTE};
or diff --git a/irr/src/OpenGLES2/Driver.cpp b/irr/src/OpenGLES2/Driver.cpp
index 3c034522c..9f212b57d 100644
--- a/irr/src/OpenGLES2/Driver.cpp
+++ b/irr/src/OpenGLES2/Driver.cpp
@@ -64,7 +64,7 @@ void COpenGLES2Driver::initFeatures()
TextureFormats[ECF_D24S8] = {GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8};
if (FeatureAvailable[IRR_GL_EXT_texture_format_BGRA8888])
- TextureFormats[ECF_A8R8G8B8] = {GL_BGRA, GL_BGRA, GL_UNSIGNED_BYTE};
+ TextureFormats[ECF_A8R8G8B8] = {GL_BGRA8_EXT, GL_BGRA, GL_UNSIGNED_BYTE};
else if (FeatureAvailable[IRR_GL_APPLE_texture_format_BGRA8888])
TextureFormats[ECF_A8R8G8B8] = {BGRA8_EXT, GL_BGRA, GL_UNSIGNED_BYTE};
make all textures turn black, if that's what you mean |
works on my machine™
how implementations are supposed to deal with this is a mystery to me anyway this is not a thing for this PR. |
fixes #14285, minetest/irrlicht#286
Screenshot showing it in action:
"master" branch: post-processing, volumetric lighting, FSAA enabled but doesn't work

this PR: post-processing, volumetric lighting, FSAA works

P.S. I have used "ChatGPT" as a source of information/answers while working on this
To do
This PR is a Ready for Review.
GL error when FSAA is enabled without restart with "opengl" video driver?fixed by 0d3a93d in this PRGL warning "framebuffer object is unsupported because the depth/stencil attachment is mismatched" with post-processing with "opengl3" video driver (FSAA state and/or FSAA state on startup may matter)already happens before this PR, "fixed" in PR Get rid of depth buffer workaround in the render pipeline code #15407 (the code triggering the warning was only used due to the workaround, no its no longer used)black screen with post-processing with "ogles2" video driver on desktopalready happens before this PR, fixed in PR [no sq] Fix ECF_D32 support in ogles2 video driver #15396How to test
Enable post-processing and FSAA, see that FSAA works.