MultiSampleAntiAliasing QML Type
启用多采样抗锯齿。更多
Import Statement: | import Qt3D.Render 2.9 |
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() 而不是纹理()。
例如
#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 时,如果在渲染状态中添加了多重采样抗锯齿功能,则会调用 glEnable(GL_MULTISAMPLE)。
© 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.