简体   繁体   中英

How to achieve better anti-aliasing in GlControl in OpenTK?

OpenTK offers two approaches how to use OpenGL:

  1. GlControl which is standard WinForms control, and
  2. Native window with OpenGL context.

I am using the GlControl and the FSAA seems to be low quality. I am developing an application with many controls around the OpenGL control so I am kind of forced to use GlControl.

Is there any way to achieve better anti-aliasing (for example super-sampling) in the GLControl? In my application I am rendering a lot of stuff that has pixel or even sub-pixel sizes and current FSAA is not dealing with it well.

I saw a parameter in the constructor that specifies number of buffers, would it be somehow feasible to set this number to (let's say) 6 and render 4 samples, combine them to 5th buffer and swap with 6th? Or what would be the easiest way how to implement SSAA by myself?

This is how am I creating the GlControl, the 8 is number of samples but for FSAA:

glControl = new GLControl(new OpenTK.Graphics.GraphicsMode(32, 24, 0, 8));

UPDATE: Here is a print-screen with 8x FSAA of GlControl. I checked my driver settings and it says Antializaing mode = Application controlled .

别名示例

UPDATE2: Ok, this is prrobably embarassing, there was another option in the NVIDIA Control Panel called Antialiasing - transparency which was set to Off . I did not pay attention because I thought that's some alpha-blending stuff but I was wrong. I set it to 8x (supersample) and now the GlControl is indeed 8xSSAA.

别名固定

There are two common hardware-based antialiasing methods: MSAA (multisample antialiasing) and SSAA (supersample antialiasing). Both methods are subcategories of FSAA (aka fullscreen antialiasing).

Which method is used depends on your GPU and driver settings. By default, all modern GPUs will give you MSAA. You can override this in the driver control panel.

In other words, this line:

glControl = new GLControl(new OpenTK.Graphics.GraphicsMode(32, 24, 0, 8));

will give you 8x FSAA on any modern GPU. This can be either MSAA (default) or SSAA, depending on your driver settings.

If you need more control on the antialiasing implementation, create a GLControl without antialiasing and render to a FBO with the exact settings you need.

More information:

  1. OpenTK FBO example
  2. WGL_ARB_multisample
  3. WGL_ARB_create_context
  4. GL_ARB_framebuffer_object
  5. OpenGL 4.4 specification
  6. OpenGL 4.4 reference card

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM