Sur cette page

MultiSampleAntiAliasing QML Type

Activer l'anticrénelage multi-échantillonnage. En savoir plus...

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

RenderState

Status: Deprecated

Ce type est obsolète. Nous déconseillons fortement de l'utiliser dans du nouveau code.

Description détaillée

Un type MultiSampleAntiAliasing active l'anticrénelage multi-échantillon.

Il peut être ajouté à un ` RenderPass` :

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

Ou à une cible de rendu ( RenderStateSet) :

RenderStateSet {
    renderStates: [
        MultiSampleAntiAliasing {}
    ]
}

Pour que le multisampling soit effectif, la cible de rendu doit avoir été allouée avec le multisampling activé :

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
            }
        }
    ]
}

De plus, le code du shader doit utiliser des types d'échantillonneurs multi-échantillonnage et la fonction texelFetch() à la place de texture().

De plus, le code du shader doit utiliser des types d’échantillonneurs multi-échantillonnage et la fonction texelFetch() à la place de texture().

Par exemple, si vous avez un code tel que

#version 150

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

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

vous pouvez le réécrire ainsi :

#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;
}

Remarque : lorsque vous utilisez OpenGL comme API graphique, la fonction glEnable(GL_MULTISAMPLE) sera appelée si MultiSampleAntiAliasing a été ajouté aux états de rendu.

© 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.