summaryrefslogtreecommitdiffstats
path: root/src/core/doc/snippets/code/src_render_renderstates_qmultisampleantialiasing.qdocinc
blob: 9c530382fd64abbff67ab554bb34b9dfbe0637be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Further, the shader code must use multisampling sampler types and texelFetch() instead
    of texture().

\oldcode

#version 150

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

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

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

\endcode