1// Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
2// Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#include "qalphacoverage.h"
6#include "qrenderstate_p.h"
7
8QT_BEGIN_NAMESPACE
9
10namespace Qt3DRender {
11
12/*!
13 \class Qt3DRender::QAlphaCoverage
14 \since 5.7
15 \ingroup renderstates
16 \inmodule Qt3DRender
17 \brief Enable alpha-to-coverage multisampling mode.
18
19 A Qt3DRender::QAlphaCoverage class enables alpha-to-coverage multisampling mode.
20 When enabled, the fragment alpha value is used as a coverage for the sample
21 and combined with fragment coverage value. Qt3DRender::QAlphaCoverage does
22 nothing if multisampling is disabled. Alpha-to-coverage is most useful when
23 order independent blending is required, for example when rendering leaves,
24 grass and other rich vegetation.
25
26 It can be added to a QRenderPass by calling QRenderPass::addRenderState():
27
28 \code
29 QRenderPass *renderPass = new QRenderPass();
30
31 // Create a alpha coverage render state
32 QAlphaCoverage *alphaCoverage = new QAlphaCoverage();
33 QMultiSampleAntiAliasing *multiSampleAntialiasing = new QMultiSampleAntiAliasing();
34
35 // Add the render states to the render pass
36 renderPass->addRenderState(alphaCoverage);
37 renderPass->addRenderState(multiSampleAntialiasing);
38 \endcode
39
40 Or to a QRenderStateSet by calling QRenderStateSet::addRenderState():
41
42 \code
43 QRenderStateSet *renderStateSet = new QRenderStateSet();
44
45 // Create a alpha coverage render state
46 QAlphaCoverage *alphaCoverage = new QAlphaCoverage();
47 QMultiSampleAntiAliasing *multiSampleAntialiasing = new QMultiSampleAntiAliasing();
48
49 // Add the render states to the render state set
50 renderStateSet->addRenderState(alphaCoverage);
51 renderStateSet->addRenderState(multiSampleAntialiasing);
52 \endcode
53
54 \sa Qt3DRender::QMultiSampleAntiAliasing
55 */
56
57/*!
58 \qmltype AlphaCoverage
59 \since 5.7
60 \ingroup renderstates
61 \inqmlmodule Qt3D.Render
62 \instantiates Qt3DRender::QAlphaCoverage
63 \inherits RenderState
64 \brief Enable alpha-to-coverage multisampling mode.
65
66 An AlphaCoverage type enables alpha-to-coverage multisampling mode.
67 When enabled, the fragment alpha value is used as a coverage for the sample
68 and combined with fragment coverage value. AlphaCoverage does nothing if
69 multisampling is disabled. Alpha-to-coverage is most useful when
70 order independent blending is required, for example when rendering leaves,
71 grass and other rich vegetation.
72
73 It can be added to a RenderPass:
74
75 \qml
76 RenderPass {
77 shaderProgram: ShaderProgram {
78 // ...
79 }
80 renderStates: [
81 AlphaCoverage {},
82 MultiSampleAntiAliasing {}
83 ]
84 }
85 \endqml
86
87 Or to a RenderStateSet:
88
89 \qml
90 RenderStateSet {
91 renderStates: [
92 AlphaCoverage {},
93 MultiSampleAntiAliasing {}
94 ]
95 }
96 \endqml
97
98 \sa MultiSampleAntiAliasing
99 */
100
101class QAlphaCoveragePrivate : public QRenderStatePrivate
102{
103public :
104 QAlphaCoveragePrivate()
105 : QRenderStatePrivate(Render::AlphaCoverageStateMask)
106 {}
107
108 Q_DECLARE_PUBLIC(QAlphaCoverage)
109};
110
111/*!
112 The constructor creates a new QAlphaCoverage::QAlphaCoverage instance
113 with the specified \a parent.
114 */
115QAlphaCoverage::QAlphaCoverage(QNode *parent)
116 : QRenderState(*new QAlphaCoveragePrivate, parent)
117{
118}
119
120/*! \internal */
121QAlphaCoverage::~QAlphaCoverage()
122{
123}
124
125} // namespace Qt3DRender
126
127QT_END_NAMESPACE
128
129#include "moc_qalphacoverage.cpp"
130

source code of qt3d/src/render/renderstates/qalphacoverage.cpp