mirror of https://github.com/qt/qt3d.git
QDepthMask transformed into QNoDepthMask
By default the absence of a QNoDepthMask node in a RenderStateSet implies depth mask is enabled. Its presence, disables it. Change-Id: Iaa22b6cee12ee76e64d66a00e97f8aadfa82398b Task-number: QTBUG-51433 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
This commit is contained in:
parent
002bb76d8c
commit
acb32c488b
|
|
@ -96,7 +96,7 @@ Material {
|
|||
renderPasses: RenderPass {
|
||||
shaderProgram: gl3PhongAlphaShader
|
||||
renderStates: [
|
||||
DepthMask { mask: false },
|
||||
NoDepthMask { },
|
||||
BlendEquationArguments {
|
||||
sourceRgb: BlendEquationArguments.SourceAlpha
|
||||
destinationRgb: BlendEquationArguments.OneMinusSourceAlpha
|
||||
|
|
@ -118,7 +118,7 @@ Material {
|
|||
renderPasses: RenderPass {
|
||||
shaderProgram: gl2es2PhongAlphaShader
|
||||
renderStates: [
|
||||
DepthMask { mask: false },
|
||||
NoDepthMask { },
|
||||
BlendEquationArguments {
|
||||
sourceRgb: BlendEquationArguments.SourceAlpha
|
||||
destinationRgb: BlendEquationArguments.OneMinusSourceAlpha
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ Entity {
|
|||
renderStates: [
|
||||
CullFace { mode : CullFace.Back },
|
||||
DepthTest { depthFunction: DepthTest.Less },
|
||||
DepthMask { mask: false },
|
||||
NoDepthMask { },
|
||||
BlendEquationArguments {
|
||||
sourceRgb: BlendEquationArguments.SourceAlpha
|
||||
destinationRgb: BlendEquationArguments.OneMinusSourceAlpha
|
||||
|
|
@ -184,7 +184,7 @@ Entity {
|
|||
renderStates: [
|
||||
CullFace { mode : CullFace.Back },
|
||||
DepthTest { depthFunction: DepthTest.Less },
|
||||
DepthMask { mask: false },
|
||||
NoDepthMask { },
|
||||
BlendEquationArguments {
|
||||
sourceRgb: BlendEquationArguments.SourceAlpha
|
||||
destinationRgb: BlendEquationArguments.OneMinusSourceAlpha
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ Entity {
|
|||
renderStates: [
|
||||
CullFace { mode : CullFace.Back },
|
||||
DepthTest { depthFunction: DepthTest.Less },
|
||||
DepthMask { mask: false },
|
||||
NoDepthMask { },
|
||||
BlendEquationArguments {
|
||||
sourceRgb: BlendEquationArguments.SourceAlpha
|
||||
destinationRgb: BlendEquationArguments.OneMinusSourceAlpha
|
||||
|
|
@ -198,7 +198,7 @@ Entity {
|
|||
renderStates: [
|
||||
CullFace { mode : CullFace.Back },
|
||||
DepthTest { depthFunction: DepthTest.Less },
|
||||
DepthMask { mask: false },
|
||||
NoDepthMask { },
|
||||
BlendEquationArguments {
|
||||
sourceRgb: BlendEquationArguments.SourceAlpha
|
||||
destinationRgb: BlendEquationArguments.OneMinusSourceAlpha
|
||||
|
|
|
|||
|
|
@ -94,7 +94,6 @@ Effect {
|
|||
// Disable depth testing and use simple additive blending
|
||||
renderStates: [
|
||||
DepthTest { depthFunction: DepthTest.Always },
|
||||
DepthMask { mask: true },
|
||||
BlendEquationArguments {
|
||||
sourceRgb: BlendEquationArguments.One
|
||||
destinationRgb: BlendEquationArguments.OneMinusSourceColor
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@
|
|||
#include <Qt3DRender/QBlendStateSeparate>
|
||||
#include <Qt3DRender/QColorMask>
|
||||
#include <Qt3DRender/QCullFace>
|
||||
#include <Qt3DRender/QDepthMask>
|
||||
#include <Qt3DRender/QNoDepthMask>
|
||||
#include <Qt3DRender/QDepthTest>
|
||||
#include <Qt3DRender/QEffect>
|
||||
#include <Qt3DRender/QFrontFace>
|
||||
|
|
@ -1512,8 +1512,11 @@ QRenderState* GLTFParser::buildState(const QString& functionName, const QJsonVal
|
|||
}
|
||||
|
||||
if (functionName == QStringLiteral("depthMask")) {
|
||||
QDepthMask *depthMask = new QDepthMask;
|
||||
depthMask->setMask(values.at(0).toBool(true));
|
||||
if (!values.at(0).toBool(true)) {
|
||||
QNoDepthMask *depthMask = new QNoDepthMask;
|
||||
return depthMask;
|
||||
}
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
|
||||
if (functionName == QStringLiteral("depthRange")) {
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ Material {
|
|||
renderPasses: RenderPass {
|
||||
shaderProgram: gl3PhongAlphaShader
|
||||
renderStates: [
|
||||
DepthMask { mask: false },
|
||||
NoDepthMask { },
|
||||
BlendEquationArguments {
|
||||
sourceRgb: BlendEquationArguments.SourceAlpha
|
||||
destinationRgb: BlendEquationArguments.OneMinusSourceAlpha
|
||||
|
|
@ -112,7 +112,7 @@ Material {
|
|||
renderPasses: RenderPass {
|
||||
shaderProgram: gl2es2PhongAlphaShader
|
||||
renderStates: [
|
||||
DepthMask { mask: false },
|
||||
NoDepthMask { },
|
||||
BlendEquationArguments {
|
||||
sourceRgb: BlendEquationArguments.SourceAlpha
|
||||
destinationRgb: BlendEquationArguments.OneMinusSourceAlpha
|
||||
|
|
@ -134,7 +134,7 @@ Material {
|
|||
renderPasses: RenderPass {
|
||||
shaderProgram: gl2es2PhongAlphaShader
|
||||
renderStates: [
|
||||
DepthMask { mask: false },
|
||||
NoDepthMask { },
|
||||
BlendEquationArguments {
|
||||
sourceRgb: BlendEquationArguments.SourceAlpha
|
||||
destinationRgb: BlendEquationArguments.OneMinusSourceAlpha
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@
|
|||
#include <Qt3DRender/qblendequation.h>
|
||||
#include <Qt3DRender/qalphatest.h>
|
||||
#include <Qt3DRender/qdepthtest.h>
|
||||
#include <Qt3DRender/qdepthmask.h>
|
||||
#include <Qt3DRender/qnodepthmask.h>
|
||||
#include <Qt3DRender/qcullface.h>
|
||||
#include <Qt3DRender/qfrontface.h>
|
||||
#include <Qt3DRender/qstenciltest.h>
|
||||
|
|
@ -294,7 +294,7 @@ void Qt3DQuick3DRenderPlugin::registerTypes(const char *uri)
|
|||
qmlRegisterType<Qt3DRender::QBlendEquation>(uri, 2, 0, "BlendEquation");
|
||||
qmlRegisterType<Qt3DRender::QAlphaTest>(uri, 2, 0, "AlphaTest");
|
||||
qmlRegisterType<Qt3DRender::QDepthTest>(uri, 2, 0, "DepthTest");
|
||||
qmlRegisterType<Qt3DRender::QDepthMask>(uri, 2, 0, "DepthMask");
|
||||
qmlRegisterType<Qt3DRender::QNoDepthMask>(uri, 2, 0, "NoDepthMask");
|
||||
qmlRegisterType<Qt3DRender::QCullFace>(uri, 2, 0, "CullFace");
|
||||
qmlRegisterType<Qt3DRender::QFrontFace>(uri, 2, 0, "FrontFace");
|
||||
qmlRegisterUncreatableType<Qt3DRender::QStencilTestArguments>(uri, 2, 0, "StencilTestArguments", QStringLiteral("QStencilTestArguments cannot be instantiated on its own"));
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@
|
|||
#include <Qt3DRender/qgraphicsapifilter.h>
|
||||
#include <Qt3DRender/qblendequation.h>
|
||||
#include <Qt3DRender/qblendequationarguments.h>
|
||||
#include <Qt3DRender/qdepthmask.h>
|
||||
#include <Qt3DRender/qnodepthmask.h>
|
||||
#include <QUrl>
|
||||
#include <QVector3D>
|
||||
#include <QVector4D>
|
||||
|
|
@ -74,7 +74,7 @@ QPhongAlphaMaterialPrivate::QPhongAlphaMaterialPrivate()
|
|||
, m_phongAlphaES2RenderPass(new QRenderPass())
|
||||
, m_phongAlphaGL3Shader(new QShaderProgram())
|
||||
, m_phongAlphaGL2ES2Shader(new QShaderProgram())
|
||||
, m_depthMask(new QDepthMask())
|
||||
, m_noDepthMask(new QNoDepthMask())
|
||||
, m_blendState(new QBlendEquationArguments())
|
||||
, m_blendEquation(new QBlendEquation())
|
||||
, m_filterKey(new QFilterKey)
|
||||
|
|
@ -124,8 +124,6 @@ void QPhongAlphaMaterialPrivate::init()
|
|||
m_phongAlphaGL2Technique->addFilterKey(m_filterKey);
|
||||
m_phongAlphaES2Technique->addFilterKey(m_filterKey);
|
||||
|
||||
m_depthMask->setMask(false);
|
||||
|
||||
m_blendState->setSourceRgb(QBlendEquationArguments::SourceAlpha);
|
||||
m_blendState->setDestinationRgb(QBlendEquationArguments::OneMinusSourceAlpha);
|
||||
m_blendEquation->setBlendFunction(QBlendEquation::Add);
|
||||
|
|
@ -134,15 +132,15 @@ void QPhongAlphaMaterialPrivate::init()
|
|||
m_phongAlphaGL2RenderPass->setShaderProgram(m_phongAlphaGL2ES2Shader);
|
||||
m_phongAlphaES2RenderPass->setShaderProgram(m_phongAlphaGL2ES2Shader);
|
||||
|
||||
m_phongAlphaGL3RenderPass->addRenderState(m_depthMask);
|
||||
m_phongAlphaGL3RenderPass->addRenderState(m_noDepthMask);
|
||||
m_phongAlphaGL3RenderPass->addRenderState(m_blendState);
|
||||
m_phongAlphaGL3RenderPass->addRenderState(m_blendEquation);
|
||||
|
||||
m_phongAlphaGL2RenderPass->addRenderState(m_depthMask);
|
||||
m_phongAlphaGL2RenderPass->addRenderState(m_noDepthMask);
|
||||
m_phongAlphaGL2RenderPass->addRenderState(m_blendState);
|
||||
m_phongAlphaGL2RenderPass->addRenderState(m_blendEquation);
|
||||
|
||||
m_phongAlphaES2RenderPass->addRenderState(m_depthMask);
|
||||
m_phongAlphaES2RenderPass->addRenderState(m_noDepthMask);
|
||||
m_phongAlphaES2RenderPass->addRenderState(m_blendState);
|
||||
m_phongAlphaES2RenderPass->addRenderState(m_blendEquation);
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class QParameter;
|
|||
class QShaderProgram;
|
||||
class QRenderPass;
|
||||
class QParameterMapping;
|
||||
class QDepthMask;
|
||||
class QNoDepthMask;
|
||||
class QBlendEquationArguments;
|
||||
class QBlendEquation;
|
||||
|
||||
|
|
@ -97,7 +97,7 @@ public:
|
|||
QRenderPass *m_phongAlphaES2RenderPass;
|
||||
QShaderProgram *m_phongAlphaGL3Shader;
|
||||
QShaderProgram *m_phongAlphaGL2ES2Shader;
|
||||
QDepthMask *m_depthMask;
|
||||
QNoDepthMask *m_noDepthMask;
|
||||
QBlendEquationArguments *m_blendState;
|
||||
QBlendEquation *m_blendEquation;
|
||||
QFilterKey *m_filterKey;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qdepthmask.h"
|
||||
#include "qnodepthmask.h"
|
||||
#include "qrenderstate_p.h"
|
||||
#include <private/qnode_p.h>
|
||||
#include <Qt3DCore/qscenepropertychange.h>
|
||||
|
|
@ -47,51 +47,27 @@ QT_BEGIN_NAMESPACE
|
|||
|
||||
namespace Qt3DRender {
|
||||
|
||||
class QDepthMaskPrivate : public QRenderStatePrivate
|
||||
class QNoDepthMaskPrivate : public QRenderStatePrivate
|
||||
{
|
||||
public:
|
||||
QDepthMaskPrivate()
|
||||
: QRenderStatePrivate(QRenderStatePrivate::DepthMask)
|
||||
, m_mask(false)
|
||||
QNoDepthMaskPrivate()
|
||||
: QRenderStatePrivate(QRenderStatePrivate::NoDepthMask)
|
||||
{
|
||||
}
|
||||
|
||||
Q_DECLARE_PUBLIC(QDepthMask)
|
||||
bool m_mask;
|
||||
Q_DECLARE_PUBLIC(QNoDepthMask)
|
||||
};
|
||||
|
||||
QDepthMask::QDepthMask(QNode *parent)
|
||||
: QRenderState(*new QDepthMaskPrivate, parent)
|
||||
QNoDepthMask::QNoDepthMask(QNode *parent)
|
||||
: QRenderState(*new QNoDepthMaskPrivate, parent)
|
||||
{
|
||||
}
|
||||
|
||||
QDepthMask::~QDepthMask()
|
||||
QNoDepthMask::~QNoDepthMask()
|
||||
{
|
||||
QNode::cleanup();
|
||||
}
|
||||
|
||||
void QDepthMask::copy(const QNode *ref)
|
||||
{
|
||||
QRenderState::copy(ref);
|
||||
const QDepthMask *refState = static_cast<const QDepthMask*>(ref);
|
||||
d_func()->m_mask = refState->d_func()->m_mask;
|
||||
}
|
||||
|
||||
bool QDepthMask::mask() const
|
||||
{
|
||||
Q_D(const QDepthMask);
|
||||
return d->m_mask;
|
||||
}
|
||||
|
||||
void QDepthMask::setMask(bool mask)
|
||||
{
|
||||
Q_D(QDepthMask);
|
||||
if (d->m_mask != mask) {
|
||||
d->m_mask = mask;
|
||||
emit maskChanged(mask);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Qt3DRender
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
@ -38,8 +38,8 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QT3DRENDER_QDEPTHMASK_H
|
||||
#define QT3DRENDER_QDEPTHMASK_H
|
||||
#ifndef QT3DRENDER_QNODEPTHMASK_H
|
||||
#define QT3DRENDER_QNODEPTHMASK_H
|
||||
|
||||
#include <Qt3DRender/qrenderstate.h>
|
||||
|
||||
|
|
@ -47,34 +47,22 @@ QT_BEGIN_NAMESPACE
|
|||
|
||||
namespace Qt3DRender {
|
||||
|
||||
class QDepthMaskPrivate;
|
||||
class QNoDepthMaskPrivate;
|
||||
|
||||
class QT3DRENDERSHARED_EXPORT QDepthMask : public QRenderState
|
||||
class QT3DRENDERSHARED_EXPORT QNoDepthMask : public QRenderState
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY (bool mask READ mask WRITE setMask NOTIFY maskChanged)
|
||||
public:
|
||||
explicit QDepthMask(Qt3DCore::QNode *parent = 0);
|
||||
~QDepthMask();
|
||||
|
||||
bool mask() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void setMask(bool mask);
|
||||
|
||||
Q_SIGNALS:
|
||||
void maskChanged(bool mask);
|
||||
|
||||
protected:
|
||||
void copy(const Qt3DCore::QNode *ref) Q_DECL_OVERRIDE;
|
||||
explicit QNoDepthMask(Qt3DCore::QNode *parent = Q_NULLPTR);
|
||||
~QNoDepthMask();
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE(QDepthMask)
|
||||
QT3D_CLONEABLE(QDepthMask)
|
||||
Q_DECLARE_PRIVATE(QNoDepthMask)
|
||||
QT3D_CLONEABLE(QNoDepthMask)
|
||||
};
|
||||
|
||||
} // namespace Qt3DRender
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT3DRENDER_QDEPTHMASK_H
|
||||
#endif // QT3DRENDER_QNODEPTHMASK_H
|
||||
|
|
@ -71,7 +71,7 @@ public:
|
|||
BlendStateSeparate,
|
||||
ColorMask,
|
||||
CullFace,
|
||||
DepthMask,
|
||||
NoDepthMask,
|
||||
DepthTest,
|
||||
Dithering,
|
||||
FrontFace,
|
||||
|
|
|
|||
|
|
@ -186,12 +186,12 @@ void FrontFace::updateProperty(const char *name, const QVariant &value)
|
|||
if (name == QByteArrayLiteral("direction")) m_1 = value.toInt();
|
||||
}
|
||||
|
||||
void DepthMask::apply(GraphicsContext *gc) const
|
||||
void NoDepthMask::apply(GraphicsContext *gc) const
|
||||
{
|
||||
gc->depthMask(m_1);
|
||||
}
|
||||
|
||||
void DepthMask::updateProperty(const char *name, const QVariant &value)
|
||||
void NoDepthMask::updateProperty(const char *name, const QVariant &value)
|
||||
{
|
||||
if (name == QByteArrayLiteral("mask")) m_1 = value.toBool();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,6 @@ HEADERS += \
|
|||
$$PWD/qclipplane.h \
|
||||
$$PWD/qcolormask.h \
|
||||
$$PWD/qcullface.h \
|
||||
$$PWD/qdepthmask.h \
|
||||
$$PWD/qdepthtest.h \
|
||||
$$PWD/qdithering.h \
|
||||
$$PWD/qfrontface.h \
|
||||
$$PWD/qpolygonoffset.h \
|
||||
|
|
@ -26,7 +24,9 @@ HEADERS += \
|
|||
$$PWD/renderstateset_p.h \
|
||||
$$PWD/qpointsize.h \
|
||||
$$PWD/renderstatecollection_p.h \
|
||||
$$PWD/qseamlesscubemap.h
|
||||
$$PWD/qseamlesscubemap.h \
|
||||
$$PWD/qdepthtest.h \
|
||||
$$PWD/qnodepthmask.h
|
||||
|
||||
|
||||
SOURCES += \
|
||||
|
|
@ -37,7 +37,6 @@ SOURCES += \
|
|||
$$PWD/qclipplane.cpp \
|
||||
$$PWD/qcolormask.cpp \
|
||||
$$PWD/qcullface.cpp \
|
||||
$$PWD/qdepthmask.cpp \
|
||||
$$PWD/qdepthtest.cpp \
|
||||
$$PWD/qdithering.cpp \
|
||||
$$PWD/qfrontface.cpp \
|
||||
|
|
@ -53,4 +52,5 @@ SOURCES += \
|
|||
$$PWD/renderstateset.cpp \
|
||||
$$PWD/qpointsize.cpp \
|
||||
$$PWD/renderstatecollection.cpp \
|
||||
$$PWD/qseamlesscubemap.cpp
|
||||
$$PWD/qseamlesscubemap.cpp \
|
||||
$$PWD/qnodepthmask.cpp
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ public:
|
|||
void updateProperty(const char *name, const QVariant &value) Q_DECL_OVERRIDE;
|
||||
};
|
||||
|
||||
class Q_AUTOTEST_EXPORT DepthMask : public GenericState1<DepthMask, DepthWriteStateMask, GLboolean>
|
||||
class Q_AUTOTEST_EXPORT NoDepthMask : public GenericState1<NoDepthMask, DepthWriteStateMask, GLboolean>
|
||||
{
|
||||
public:
|
||||
virtual void apply(GraphicsContext *gc) const Q_DECL_OVERRIDE;
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@
|
|||
#include <Qt3DRender/qblendequationarguments.h>
|
||||
#include <Qt3DRender/qcolormask.h>
|
||||
#include <Qt3DRender/qcullface.h>
|
||||
#include <Qt3DRender/qdepthmask.h>
|
||||
#include <Qt3DRender/qnodepthmask.h>
|
||||
#include <Qt3DRender/qdepthtest.h>
|
||||
#include <Qt3DRender/qdithering.h>
|
||||
#include <Qt3DRender/qfrontface.h>
|
||||
|
|
@ -288,9 +288,8 @@ RenderStateImpl* RenderStateImpl::getOrCreateState(QRenderState *renderState)
|
|||
QCullFace *cullFace = static_cast<QCullFace *>(renderState);
|
||||
return getOrCreateRenderStateImpl<CullFace>(cullFace->mode());
|
||||
}
|
||||
case QRenderStatePrivate::DepthMask: {
|
||||
QDepthMask *depthMask = static_cast<QDepthMask *>(renderState);
|
||||
return getOrCreateRenderStateImpl<DepthMask>(depthMask->mask());
|
||||
case QRenderStatePrivate::NoDepthMask: {
|
||||
return getOrCreateRenderStateImpl<NoDepthMask>(false);
|
||||
}
|
||||
case QRenderStatePrivate::DepthTest: {
|
||||
QDepthTest *depthTest = static_cast<QDepthTest *>(renderState);
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@
|
|||
#include <Qt3DRender/QBlendEquationArguments>
|
||||
#include <Qt3DRender/QColorMask>
|
||||
#include <Qt3DRender/QCullFace>
|
||||
#include <Qt3DRender/QDepthMask>
|
||||
#include <Qt3DRender/QNoDepthMask>
|
||||
#include <Qt3DRender/QDepthTest>
|
||||
#include <Qt3DRender/QDithering>
|
||||
#include <Qt3DRender/QFrontFace>
|
||||
|
|
|
|||
Loading…
Reference in New Issue