florianblume / qt3d-widget

Qt3D Widget. Works by rendering to an offscreen texture in Qt3D and using that texture in a QOpenGLWidget.
GNU General Public License v3.0
35 stars 6 forks source link

Anti-aliasing #3

Closed nikkymen closed 3 years ago

nikkymen commented 3 years ago

Thanks for the code!

I noticed that your solution does not use anti-aliasing.

Objects appear smoother when I using Qt3DExtras::Qt3DWindow

Qt3DWidget: Qt3DWidget

Qt3DWindow: Qt3DWindow

Any thoughts on how this can be done?

florianblume commented 3 years ago

Hey, thanks for your interest :)

I'm aware of this issue and tried to solve it once already but didn't get it to work. My idea was to use a multisampling texture for offscreen rendering and a second normal texture and use QBlitFrameBuffer to get an antialiased image.

If you have an idea feel free to create a pull request :) Maybe I'll get round to checking out this issue the next days.

florianblume commented 3 years ago

Could you maybe also share your code? The problem is that in the examples I produced it's not clearly visible whether antialiasing works or not.

nikkymen commented 3 years ago

If you have an idea feel free to create a pull request :) Maybe I'll get round to checking out this issue the next days.

Unfortunately, my experience with OpenGL is almost zero. I tried to set QSurfaceFormat with setSamples(16) for Qt3DWidget, but this only works for drawing inside Qt3DWidget::paintGL() method

Could you maybe also share your code? The problem is that in the examples I produced it's not clearly visible whether antialiasing works or not.

Your example is quite suitable for observing this issue: you just need to comment out the animation and replace using Qt3DWidget with Qt3DWindow.

I get the following pictures - the edge differences are quite obvious.

Qt3DWidget: widget

Qt3DWindow: window

florianblume commented 3 years ago

Ah ok well the difference is clearly visible, thanks. I'll try to have another look the next days.

florianblume commented 3 years ago

Screenshot from 2021-01-22 15-18-53

All done ;) You only have to set the version of the format to at least 3.0 and define the number of samples (checkout the README on the main page I'll explain it there).

nikkymen commented 3 years ago

All done ;) You only have to set the version of the format to at least 3.0 and define the number of samples (checkout the README on the main page I'll explain it there).

Nice! I was close to your solution :D