| 1 | // Copyright (C) 2022 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QQUICK3DSPECULARGLOSSYMATERIAL_P_H |
| 5 | #define QQUICK3DSPECULARGLOSSYMATERIAL_P_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version toSpecularGlossyMaterial |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include <QtQuick3D/private/qquick3dmaterial_p.h> |
| 19 | #include <QtQuick3D/private/qquick3dtexture_p.h> |
| 20 | |
| 21 | #include <QColor> |
| 22 | #include <QHash> |
| 23 | |
| 24 | QT_BEGIN_NAMESPACE |
| 25 | |
| 26 | class Q_QUICK3D_EXPORT QQuick3DSpecularGlossyMaterial : public QQuick3DMaterial |
| 27 | { |
| 28 | Q_OBJECT |
| 29 | Q_PROPERTY(Lighting lighting READ lighting WRITE setLighting NOTIFY lightingChanged) |
| 30 | Q_PROPERTY(BlendMode blendMode READ blendMode WRITE setBlendMode NOTIFY blendModeChanged) |
| 31 | |
| 32 | Q_PROPERTY(QColor albedoColor READ albedoColor WRITE setAlbedoColor NOTIFY albedoColorChanged) |
| 33 | Q_PROPERTY(QQuick3DTexture *albedoMap READ albedoMap WRITE setAlbedoMap NOTIFY albedoMapChanged) |
| 34 | Q_PROPERTY(bool albedoSingleChannelEnabled READ albedoSingleChannelEnabled WRITE setAlbedoSingleChannelEnabled NOTIFY albedoSingleChannelEnabledChanged REVISION(6, 8)) |
| 35 | Q_PROPERTY(QQuick3DMaterial::TextureChannelMapping albedoChannel READ albedoChannel WRITE setAlbedoChannel NOTIFY albedoChannelChanged REVISION(6, 8)) |
| 36 | |
| 37 | Q_PROPERTY(QColor specularColor READ specularColor WRITE setSpecularColor NOTIFY specularColorChanged) |
| 38 | Q_PROPERTY(QQuick3DTexture *specularMap READ specularMap WRITE setSpecularMap NOTIFY specularMapChanged) |
| 39 | Q_PROPERTY(bool specularSingleChannelEnabled READ specularSingleChannelEnabled WRITE setSpecularSingleChannelEnabled NOTIFY specularSingleChannelEnabledChanged REVISION(6, 8)) |
| 40 | Q_PROPERTY(QQuick3DMaterial::TextureChannelMapping specularChannel READ specularChannel WRITE setSpecularChannel NOTIFY specularChannelChanged REVISION(6, 8)) |
| 41 | |
| 42 | Q_PROPERTY(float glossiness READ glossiness WRITE setGlossiness NOTIFY glossinessChanged) |
| 43 | Q_PROPERTY(QQuick3DTexture *glossinessMap READ glossinessMap WRITE setGlossinessMap NOTIFY glossinessMapChanged) |
| 44 | Q_PROPERTY(QQuick3DMaterial::TextureChannelMapping glossinessChannel READ glossinessChannel WRITE setGlossinessChannel NOTIFY glossinessChannelChanged) |
| 45 | |
| 46 | Q_PROPERTY(QVector3D emissiveFactor READ emissiveFactor WRITE setEmissiveFactor NOTIFY emissiveFactorChanged) |
| 47 | Q_PROPERTY(QQuick3DTexture *emissiveMap READ emissiveMap WRITE setEmissiveMap NOTIFY emissiveMapChanged) |
| 48 | Q_PROPERTY(bool emissiveSingleChannelEnabled READ emissiveSingleChannelEnabled WRITE setEmissiveSingleChannelEnabled NOTIFY emissiveSingleChannelEnabledChanged REVISION(6, 8)) |
| 49 | Q_PROPERTY(QQuick3DMaterial::TextureChannelMapping emissiveChannel READ emissiveChannel WRITE setEmissiveChannel NOTIFY emissiveChannelChanged REVISION(6, 8)) |
| 50 | |
| 51 | Q_PROPERTY(bool invertOpacityMapValue READ invertOpacityMapValue WRITE setInvertOpacityMapValue NOTIFY invertOpacityMapValueChanged REVISION(6, 8)) |
| 52 | Q_PROPERTY(float opacity READ opacity WRITE setOpacity NOTIFY opacityChanged) |
| 53 | Q_PROPERTY(QQuick3DTexture *opacityMap READ opacityMap WRITE setOpacityMap NOTIFY opacityMapChanged) |
| 54 | Q_PROPERTY(QQuick3DMaterial::TextureChannelMapping opacityChannel READ opacityChannel WRITE setOpacityChannel NOTIFY opacityChannelChanged) |
| 55 | |
| 56 | Q_PROPERTY(QQuick3DTexture *normalMap READ normalMap WRITE setNormalMap NOTIFY normalMapChanged) |
| 57 | Q_PROPERTY(float normalStrength READ normalStrength WRITE setNormalStrength NOTIFY normalStrengthChanged) |
| 58 | |
| 59 | Q_PROPERTY(QQuick3DTexture *occlusionMap READ occlusionMap WRITE setOcclusionMap NOTIFY occlusionMapChanged) |
| 60 | Q_PROPERTY(QQuick3DMaterial::TextureChannelMapping occlusionChannel READ occlusionChannel WRITE setOcclusionChannel NOTIFY occlusionChannelChanged) |
| 61 | Q_PROPERTY(float occlusionAmount READ occlusionAmount WRITE setOcclusionAmount NOTIFY occlusionAmountChanged) |
| 62 | |
| 63 | Q_PROPERTY(AlphaMode alphaMode READ alphaMode WRITE setAlphaMode NOTIFY alphaModeChanged) |
| 64 | Q_PROPERTY(float alphaCutoff READ alphaCutoff WRITE setAlphaCutoff NOTIFY alphaCutoffChanged) |
| 65 | |
| 66 | Q_PROPERTY(float pointSize READ pointSize WRITE setPointSize NOTIFY pointSizeChanged) |
| 67 | Q_PROPERTY(float lineWidth READ lineWidth WRITE setLineWidth NOTIFY lineWidthChanged) |
| 68 | |
| 69 | Q_PROPERTY(QQuick3DTexture *heightMap READ heightMap WRITE setHeightMap NOTIFY heightMapChanged) |
| 70 | Q_PROPERTY(QQuick3DMaterial::TextureChannelMapping heightChannel READ heightChannel WRITE setHeightChannel NOTIFY heightChannelChanged) |
| 71 | Q_PROPERTY(float heightAmount READ heightAmount WRITE setHeightAmount NOTIFY heightAmountChanged) |
| 72 | Q_PROPERTY(int minHeightMapSamples READ minHeightMapSamples WRITE setMinHeightMapSamples NOTIFY minHeightMapSamplesChanged) |
| 73 | Q_PROPERTY(int maxHeightMapSamples READ maxHeightMapSamples WRITE setMaxHeightMapSamples NOTIFY maxHeightMapSamplesChanged) |
| 74 | |
| 75 | Q_PROPERTY(float clearcoatAmount READ clearcoatAmount WRITE setClearcoatAmount NOTIFY clearcoatAmountChanged) |
| 76 | Q_PROPERTY(QQuick3DTexture *clearcoatMap READ clearcoatMap WRITE setClearcoatMap NOTIFY clearcoatMapChanged) |
| 77 | Q_PROPERTY(QQuick3DMaterial::TextureChannelMapping clearcoatChannel READ clearcoatChannel WRITE setClearcoatChannel NOTIFY |
| 78 | clearcoatChannelChanged) |
| 79 | Q_PROPERTY(float clearcoatRoughnessAmount READ clearcoatRoughnessAmount WRITE setClearcoatRoughnessAmount NOTIFY |
| 80 | clearcoatRoughnessAmountChanged) |
| 81 | Q_PROPERTY(QQuick3DMaterial::TextureChannelMapping clearcoatRoughnessChannel READ clearcoatRoughnessChannel WRITE |
| 82 | setClearcoatRoughnessChannel NOTIFY clearcoatRoughnessChannelChanged) |
| 83 | Q_PROPERTY(QQuick3DTexture *clearcoatRoughnessMap READ clearcoatRoughnessMap WRITE setClearcoatRoughnessMap NOTIFY |
| 84 | clearcoatRoughnessMapChanged) |
| 85 | Q_PROPERTY(QQuick3DTexture *clearcoatNormalMap READ clearcoatNormalMap WRITE setClearcoatNormalMap NOTIFY |
| 86 | clearcoatNormalMapChanged) |
| 87 | Q_PROPERTY(float clearcoatNormalStrength READ clearcoatNormalStrength WRITE setClearcoatNormalStrength NOTIFY clearcoatNormalStrengthChanged REVISION(6, 8)) |
| 88 | |
| 89 | Q_PROPERTY(float transmissionFactor READ transmissionFactor WRITE setTransmissionFactor NOTIFY transmissionFactorChanged) |
| 90 | Q_PROPERTY(QQuick3DTexture * transmissionMap READ transmissionMap WRITE setTransmissionMap NOTIFY transmissionMapChanged) |
| 91 | Q_PROPERTY(QQuick3DMaterial::TextureChannelMapping transmissionChannel READ transmissionChannel WRITE setTransmissionChannel NOTIFY transmissionChannelChanged) |
| 92 | |
| 93 | Q_PROPERTY(float thicknessFactor READ thicknessFactor WRITE setThicknessFactor NOTIFY thicknessFactorChanged) |
| 94 | Q_PROPERTY(QQuick3DTexture *thicknessMap READ thicknessMap WRITE setThicknessMap NOTIFY thicknessMapChanged) |
| 95 | Q_PROPERTY(QQuick3DMaterial::TextureChannelMapping thicknessChannel READ thicknessChannel WRITE setThicknessChannel NOTIFY |
| 96 | thicknessChannelChanged) |
| 97 | Q_PROPERTY(float attenuationDistance READ attenuationDistance WRITE setAttenuationDistance NOTIFY attenuationDistanceChanged) |
| 98 | Q_PROPERTY(QColor attenuationColor READ attenuationColor WRITE setAttenuationColor NOTIFY attenuationColorChanged) |
| 99 | |
| 100 | Q_PROPERTY(bool vertexColorsEnabled READ vertexColorsEnabled WRITE setVertexColorsEnabled NOTIFY vertexColorsEnabledChanged REVISION(6, 5)) |
| 101 | |
| 102 | Q_PROPERTY(bool fresnelScaleBiasEnabled READ fresnelScaleBiasEnabled WRITE setFresnelScaleBiasEnabled NOTIFY fresnelScaleBiasEnabledChanged REVISION(6, 8)) |
| 103 | Q_PROPERTY(float fresnelScale READ fresnelScale WRITE setFresnelScale NOTIFY fresnelScaleChanged REVISION(6, 8)) |
| 104 | Q_PROPERTY(float fresnelBias READ fresnelBias WRITE setFresnelBias NOTIFY fresnelBiasChanged REVISION(6, 8)) |
| 105 | Q_PROPERTY(float fresnelPower READ fresnelPower WRITE setFresnelPower NOTIFY fresnelPowerChanged REVISION(6, 8)) |
| 106 | |
| 107 | Q_PROPERTY(bool clearcoatFresnelScaleBiasEnabled READ clearcoatFresnelScaleBiasEnabled WRITE setClearcoatFresnelScaleBiasEnabled NOTIFY clearcoatFresnelScaleBiasEnabledChanged REVISION(6, 8)) |
| 108 | Q_PROPERTY(float clearcoatFresnelScale READ clearcoatFresnelScale WRITE setClearcoatFresnelScale NOTIFY clearcoatFresnelScaleChanged REVISION(6, 8)) |
| 109 | Q_PROPERTY(float clearcoatFresnelBias READ clearcoatFresnelBias WRITE setClearcoatFresnelBias NOTIFY clearcoatFresnelBiasChanged REVISION(6, 8)) |
| 110 | Q_PROPERTY(float clearcoatFresnelPower READ clearcoatFresnelPower WRITE setClearcoatFresnelPower NOTIFY clearcoatFresnelPowerChanged REVISION(6, 8)) |
| 111 | |
| 112 | Q_PROPERTY(bool vertexColorsMaskEnabled READ vertexColorsMaskEnabled WRITE setVertexColorsMaskEnabled NOTIFY vertexColorsMaskEnabledChanged REVISION(6, 8)) |
| 113 | Q_PROPERTY(VertexColorMaskFlags vertexColorRedMask READ vertexColorRedMask WRITE setVertexColorRedMask NOTIFY vertexColorRedMaskChanged REVISION(6, 8)) |
| 114 | Q_PROPERTY(VertexColorMaskFlags vertexColorGreenMask READ vertexColorGreenMask WRITE setVertexColorGreenMask NOTIFY vertexColorGreenMaskChanged REVISION(6, 8)) |
| 115 | Q_PROPERTY(VertexColorMaskFlags vertexColorBlueMask READ vertexColorBlueMask WRITE setVertexColorBlueMask NOTIFY vertexColorBlueMaskChanged REVISION(6, 8)) |
| 116 | Q_PROPERTY(VertexColorMaskFlags vertexColorAlphaMask READ vertexColorAlphaMask WRITE setVertexColorAlphaMask NOTIFY vertexColorAlphaMaskChanged REVISION(6, 8)) |
| 117 | |
| 118 | QML_NAMED_ELEMENT(SpecularGlossyMaterial) |
| 119 | QML_ADDED_IN_VERSION(6, 4) |
| 120 | |
| 121 | public: |
| 122 | enum Lighting { |
| 123 | NoLighting = 0, |
| 124 | FragmentLighting |
| 125 | }; |
| 126 | Q_ENUM(Lighting) |
| 127 | |
| 128 | enum BlendMode { |
| 129 | SourceOver = 0, |
| 130 | Screen, |
| 131 | Multiply |
| 132 | }; |
| 133 | Q_ENUM(BlendMode) |
| 134 | |
| 135 | enum AlphaMode { |
| 136 | Default = 0, |
| 137 | Mask, |
| 138 | Blend, |
| 139 | Opaque |
| 140 | }; |
| 141 | Q_ENUM(AlphaMode) |
| 142 | |
| 143 | enum VertexColorMask { |
| 144 | NoMask = QQuick3DMaterial::NoMask, |
| 145 | GlossinessMask = QQuick3DMaterial::RoughnessMask, |
| 146 | NormalStrengthMask = QQuick3DMaterial::NormalStrengthMask, |
| 147 | ClearcoatAmountMask = QQuick3DMaterial::ClearcoatAmountMask, |
| 148 | ClearcoatRoughnessAmountMask = QQuick3DMaterial::ClearcoatRoughnessAmountMask, |
| 149 | ClearcoatNormalStrengthMask = QQuick3DMaterial::NormalStrengthMask, |
| 150 | HeightAmountMask = QQuick3DMaterial::HeightAmountMask, |
| 151 | OcclusionAmountMask = QQuick3DMaterial::OcclusionAmountMask, |
| 152 | ThicknessFactorMask = QQuick3DMaterial::ThicknessFactorMask, |
| 153 | TransmissionFactorMask = QQuick3DMaterial::TransmissionFactorMask |
| 154 | }; |
| 155 | Q_ENUM(VertexColorMask) |
| 156 | Q_DECLARE_FLAGS(VertexColorMaskFlags, VertexColorMask) |
| 157 | Q_FLAG(VertexColorMaskFlags) |
| 158 | |
| 159 | explicit QQuick3DSpecularGlossyMaterial(QQuick3DObject *parent = nullptr); |
| 160 | ~QQuick3DSpecularGlossyMaterial() override; |
| 161 | |
| 162 | Lighting lighting() const; |
| 163 | BlendMode blendMode() const; |
| 164 | QColor albedoColor() const; |
| 165 | QQuick3DTexture *albedoMap() const; |
| 166 | Q_REVISION(6, 8) bool albedoSingleChannelEnabled() const; |
| 167 | Q_REVISION(6, 8) TextureChannelMapping albedoChannel() const; |
| 168 | Q_REVISION(6, 8) bool specularSingleChannelEnabled() const; |
| 169 | Q_REVISION(6, 8) TextureChannelMapping specularChannel() const; |
| 170 | Q_REVISION(6, 8) bool emissiveSingleChannelEnabled() const; |
| 171 | Q_REVISION(6, 8) TextureChannelMapping emissiveChannel() const; |
| 172 | QQuick3DTexture *emissiveMap() const; |
| 173 | QVector3D emissiveFactor() const; |
| 174 | float glossiness() const; |
| 175 | QQuick3DTexture *glossinessMap() const; |
| 176 | Q_REVISION(6, 8) bool invertOpacityMapValue() const; |
| 177 | float opacity() const; |
| 178 | QQuick3DTexture *opacityMap() const; |
| 179 | QQuick3DTexture *normalMap() const; |
| 180 | QColor specularColor() const; |
| 181 | QQuick3DTexture *specularMap() const; |
| 182 | float normalStrength() const; |
| 183 | QQuick3DTexture *occlusionMap() const; |
| 184 | float occlusionAmount() const; |
| 185 | AlphaMode alphaMode() const; |
| 186 | float alphaCutoff() const; |
| 187 | TextureChannelMapping glossinessChannel() const; |
| 188 | TextureChannelMapping opacityChannel() const; |
| 189 | TextureChannelMapping occlusionChannel() const; |
| 190 | float pointSize() const; |
| 191 | float lineWidth() const; |
| 192 | QQuick3DTexture *heightMap() const; |
| 193 | TextureChannelMapping heightChannel() const; |
| 194 | float heightAmount() const; |
| 195 | int minHeightMapSamples() const; |
| 196 | int maxHeightMapSamples() const; |
| 197 | |
| 198 | float clearcoatAmount() const; |
| 199 | QQuick3DTexture *clearcoatMap() const; |
| 200 | TextureChannelMapping clearcoatChannel() const; |
| 201 | float clearcoatRoughnessAmount() const; |
| 202 | TextureChannelMapping clearcoatRoughnessChannel() const; |
| 203 | QQuick3DTexture *clearcoatRoughnessMap() const; |
| 204 | QQuick3DTexture *clearcoatNormalMap() const; |
| 205 | |
| 206 | float transmissionFactor() const; |
| 207 | QQuick3DTexture *transmissionMap() const; |
| 208 | TextureChannelMapping transmissionChannel() const; |
| 209 | |
| 210 | float thicknessFactor() const; |
| 211 | QQuick3DTexture *thicknessMap() const; |
| 212 | TextureChannelMapping thicknessChannel() const; |
| 213 | float attenuationDistance() const; |
| 214 | QColor attenuationColor() const; |
| 215 | |
| 216 | Q_REVISION(6, 8) bool fresnelScaleBiasEnabled() const; |
| 217 | Q_REVISION(6, 8) float fresnelScale() const; |
| 218 | Q_REVISION(6, 8) float fresnelBias() const; |
| 219 | Q_REVISION(6, 8) float fresnelPower() const; |
| 220 | |
| 221 | Q_REVISION(6, 8) bool clearcoatFresnelScaleBiasEnabled() const; |
| 222 | Q_REVISION(6, 8) float clearcoatFresnelScale() const; |
| 223 | Q_REVISION(6, 8) float clearcoatFresnelBias() const; |
| 224 | Q_REVISION(6, 8) float clearcoatFresnelPower() const; |
| 225 | |
| 226 | Q_REVISION(6, 5) bool vertexColorsEnabled() const; |
| 227 | Q_REVISION(6, 8) float clearcoatNormalStrength() const; |
| 228 | |
| 229 | Q_REVISION(6, 8) bool vertexColorsMaskEnabled() const; |
| 230 | Q_REVISION(6, 8) VertexColorMaskFlags vertexColorRedMask() const; |
| 231 | Q_REVISION(6, 8) VertexColorMaskFlags vertexColorGreenMask() const; |
| 232 | Q_REVISION(6, 8) VertexColorMaskFlags vertexColorBlueMask() const; |
| 233 | Q_REVISION(6, 8) VertexColorMaskFlags vertexColorAlphaMask() const; |
| 234 | |
| 235 | public Q_SLOTS: |
| 236 | void setLighting(QQuick3DSpecularGlossyMaterial::Lighting lighting); |
| 237 | void setBlendMode(QQuick3DSpecularGlossyMaterial::BlendMode blendMode); |
| 238 | void setAlbedoColor(const QColor &albedo); |
| 239 | void setAlbedoMap(QQuick3DTexture *albedoMap); |
| 240 | Q_REVISION(6, 8) void setAlbedoSingleChannelEnabled(bool albedoSingleChannelEnabled); |
| 241 | Q_REVISION(6, 8) void setAlbedoChannel(QQuick3DMaterial::TextureChannelMapping channel); |
| 242 | Q_REVISION(6, 8) void setSpecularSingleChannelEnabled(bool specularSingleChannelEnabled); |
| 243 | Q_REVISION(6, 8) void setSpecularChannel(QQuick3DMaterial::TextureChannelMapping channel); |
| 244 | Q_REVISION(6, 8) void setEmissiveSingleChannelEnabled(bool emissiveSingleChannelEnabled); |
| 245 | Q_REVISION(6, 8) void setEmissiveChannel(QQuick3DMaterial::TextureChannelMapping channel); |
| 246 | void setEmissiveMap(QQuick3DTexture *emissiveMap); |
| 247 | void setEmissiveFactor(const QVector3D &emissiveFactor); |
| 248 | void setGlossiness(float glossiness); |
| 249 | void setGlossinessMap(QQuick3DTexture *glossinessMap); |
| 250 | Q_REVISION(6, 8) void setInvertOpacityMapValue(bool invertOpacityMapValue); |
| 251 | void setOpacity(float opacity); |
| 252 | void setOpacityMap(QQuick3DTexture *opacityMap); |
| 253 | void setNormalMap(QQuick3DTexture *normalMap); |
| 254 | void setSpecularColor(const QColor &specular); |
| 255 | void setSpecularMap(QQuick3DTexture *specularMap); |
| 256 | void setNormalStrength(float normalStrength); |
| 257 | void setOcclusionMap(QQuick3DTexture *occlusionMap); |
| 258 | void setOcclusionAmount(float occlusionAmount); |
| 259 | void setAlphaMode(QQuick3DSpecularGlossyMaterial::AlphaMode alphaMode); |
| 260 | void setAlphaCutoff(float alphaCutoff); |
| 261 | void setGlossinessChannel(QQuick3DMaterial::TextureChannelMapping channel); |
| 262 | void setOpacityChannel(QQuick3DMaterial::TextureChannelMapping channel); |
| 263 | void setOcclusionChannel(QQuick3DMaterial::TextureChannelMapping channel); |
| 264 | void setPointSize(float size); |
| 265 | void setLineWidth(float width); |
| 266 | void setHeightMap(QQuick3DTexture *heightMap); |
| 267 | void setHeightChannel(QQuick3DMaterial::TextureChannelMapping channel); |
| 268 | void setHeightAmount(float heightAmount); |
| 269 | void setMinHeightMapSamples(int samples); |
| 270 | void setMaxHeightMapSamples(int samples); |
| 271 | |
| 272 | void setClearcoatAmount(float newClearcoatAmount); |
| 273 | void setClearcoatMap(QQuick3DTexture *newClearcoatMap); |
| 274 | void setClearcoatChannel(QQuick3DMaterial::TextureChannelMapping newClearcoatChannel); |
| 275 | void setClearcoatRoughnessAmount(float newClearcoatRoughnessAmount); |
| 276 | void setClearcoatRoughnessChannel(QQuick3DMaterial::TextureChannelMapping newClearcoatRoughnessChannel); |
| 277 | void setClearcoatRoughnessMap(QQuick3DTexture *newClearcoatRoughnessMap); |
| 278 | void setClearcoatNormalMap(QQuick3DTexture *newClearcoatNormalMap); |
| 279 | Q_REVISION(6, 8) void setClearcoatNormalStrength( float newClearcoatNormalStrength ); |
| 280 | |
| 281 | void setTransmissionFactor(float newTransmissionFactor); |
| 282 | void setTransmissionMap(QQuick3DTexture *newTransmissionMap); |
| 283 | void setTransmissionChannel(QQuick3DMaterial::TextureChannelMapping newTransmissionChannel); |
| 284 | |
| 285 | void setThicknessFactor(float newThicknessFactor); |
| 286 | void setThicknessMap(QQuick3DTexture *newThicknessMap); |
| 287 | void setThicknessChannel(QQuick3DMaterial::TextureChannelMapping newThicknessChannel); |
| 288 | void setAttenuationDistance(float newAttenuationDistance); |
| 289 | void setAttenuationColor(const QColor &newAttenuationColor); |
| 290 | |
| 291 | Q_REVISION(6, 8) void setFresnelScaleBiasEnabled(bool fresnelScaleBias); |
| 292 | Q_REVISION(6, 8) void setFresnelScale(float fresnelScale); |
| 293 | Q_REVISION(6, 8) void setFresnelBias(float fresnelBias); |
| 294 | Q_REVISION(6, 8) void setFresnelPower(float fresnelPower); |
| 295 | |
| 296 | Q_REVISION(6, 8) void setClearcoatFresnelScaleBiasEnabled(bool clearcoatFresnelScaleBias); |
| 297 | Q_REVISION(6, 8) void setClearcoatFresnelScale(float clearcoatFresnelScale); |
| 298 | Q_REVISION(6, 8) void setClearcoatFresnelBias(float clearcoatFresnelBias); |
| 299 | Q_REVISION(6, 8) void setClearcoatFresnelPower(float clearcoatFresnelPower); |
| 300 | |
| 301 | Q_REVISION(6, 5) void setVertexColorsEnabled(bool vertexColorsEnabled); |
| 302 | |
| 303 | Q_REVISION(6, 8) void setVertexColorsMaskEnabled(bool vertexColorsMaskEnabled); |
| 304 | Q_REVISION(6, 8) void setVertexColorRedMask(VertexColorMaskFlags vertexColorRedMask); |
| 305 | Q_REVISION(6, 8) void setVertexColorGreenMask(VertexColorMaskFlags vertexColorGreenMask); |
| 306 | Q_REVISION(6, 8) void setVertexColorBlueMask(VertexColorMaskFlags vertexColorBlueMask); |
| 307 | Q_REVISION(6, 8) void setVertexColorAlphaMask(VertexColorMaskFlags vertexColorAlphaMask); |
| 308 | |
| 309 | Q_SIGNALS: |
| 310 | void lightingChanged(); |
| 311 | void blendModeChanged(); |
| 312 | void albedoColorChanged(); |
| 313 | void albedoMapChanged(); |
| 314 | Q_REVISION(6, 8) void albedoSingleChannelEnabledChanged(); |
| 315 | Q_REVISION(6, 8) void albedoChannelChanged(); |
| 316 | Q_REVISION(6, 8) void specularSingleChannelEnabledChanged(); |
| 317 | Q_REVISION(6, 8) void specularChannelChanged(); |
| 318 | Q_REVISION(6, 8) void emissiveSingleChannelEnabledChanged(); |
| 319 | Q_REVISION(6, 8) void emissiveChannelChanged(); |
| 320 | void emissiveMapChanged(); |
| 321 | void emissiveFactorChanged(); |
| 322 | void glossinessChanged(); |
| 323 | void glossinessMapChanged(); |
| 324 | Q_REVISION(6, 8) void invertOpacityMapValueChanged(); |
| 325 | void opacityChanged(); |
| 326 | void opacityMapChanged(); |
| 327 | void normalMapChanged(); |
| 328 | void specularColorChanged(); |
| 329 | void specularMapChanged(); |
| 330 | void normalStrengthChanged(); |
| 331 | void occlusionMapChanged(); |
| 332 | void occlusionAmountChanged(); |
| 333 | void alphaModeChanged(); |
| 334 | void alphaCutoffChanged(); |
| 335 | void glossinessChannelChanged(); |
| 336 | void opacityChannelChanged(); |
| 337 | void occlusionChannelChanged(); |
| 338 | void pointSizeChanged(); |
| 339 | void lineWidthChanged(); |
| 340 | void heightMapChanged(); |
| 341 | void heightChannelChanged(); |
| 342 | void heightAmountChanged(); |
| 343 | void minHeightMapSamplesChanged(); |
| 344 | void maxHeightMapSamplesChanged(); |
| 345 | |
| 346 | void clearcoatAmountChanged(); |
| 347 | void clearcoatMapChanged(); |
| 348 | void clearcoatChannelChanged(); |
| 349 | void clearcoatRoughnessAmountChanged(); |
| 350 | void clearcoatRoughnessChannelChanged(); |
| 351 | void clearcoatRoughnessMapChanged(); |
| 352 | void clearcoatNormalMapChanged(); |
| 353 | void clearcoatNormalStrengthChanged(); |
| 354 | |
| 355 | void transmissionFactorChanged(); |
| 356 | void transmissionMapChanged(); |
| 357 | void transmissionChannelChanged(); |
| 358 | |
| 359 | void thicknessFactorChanged(); |
| 360 | void thicknessMapChanged(); |
| 361 | void thicknessChannelChanged(); |
| 362 | void attenuationDistanceChanged(); |
| 363 | void attenuationColorChanged(); |
| 364 | |
| 365 | Q_REVISION(6, 5) void vertexColorsEnabledChanged(bool vertexColorsEnabled); |
| 366 | |
| 367 | Q_REVISION(6, 8) void fresnelScaleBiasEnabledChanged(bool fresnelScaleBiasEnabled); |
| 368 | Q_REVISION(6, 8) void fresnelScaleChanged(float fresnelScale); |
| 369 | Q_REVISION(6, 8) void fresnelBiasChanged(float fresnelBias); |
| 370 | Q_REVISION(6, 8) void fresnelPowerChanged(float fresnelPower); |
| 371 | |
| 372 | Q_REVISION(6, 8) void clearcoatFresnelScaleBiasEnabledChanged(bool clearcoatFresnelScaleBiasEnabled); |
| 373 | Q_REVISION(6, 8) void clearcoatFresnelScaleChanged(float clearcoatFresnelScale); |
| 374 | Q_REVISION(6, 8) void clearcoatFresnelBiasChanged(float clearcoatFresnelBias); |
| 375 | Q_REVISION(6, 8) void clearcoatFresnelPowerChanged(float clearcoatFresnelPower); |
| 376 | |
| 377 | Q_REVISION(6, 8) void vertexColorsMaskEnabledChanged(); |
| 378 | Q_REVISION(6, 8) void vertexColorRedMaskChanged(); |
| 379 | Q_REVISION(6, 8) void vertexColorGreenMaskChanged(); |
| 380 | Q_REVISION(6, 8) void vertexColorBlueMaskChanged(); |
| 381 | Q_REVISION(6, 8) void vertexColorAlphaMaskChanged(); |
| 382 | |
| 383 | protected: |
| 384 | QSSGRenderGraphObject *updateSpatialNode(QSSGRenderGraphObject *node) override; |
| 385 | void markAllDirty() override; |
| 386 | void itemChange(ItemChange, const ItemChangeData &) override; |
| 387 | private: |
| 388 | |
| 389 | enum DirtyType { |
| 390 | LightingModeDirty = 0x00000001, |
| 391 | BlendModeDirty = 0x00000002, |
| 392 | AlbedoDirty = 0x00000004, |
| 393 | EmissiveDirty = 0x00000008, |
| 394 | SpecularDirty = 0x00000010, |
| 395 | OpacityDirty = 0x00000020, |
| 396 | NormalDirty = 0x00000040, |
| 397 | GlossyDirty = 0x00000080, |
| 398 | OcclusionDirty = 0x00000100, |
| 399 | AlphaModeDirty = 0x00000200, |
| 400 | PointSizeDirty = 0x00000400, |
| 401 | LineWidthDirty = 0x00000800, |
| 402 | HeightDirty = 0x00001000, |
| 403 | ClearcoatDirty = 0x00002000, |
| 404 | TransmissionDirty = 0x00004000, |
| 405 | VolumeDirty = 0x00008000, |
| 406 | VertexColorsDirty = 0x00001000 |
| 407 | }; |
| 408 | |
| 409 | void updateSceneManager(QQuick3DSceneManager *window); |
| 410 | |
| 411 | Lighting m_lighting = FragmentLighting; |
| 412 | BlendMode m_blendMode = SourceOver; |
| 413 | AlphaMode m_alphaMode = Default; |
| 414 | QColor m_albedo = Qt::white; |
| 415 | QQuick3DTexture *m_albedoMap = nullptr; |
| 416 | bool m_albedoSingleChannelEnabled = false; |
| 417 | TextureChannelMapping m_albedoChannel = QQuick3DMaterial::R; |
| 418 | bool m_specularSingleChannelEnabled = false; |
| 419 | TextureChannelMapping m_specularChannel = QQuick3DMaterial::R; |
| 420 | bool m_emissiveSingleChannelEnabled = false; |
| 421 | TextureChannelMapping m_emissiveChannel = QQuick3DMaterial::R; |
| 422 | QVector3D m_emissiveFactor; |
| 423 | QQuick3DTexture *m_emissiveMap = nullptr; |
| 424 | QQuick3DTexture *m_glossinessMap = nullptr; |
| 425 | QQuick3DTexture *m_opacityMap = nullptr; |
| 426 | QQuick3DTexture *m_normalMap = nullptr; |
| 427 | QQuick3DTexture *m_specularMap = nullptr; |
| 428 | QQuick3DTexture *m_occlusionMap = nullptr; |
| 429 | float m_glossiness = 1.0f; |
| 430 | bool m_invertOpacityMapValue = false; |
| 431 | float m_opacity = 1.0f; |
| 432 | QColor m_specular = Qt::white; |
| 433 | float m_normalStrength = 1.0f; |
| 434 | float m_occlusionAmount = 1.0f; |
| 435 | float m_alphaCutoff = 0.5f; |
| 436 | TextureChannelMapping m_glossinessChannel = QQuick3DMaterial::A; |
| 437 | TextureChannelMapping m_opacityChannel = QQuick3DMaterial::A; |
| 438 | TextureChannelMapping m_occlusionChannel = QQuick3DMaterial::R; |
| 439 | float m_pointSize = 1.0f; |
| 440 | float m_lineWidth = 1.0f; |
| 441 | QQuick3DTexture *m_heightMap = nullptr; |
| 442 | TextureChannelMapping m_heightChannel = QQuick3DMaterial::R; |
| 443 | float m_heightAmount = 0.0f; |
| 444 | int m_minHeightMapSamples = 8; |
| 445 | int m_maxHeightMapSamples = 32; |
| 446 | float m_clearcoatAmount = 0.0f; |
| 447 | QQuick3DTexture *m_clearcoatMap = nullptr; |
| 448 | TextureChannelMapping m_clearcoatChannel = QQuick3DMaterial::R; |
| 449 | float m_clearcoatRoughnessAmount = 0.0f; |
| 450 | TextureChannelMapping m_clearcoatRoughnessChannel = QQuick3DMaterial::G; |
| 451 | QQuick3DTexture *m_clearcoatRoughnessMap = nullptr; |
| 452 | QQuick3DTexture *m_clearcoatNormalMap = nullptr; |
| 453 | float m_clearcoatNormalStrength = 1.0f; |
| 454 | float m_transmissionFactor = 0.0f; |
| 455 | QQuick3DTexture *m_transmissionMap = nullptr; |
| 456 | TextureChannelMapping m_transmissionChannel = QQuick3DMaterial::R; |
| 457 | float m_thicknessFactor = 0.0f; |
| 458 | QQuick3DTexture *m_thicknessMap = nullptr; |
| 459 | TextureChannelMapping m_thicknessChannel = QQuick3DMaterial::G; |
| 460 | float m_attenuationDistance = std::numeric_limits<float>::infinity(); |
| 461 | QColor m_attenuationColor = Qt::white; |
| 462 | bool m_fresnelScaleBiasEnabled = false; |
| 463 | float m_fresnelScale = 1.0f; |
| 464 | float m_fresnelBias = 0.0f; |
| 465 | float m_fresnelPower = 5.0f; |
| 466 | bool m_clearcoatFresnelScaleBiasEnabled = false; |
| 467 | float m_clearcoatFresnelScale = 1.0f; |
| 468 | float m_clearcoatFresnelBias = 0.0f; |
| 469 | float m_clearcoatFresnelPower = 5.0f; |
| 470 | bool m_vertexColorsEnabled = true; |
| 471 | bool m_vertexColorsMaskEnabled = false; |
| 472 | VertexColorMaskFlags m_vertexColorRedMask = NoMask; |
| 473 | VertexColorMaskFlags m_vertexColorGreenMask = NoMask; |
| 474 | VertexColorMaskFlags m_vertexColorBlueMask = NoMask; |
| 475 | VertexColorMaskFlags m_vertexColorAlphaMask = NoMask; |
| 476 | |
| 477 | quint32 m_dirtyAttributes = 0xffffffff; // all dirty by default |
| 478 | void markDirty(DirtyType type); |
| 479 | |
| 480 | static constexpr float ensureNormalized(float val) { return qBound(min: 0.0f, val, max: 1.0f); } |
| 481 | }; |
| 482 | |
| 483 | QT_END_NAMESPACE |
| 484 | |
| 485 | #endif // QQUICK3DSPECULARGLOSSYMATERIAL_P_H |
| 486 | |