1/****************************************************************************
2**
3** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
4** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies).
5** Contact: https://www.qt.io/licensing/
6**
7** This file is part of the Qt3D module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial License Usage
11** Licensees holding valid commercial Qt licenses may use this file in
12** accordance with the commercial license agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and The Qt Company. For licensing terms
15** and conditions see https://www.qt.io/terms-conditions. For further
16** information use the contact form at https://www.qt.io/contact-us.
17**
18** GNU Lesser General Public License Usage
19** Alternatively, this file may be used under the terms of the GNU Lesser
20** General Public License version 3 as published by the Free Software
21** Foundation and appearing in the file LICENSE.LGPL3 included in the
22** packaging of this file. Please review the following information to
23** ensure the GNU Lesser General Public License version 3 requirements
24** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
25**
26** GNU General Public License Usage
27** Alternatively, this file may be used under the terms of the GNU
28** General Public License version 2.0 or (at your option) the GNU General
29** Public license version 3 or any later version approved by the KDE Free
30** Qt Foundation. The licenses are as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
32** included in the packaging of this file. Please review the following
33** information to ensure the GNU General Public License requirements will
34** be met: https://www.gnu.org/licenses/gpl-2.0.html and
35** https://www.gnu.org/licenses/gpl-3.0.html.
36**
37** $QT_END_LICENSE$
38**
39****************************************************************************/
40
41#include "qalphacoverage.h"
42#include "qrenderstate_p.h"
43
44QT_BEGIN_NAMESPACE
45
46namespace Qt3DRender {
47
48/*!
49 \class Qt3DRender::QAlphaCoverage
50 \since 5.7
51 \ingroup renderstates
52 \inmodule Qt3DRender
53 \brief Enable alpha-to-coverage multisampling mode.
54
55 A Qt3DRender::QAlphaCoverage class enables alpha-to-coverage multisampling mode.
56 When enabled, the fragment alpha value is used as a coverage for the sample
57 and combined with fragment coverage value. Qt3DRender::QAlphaCoverage does
58 nothing if multisampling is disabled. Alpha-to-coverage is most useful when
59 order independent blending is required, for example when rendering leaves,
60 grass and other rich vegetation.
61
62 It can be added to a QRenderPass by calling QRenderPass::addRenderState():
63
64 \code
65 QRenderPass *renderPass = new QRenderPass();
66
67 // Create a alpha coverage render state
68 QAlphaCoverage *alphaCoverage = new QAlphaCoverage();
69 QMultiSampleAntiAliasing *multiSampleAntialiasing = new QMultiSampleAntiAliasing();
70
71 // Add the render states to the render pass
72 renderPass->addRenderState(alphaCoverage);
73 renderPass->addRenderState(multiSampleAntialiasing);
74 \endcode
75
76 Or to a QRenderStateSet by calling QRenderStateSet::addRenderState():
77
78 \code
79 QRenderStateSet *renderStateSet = new QRenderStateSet();
80
81 // Create a alpha coverage render state
82 QAlphaCoverage *alphaCoverage = new QAlphaCoverage();
83 QMultiSampleAntiAliasing *multiSampleAntialiasing = new QMultiSampleAntiAliasing();
84
85 // Add the render states to the render state set
86 renderStateSet->addRenderState(alphaCoverage);
87 renderStateSet->addRenderState(multiSampleAntialiasing);
88 \endcode
89
90 \sa Qt3DRender::QMultiSampleAntiAliasing
91 */
92
93/*!
94 \qmltype AlphaCoverage
95 \since 5.7
96 \ingroup renderstates
97 \inqmlmodule Qt3D.Render
98 \instantiates Qt3DRender::QAlphaCoverage
99 \inherits RenderState
100 \brief Enable alpha-to-coverage multisampling mode.
101
102 An AlphaCoverage type enables alpha-to-coverage multisampling mode.
103 When enabled, the fragment alpha value is used as a coverage for the sample
104 and combined with fragment coverage value. AlphaCoverage does nothing if
105 multisampling is disabled. Alpha-to-coverage is most useful when
106 order independent blending is required, for example when rendering leaves,
107 grass and other rich vegetation.
108
109 It can be added to a RenderPass:
110
111 \qml
112 RenderPass {
113 shaderProgram: ShaderProgram {
114 // ...
115 }
116 renderStates: [
117 AlphaCoverage {},
118 MultiSampleAntiAliasing {}
119 ]
120 }
121 \endqml
122
123 Or to a RenderStateSet:
124
125 \qml
126 RenderStateSet {
127 renderStates: [
128 AlphaCoverage {},
129 MultiSampleAntiAliasing {}
130 ]
131 }
132 \endqml
133
134 \sa MultiSampleAntiAliasing
135 */
136
137class QAlphaCoveragePrivate : public QRenderStatePrivate
138{
139public :
140 QAlphaCoveragePrivate()
141 : QRenderStatePrivate(Render::AlphaCoverageStateMask)
142 {}
143
144 Q_DECLARE_PUBLIC(QAlphaCoverage)
145};
146
147/*!
148 The constructor creates a new QAlphaCoverage::QAlphaCoverage instance
149 with the specified \a parent.
150 */
151QAlphaCoverage::QAlphaCoverage(QNode *parent)
152 : QRenderState(*new QAlphaCoveragePrivate, parent)
153{
154}
155
156/*! \internal */
157QAlphaCoverage::~QAlphaCoverage()
158{
159}
160
161} // namespace Qt3DRender
162
163QT_END_NAMESPACE
164

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