このページでは

Qt3DRender::QMultiSampleAntiAliasing Class

class Qt3DRender::QMultiSampleAntiAliasing

マルチサンプルアンチエイリアシングを有効にします。詳細...

ヘッダー: #include <qmultisampleantialiasing.h>
CMake: find_package(Qt6 REQUIRED COMPONENTS 3drender)
target_link_libraries(mytarget PRIVATE Qt6::3drender)
qmake: QT += 3drender
QML内: MultiSampleAntiAliasing
継承元: Qt3DRender::QRenderState
ステータス: 非推奨

このクラスは非推奨です。新しいコードでの使用は強く推奨しません。

パブリック関数

QMultiSampleAntiAliasing(Qt3DCore::QNode *parent = nullptr)

詳細な説明

Qt3DRender::QMultiSampleAntiAliasing クラスは、マルチサンプルアンチエイリアシングを有効にします。

QRenderPass::addRenderState() を呼び出すことで、QRenderPass に追加できます。

QRenderPass *renderPass = new QRenderPass();

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

あるいは、QRenderStateSet::addRenderState() を呼び出すことで、QRenderStateSet に追加することもできます:

QRenderStateSet *renderStateSet = new QRenderStateSet();

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

マルチサンプリングを有効にするには、レンダリングターゲットをマルチサンプリングを有効にした状態で割り当てる必要があります:

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);

さらに、シェーダーコードでは、texture() の代わりにマルチサンプリング対応のサンプラータイプと texelFetch() を使用する必要があります。

たとえば、次のようなコードがある場合

#version 150

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

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

次のように書き換えることができます

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

注: グラフィックス API として OpenGLを使用する場合 、QMultiSampleAntiAliasing がレンダリングステートに追加されていれば、glEnable(GL_MULTISAMPLE) が呼び出されます。

メンバ関数のドキュメント

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

このコンストラクタは、指定されたparent を用いて、新しいQMultiSampleAntiAliasing::QMultiSampleAntiAliasing インスタンスを作成します。

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