MultiSampleAntiAliasing QML Type▲
-
Import Statement: import Qt3D.Render 2.12
-
Since: Qt 5.7
-
Inherits: RenderState
-
Instantiates:: QMultiSampleAntiAliasing
-
Group: MultiSampleAntiAliasing is part of renderstates
Detailed Description▲
A MultiSampleAntiAliasing type enables multisample antialiasing.
It can be added to a RenderPass:
RenderPass {
shaderProgram
:
ShaderProgram {
// ...
}
renderStates
:
[
MultiSampleAntiAliasing {}
]
}
Or a RenderStateSet:
RenderStateSet {
renderStates
:
[
MultiSampleAntiAliasing {}
]
}
For multisampling to take effect, the render target must have been allocated with multisampling enabled:
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
}
}
]
}
Further, the shader code must use multisampling sampler types and texelFetch() instead of texture().
Further, the shader code must use multisampling sampler types and texelFetch() instead of texture().
<Unknown command>oldcode
#version 150
uniform sampler2D colorTexture; in vec2 texCoord; out vec4 fragColor;
void main() { fragColor = texture(colorTexture, texCoord); }
<Unknown command>newcode
#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; }
When using OpenGL as the graphics API, glEnable(GL_MULTISAMPLE) will be called if MultiSampleAntiAliasing has been added to the render states.