En esta página

Qt3DRender::QMultiSampleAntiAliasing Class

class Qt3DRender::QMultiSampleAntiAliasing

Activar el suavizado de múltiple muestreo. Más...

Encabezado: #include <qmultisampleantialiasing.h>
CMake: find_package(Qt6 REQUIRED COMPONENTS 3drender)
target_link_libraries(mytarget PRIVATE Qt6::3drender)
qmake: QT += 3drender
En QML: MultiSampleAntiAliasing
Heredado de: Qt3DRender::QRenderState
Estado: Obsoleto

Esta clase está obsoleta. Se desaconseja encarecidamente su uso en código nuevo.

Funciones públicas

QMultiSampleAntiAliasing(Qt3DCore::QNode *parent = nullptr)

Descripción detallada

Una clase « Qt3DRender::QMultiSampleAntiAliasing » permite el antialiasing multimuestra.

Se puede añadir a un objeto ` QRenderPass ` llamando a ` QRenderPass::addRenderState()`:

QRenderPass *renderPass = new QRenderPass();

QMultiSampleAntiAliasing *msaa = new QMultiSampleAntiAliasing();
renderPass->addRenderState(msaa);

O bien, se puede añadir a un ` QRenderStateSet ` llamando a ` QRenderStateSet::addRenderState()`:

QRenderStateSet *renderStateSet = new QRenderStateSet();

QMultiSampleAntiAliasing *msaa = new QMultiSampleAntiAliasing();
renderStateSet->addRenderState(msaa);

Para que el multimuestreo surta efecto, el destino de renderizado debe haberse asignado con el multimuestreo habilitado:

QTexture2DMultisample *colorTex = new QTexture2DMultisample;
colorTex->setFormat(QAbstractTexture::RGBA8_UNorm);
colorTex->setWidth(1024);
colorTex->setHeight(1024);

QRenderTargetOutput *color = new QRenderTargetOutput;
color->setAttachmentPoint(QRenderTargetOutput::Color0);
color->setTexture(colorTex);

QTexture2DMultisample *depthStencilTex = new QTexture2DMultisample;
depthStencilTex->setFormat(QAbstractTexture::RGBA8_UNorm);
depthStencilTex->setWidth(1024);
depthStencilTex->setHeight(1024);

QRenderTargetOutput *depthStencil = new QRenderTargetOutput;
depthStencil->setAttachmentPoint(QRenderTargetOutput::DepthStencil);
depthStencil->setTexture(depthStencilTex);

Qt3DRender::QRenderTarget *renderTarget = new Qt3DRender::QRenderTarget;
renderTarget->addOutput(color);
renderTarget->addOutput(depthStencil);

Además, el código del shader debe utilizar tipos de muestreador de multimuestreo y texelFetch() en lugar de texture().

Por ejemplo, si tienes un código como

#version 150

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

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

puedes reescribirlo 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;
}

Nota: Al utilizar OpenGL como API gráfica, se llamará a glEnable(GL_MULTISAMPLE) si se ha añadido QMultiSampleAntiAliasing a los estados de renderizado.

Documentación de funciones miembro

[explicit] QMultiSampleAntiAliasing::QMultiSampleAntiAliasing(Qt3DCore::QNode *parent = nullptr)

El constructor crea una nueva instancia de ` QMultiSampleAntiAliasing::QMultiSampleAntiAliasing ` con el ` parent` especificado.

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