MultiSampleAntiAliasing QML Type
启用多采样抗锯齿。更多...
| Import Statement: | import Qt3D.Render 2.12 |
| In C++: | QMultiSampleAntiAliasing |
| Inherits: | |
| Status: | Deprecated |
此类型已弃用。我们强烈建议不要在新代码中使用它。
详细说明
MultiSampleAntiAliasing 类型可启用多采样抗锯齿功能。
可将其添加到RenderPass 中:
RenderPass {
shaderProgram: ShaderProgram {
// ...
}
renderStates: [
MultiSampleAntiAliasing {}
]
}RenderStateSet {
renderStates: [
MultiSampleAntiAliasing {}
]
}要使多采样生效,渲染目标在分配时必须已启用多采样:
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
}
}
]
}此外,着色器代码必须使用多采样采样器类型,并使用 texelFetch() 代替 texture()。
此外,着色器代码必须使用多采样采样器类型,并使用 texelFetch() 代替 texture()。
例如,如果您有如下代码:
#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;
}注意:当 使用 OpenGL 作为图形 API时, 如果渲染状态中已添加 MultiSampleAntiAliasing,则会调用 glEnable(GL_MULTISAMPLE)。
© 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.