IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

MultiSampleAntiAliasing QML Type

Enable multisample antialiasing.

This type was introduced in Qt 5.7.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

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:

 
Sélectionnez
RenderPass {
    shaderProgram: ShaderProgram {
        // ...
    }
    renderStates: [
        MultiSampleAntiAliasing {}
    ]
}

Or a RenderStateSet:

 
Sélectionnez
RenderStateSet {
    renderStates: [
        MultiSampleAntiAliasing {}
    ]
}

For multisampling to take effect, the render target must have been allocated with multisampling enabled:

 
Sélectionnez
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.

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+