Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt3D: Antialising in deferred rendering
Qt 6.11 is out! See what's new in the release blog

Qt3D: Antialising in deferred rendering

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 530 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AntiXeon
    wrote on last edited by AntiXeon
    #1

    Hello all,

    I am writing an application in which I want to use deferred rendering.

    When using forward rendering, we can see that multisample antialiasing (MSAA) is enabled.
    However, I am trying to have MSAA in my deferred rendering application and I am not able to do this.

    As my framegraph is pretty complex (see below), I just show important parts of my code where I have tried to enable MSAA.

    • First of all, I have followed the answer of this topic before creating the Qt3DWindow.
    • Then, in my framegraph I have enabled MSAA by adding a QMultiSampleAntiAliasing in the QRenderStateSet
        auto globalRenderStateSet = new Qt3DRender::QRenderStateSet(viewport);
        auto depthTestState = new Qt3DRender::QDepthTest();
        depthTestState -> setDepthFunction(Qt3DRender::QDepthTest::LessOrEqual);
        auto msaaState = new Qt3DRender::QMultiSampleAntiAliasing();
        globalRenderStateSet -> addRenderState(depthTestState);
        globalRenderStateSet -> addRenderState(msaaState);
    
    • I have a GBuffer (QRenderTarget) in which I use only QTexture2DMultisample objects, all with the same amount of samples (the same as in the QSurfaceFormat of the first point as well).
        _textures = new Qt3DRender::QTexture2DMultisample*[attachmentsCount];
        _attachments = new Qt3DRender::QRenderTargetOutput*[attachmentsCount];
        for (int attachmentIndex = 0 ; attachmentIndex < attachmentsCount ; attachmentIndex++)
        {
            const TargetOutputParameters& parameter = parameters[attachmentIndex];
    
            _attachments[attachmentIndex] = new Qt3DRender::QRenderTargetOutput(this);
            _textures[attachmentIndex] = new Qt3DRender::QTexture2DMultisample();
            _textures[attachmentIndex] -> setFormat(parameter.format());
            _textures[attachmentIndex] -> setWidth(TextureWidth);
            _textures[attachmentIndex] -> setHeight(TextureHeight);
            _textures[attachmentIndex] -> setGenerateMipMaps(false);
            _textures[attachmentIndex] -> setWrapMode(Qt3DRender::QTextureWrapMode(Qt3DRender::QTextureWrapMode::ClampToEdge));
            _textures[attachmentIndex] -> setMinificationFilter(Qt3DRender::QAbstractTexture::Linear);
            _textures[attachmentIndex] -> setMagnificationFilter(Qt3DRender::QAbstractTexture::Linear);
            _textures[attachmentIndex] -> setSamples(8);
    
            _attachments[attachmentIndex] -> setTexture(_textures[attachmentIndex]);
            _attachments[attachmentIndex] -> setAttachmentPoint(parameter.attachmentPoint());
            _attachments[attachmentIndex] -> setObjectName(parameter.name());
    
            addOutput(_attachments[attachmentIndex]);
        }
    
    • I have another QRenderTarget (MSAADestinationRenderTarget) in which I only have QTexture2D objects. I perform a QBlitFramebuffer to copy the MSAA color texture into the single-sample render target.
                auto noDraw = new Qt3DRender::QNoDraw(cameraSelector);
                auto sceneBlitColorFBOs = new Qt3DRender::QBlitFramebuffer(noDraw);
    
                _gBuffer = new GBuffer();
                _msaaRenderTarget = new MSAADestinationRenderTarget();
    
                auto msaaRenderTargetSelector = new Qt3DRender::QRenderTargetSelector(cameraSelector);
                msaaRenderTargetSelector -> setTarget(_msaaRenderTarget);
    
                sceneBlitColorFBOs -> setSource(_gBuffer);
                sceneBlitColorFBOs -> setSourceAttachmentPoint(Qt3DRender::QRenderTargetOutput::Color0);
                sceneBlitColorFBOs -> setSourceRect(QRect(0, 0, _view -> width(), _view->height()));
                sceneBlitColorFBOs -> setDestination(_msaaRenderTarget);
                sceneBlitColorFBOs -> setDestinationAttachmentPoint(Qt3DRender::QRenderTargetOutput::Color0);
                sceneBlitColorFBOs -> setDestinationRect(QRect(0, 0, _view -> width(), _view->height()));
    

    All of this seems to be working well as I can display this texture on a quad and see the scene, move the camera, etc. But, it is not antialiased.

    Am I missing something?
    Thank you for any help.

    Denis

    Framegraph:
    0_1521640808054_framegraph.png

    1 Reply Last reply
    1
    • A Offline
      A Offline
      AntiXeon
      wrote on last edited by
      #2

      Hi,

      I have not found any solution from C++ code itself.
      So I have implemented FXAA into my fragment shader to get an antialiased picture.

      Denis

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved