Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

MultiSampleAntiAliasing

Enable multisample antialiasing. More...

Import Statement: import Qt3D.Render 2.4
Since: Qt 5.7
Instantiates: QMultiSampleAntiAliasing
Inherits:

RenderState

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().

For example, if you have code like

#version 150

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

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

you can rewrite it as

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

Note: When using OpenGL as the graphics API, glEnable(GL_MULTISAMPLE) will be called if MultiSampleAntiAliasing has been added to the render states.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded