| 1 | // Copyright (C) 2008-2012 NVIDIA Corporation. |
|---|---|
| 2 | // Copyright (C) 2019 The Qt Company Ltd. |
| 3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 4 | |
| 5 | #include <QtQuick3DRuntimeRender/private/qssgrenderdefaultmaterial_p.h> |
| 6 | #include <QtQuick3DRuntimeRender/private/qssgshadermaterialadapter_p.h> |
| 7 | |
| 8 | QT_BEGIN_NAMESPACE |
| 9 | |
| 10 | QSSGRenderDefaultMaterial::QSSGRenderDefaultMaterial(QSSGRenderGraphObject::Type type) |
| 11 | : QSSGRenderGraphObject(type) |
| 12 | { |
| 13 | Q_ASSERT(type == QSSGRenderGraphObject::Type::DefaultMaterial || |
| 14 | type == QSSGRenderGraphObject::Type::PrincipledMaterial || |
| 15 | type == QSSGRenderGraphObject::Type::SpecularGlossyMaterial); |
| 16 | if (type == QSSGRenderGraphObject::Type::PrincipledMaterial) { |
| 17 | occlusionChannel = TextureChannelMapping::R; |
| 18 | roughnessChannel = TextureChannelMapping::G; |
| 19 | metalnessChannel = TextureChannelMapping::B; |
| 20 | } |
| 21 | |
| 22 | adapter = QSSGShaderMaterialAdapter::create(materialNode: *this); |
| 23 | } |
| 24 | |
| 25 | QSSGRenderDefaultMaterial::~QSSGRenderDefaultMaterial() |
| 26 | { |
| 27 | delete adapter; |
| 28 | } |
| 29 | |
| 30 | void QSSGRenderDefaultMaterial::clearDirty() |
| 31 | { |
| 32 | dirty = false; |
| 33 | } |
| 34 | |
| 35 | QSSGRenderCustomMaterial::QSSGRenderCustomMaterial() |
| 36 | : QSSGRenderGraphObject(Type::CustomMaterial) |
| 37 | { |
| 38 | adapter = QSSGShaderMaterialAdapter::create(materialNode: *this); |
| 39 | } |
| 40 | |
| 41 | QSSGRenderCustomMaterial::~QSSGRenderCustomMaterial() |
| 42 | { |
| 43 | delete adapter; |
| 44 | } |
| 45 | |
| 46 | void QSSGRenderCustomMaterial::markDirty() |
| 47 | { |
| 48 | m_flags |= FlagT(Flags::Dirty); |
| 49 | } |
| 50 | |
| 51 | void QSSGRenderCustomMaterial::clearDirty() |
| 52 | { |
| 53 | m_flags &= ~FlagT(Flags::Dirty); |
| 54 | } |
| 55 | |
| 56 | void QSSGRenderCustomMaterial::setAlwaysDirty(bool alwaysDirty) |
| 57 | { |
| 58 | if (alwaysDirty) |
| 59 | m_flags |= FlagT(Flags::AlwaysDirty); |
| 60 | else |
| 61 | m_flags &= ~FlagT(Flags::AlwaysDirty); |
| 62 | } |
| 63 | |
| 64 | QT_END_NAMESPACE |
| 65 |
