3

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.

Aliasing example

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.

Aliasing fixed

7
  • In the code, I see no great diff between context creation for win and ctl (some info) .
    – j-p
    Apr 13, 2014 at 23:03
  • @j-p Yeah, the constructors have basically the same signature, but they do very different things. I am wondering why the GlControl does not provide multi-sampling but the window does, what's the deal breaker.
    – NightElfik
    Apr 13, 2014 at 23:58
  • WinGLContext seems to be common in OpenTK internals for win and ctl, but u may be right there's WinGLNative, tired to check deeper...
    – j-p
    Apr 14, 2014 at 0:09
  • You generally want to control the number of MSAA samples rather than buffers. More imoortantly, however, you need to enable Multisample rasterization - allocating storage for samples alone will do nothing (same story as the depth buffer). Apr 14, 2014 at 16:32
  • 1
    Also, the sample count in any standard GL framework should be MSAA; GL has no core suport for configurable SSAA. The modern approach to all of this is actually to use a multisampled FBO and then blit its contents into your window's framebuffer when drawing is complete. The FBO approach is MUCH more flexible - you don't have to destroy your render context to change anti-alias quality, for example. Apr 14, 2014 at 16:43

1 Answer 1

11

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
3
  • I see, that was my misunderstanding of the terminology, thanks for clarification. I've edited the question a bit to address it. My question is then how to achieve better quality of anti-aliasing? It seems that by default the GlControl does some post-process of blurring the edges that does not look very good.
    – NightElfik
    Apr 19, 2014 at 19:52
  • Can you provide a screenshot? It may be that the driver is opting to use FXAA (Nvidia) or MLAA (Ati) instead of higher-quality MSAA/SSAA. This is a driver setting that can only be changed through the driver control panel. GLControl has no control over this (and certainly doesn't perform any postprocessing on its own.) Apr 19, 2014 at 22:46
  • And you were indeed right, it was driver setting in NVIDIA Control Panel. Thanks!
    – NightElfik
    Apr 21, 2014 at 7:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.