AlexvZyl / NativeFramework

💡 A GPU-accelerated native application framework, with performance and scalability at its core. Written in C++ using GLFW, OpenGL and dear imgui.
4 stars 1 forks source link

MSDF Text Scaling #84

Open AlexvZyl opened 2 years ago

AlexvZyl commented 2 years ago

When zooming out in the OpenGL scene the edges of blended entities get jagged edges. This is not a MSAA issue, but I am pretty sure it has something to do with blending,

Smooth text: image

Jagged when zoomed out: image image

AlexvZyl commented 2 years ago

@Cullen-Enerdyne If you are wondering why the text is not smooth.

AlexvZyl commented 2 years ago

This happens due to the way MSAA is implemented with FBO's. Blitting a texture from a multisampled one to a non multisampled one does not allow the use of GL_LINEAR and instead uses GL_NEAREST. This is temporarily improved by increasing the MSAA level to 32. This is a very large number and will impact performance.

I think we will have to implement a different AA method.

Cullen-Enerdyne commented 2 years ago

@AlexEnerdyne, have you looked at FXAA to see how much it would take to implement that?

Cullen-Enerdyne commented 2 years ago

Are you sure this isn't an issue caused by downsampling? I know gaussian filters and the likes are usually used when downsampling textures.

AlexvZyl commented 2 years ago

Yes, it basically downsamples when rendering to the screen. But I have an idea to bypass it. MSAA is the simplest and least efficient of the AA methods, so it was anyway a temporary solution.

Will look at FXAA.

AlexvZyl commented 2 years ago

A possible solution to this problem, is instead of blitting the MSAA texture to the render texture attachment, you render the MSAA texture onto a quad in the render texture attachment. This will actually improve performance as well! (It seems like blitting is an expensive operation)

AlexvZyl commented 2 years ago

It does not seem like #90 helped at all. It could be that I am not sampling correctly in the shader, causing it to behave like GL_NEAREST.

MSAA x8, rendering as texture. image

MSAA x8, blitting. image

MSAA x16, rendering as texture. image

MSAA x16, blitting. image

Cullen-Enerdyne commented 2 years ago

The text is looking much better on my screen at low zoom levels.

AlexvZyl commented 2 years ago

The text is looking much better on my screen at low zoom levels.

That is due to the higher MSAA value, not improved rendering :(

AlexvZyl commented 2 years ago

95 Could possibly help with this.

AlexvZyl commented 2 years ago

Note: https://www.youtube.com/watch?v=im5Exz4U3dE, http://andersriggelsen.dk/glblendfunc.php

AlexvZyl commented 2 years ago

MSAA has been removed. We should implement something like FXAA/TSAA.

AlexvZyl commented 2 years ago

Reopening - this is not an MSAA issue, but rather MSDF (I think).

AlexvZyl commented 2 years ago

This was fixed with #337? Will check when we add MSAA again.

AlexvZyl commented 2 years ago

397 😭

AlexvZyl commented 2 years ago

Pretty sure this has something to do with how the MSAA is being resolved and how we render MSDF.

AlexvZyl commented 2 years ago

@Cullen-Enerdyne I think this issue deserves the label.