Nesta página

MultiSampleAntiAliasing QML Type

Ativar antialiasing com múltiplas amostras. Mais...

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

RenderState

Status: Deprecated

Esse tipo está obsoleto. Recomendamos enfaticamente que não seja usado em código novo.

Descrição detalhada

Um tipo MultiSampleAntiAliasing habilita o antialiasing com múltiplas amostras.

Ele pode ser adicionado a um ` RenderPass`:

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

Ou a um RenderStateSet:

RenderStateSet {
    renderStates: [
        MultiSampleAntiAliasing {}
    ]
}

Para que a multisampling tenha efeito, o alvo de renderização deve ter sido alocado com a multisampling habilitada:

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

Além disso, o código do shader deve utilizar tipos de amostrador com multisampling e a função `texelFetch()` em vez de `texture()`.

Além disso, o código do shader deve usar tipos de amostrador de amostragem múltipla e texelFetch() em vez de texture().

Por exemplo, se você tiver um código como

#version 150

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

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

você pode reescrevê-lo como

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

Observação: Ao usar o OpenGL como API gráfica, glEnable(GL_MULTISAMPLE) será chamado se MultiSampleAntiAliasing tiver sido adicionado aos estados de renderização.

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