Qt3DRender::QMultiSampleAntiAliasing Class
class Qt3DRender::QMultiSampleAntiAliasingActiver l'anticrénelage multi-échantillon. Plus...
| En-tête : | #include <QMultiSampleAntiAliasing> |
| CMake : | find_package(Qt6 REQUIRED COMPONENTS 3drender)target_link_libraries(mytarget PRIVATE Qt6::3drender) |
| qmake : | QT += 3drender |
| En QML : | MultiSampleAntiAliasing |
| Hérite : | Qt3DRender::QRenderState |
| Statut : | Déclassé |
Fonctions publiques
| QMultiSampleAntiAliasing(Qt3DCore::QNode *parent = nullptr) |
Description détaillée
Une classe Qt3DRender::QMultiSampleAntiAliasing permet l'anticrénelage multi-échantillon.
Elle peut être ajoutée à une classe QRenderPass en appelant QRenderPass::addRenderState() :
QRenderPass *renderPass = new QRenderPass(); QMultiSampleAntiAliasing *msaa = new QMultiSampleAntiAliasing(); renderPass->addRenderState(msaa);
ou à un QRenderStateSet en appelant QRenderStateSet::addRenderState() :
QRenderStateSet *renderStateSet = new QRenderStateSet(); QMultiSampleAntiAliasing *msaa = new QMultiSampleAntiAliasing(); renderStateSet->addRenderState(msaa);
Pour que le multi-échantillonnage prenne effet, la cible de rendu doit avoir été allouée avec le multi-échantillonnage activé :
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);
En outre, le code du shader doit utiliser des types d'échantillonneurs à échantillonnage multiple et texelFetch() au lieu de texture().
Par exemple, si vous avez un code comme
#version 150 uniform sampler2D colorTexture; in vec2 texCoord; out vec4 fragColor; void main() { fragColor = texture(colorTexture, texCoord); }
vous pouvez le réécrire comme suit
#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 : lors de l'utilisation d'OpenGL comme API graphique, glEnable(GL_MULTISAMPLE) sera appelé si QMultiSampleAntiAliasing a été ajouté aux états de rendu.
Documentation des fonctions membres
[explicit] QMultiSampleAntiAliasing::QMultiSampleAntiAliasing(Qt3DCore::QNode *parent = nullptr)
Le constructeur crée une nouvelle instance QMultiSampleAntiAliasing::QMultiSampleAntiAliasing avec l'adresse parent spécifiée.
© 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.