QMultiSampleAntiAliasing Class

class Qt3DRender::QMultiSampleAntiAliasing

マルチサンプル・アンチエイリアスを有効にする。もっと見る...

ヘッダー #include <QMultiSampleAntiAliasing>
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 インスタンスを作成します。

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