In questa pagina

MultiSampleAntiAliasing QML Type

Abilita l'antialiasing multisample. Altro...

Import Statement: import Qt3D.Render 2.12
In C++: QMultiSampleAntiAliasing
Inherits:

RenderState

Status: Deprecated

Questo tipo è deprecato. Si sconsiglia vivamente di utilizzarlo nel nuovo codice.

Descrizione dettagliata

Un tipo MultiSampleAntiAliasing abilita l'antialiasing multisample.

Può essere aggiunto a un oggetto ` RenderPass`:

RenderPass {
    shaderProgram: ShaderProgram {
        // ...
    }
    renderStates: [
        MultiSampleAntiAliasing {}
    ]
}

Oppure a un ` RenderStateSet`:

RenderStateSet {
    renderStates: [
        MultiSampleAntiAliasing {}
    ]
}

Affinché il multisampling abbia effetto, il render target deve essere stato allocato con il multisampling abilitato:

RenderTarget {
    attachments: [
        RenderTargetOutput {
            attachmentPoint: RenderTargetOutput.Color0
            texture: Texture2DMultisample {
                width: 1024
                height: 1024
                format: Texture.RGBA8_UNorm
            }
        },
        RenderTargetOutput {
            attachmentPoint: RenderTargetOutput.DepthStencil
            texture: Texture2DMultisample{
                width: 1024
                height: 1024
                format: Texture.D24S8
            }
        }
    ]
}

Inoltre, il codice dello shader deve utilizzare tipi di campionatore multisampling e la funzione texelFetch() al posto di texture().

Inoltre, il codice dello shader deve utilizzare tipi di campionatore multisampling e texelFetch() al posto di texture().

Ad esempio, se si dispone di un codice come

#version 150

uniform sampler2D colorTexture;
in vec2 texCoord;
out vec4 fragColor;

void main()
{
    fragColor = texture(colorTexture, texCoord);
}

puoi riscriverlo come

#version 150

uniform sampler2DMS colorTexture;
in vec2 texCoord;
out vec4 fragColor;

void main()
{
    ivec2 tc = ivec2(floor(textureSize(colorTexture) * texCoord));
    vec4 c = texelFetch(colorTexture, tc, 0) +
                texelFetch(colorTexture, tc, 1) +
                texelFetch(colorTexture, tc, 2) +
                texelFetch(colorTexture, tc, 3);
    fragColor = c / 4.0;
}

Nota: quando si utilizza OpenGL come API grafica, verrà chiamata la funzione glEnable(GL_MULTISAMPLE) se MultiSampleAntiAliasing è stato aggiunto agli stati di rendering.

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.