diff options
Diffstat (limited to 'src/quick3d')
-rw-r--r-- | src/quick3d/qquick3dlightmapper.cpp | 28 | ||||
-rw-r--r-- | src/quick3d/qquick3dlightmapper_p.h | 5 | ||||
-rw-r--r-- | src/quick3d/qquick3dmodel.cpp | 59 | ||||
-rw-r--r-- | src/quick3d/qquick3dmodel_p.h | 7 | ||||
-rw-r--r-- | src/quick3d/qquick3dscenerenderer.cpp | 1 |
5 files changed, 70 insertions, 30 deletions
diff --git a/src/quick3d/qquick3dlightmapper.cpp b/src/quick3d/qquick3dlightmapper.cpp index 4fb375a6..5b1c362d 100644 --- a/src/quick3d/qquick3dlightmapper.cpp +++ b/src/quick3d/qquick3dlightmapper.cpp @@ -34,7 +34,7 @@ QT_BEGIN_NAMESPACE \list \li \l Model::bakedLightmap and the associated \l BakedLightmap, - \li \l Model::usedInBakedLighting and \l Model::lightmapBaseResolution, + \li \l Model::usedInBakedLighting and \l Model::texelsPerUnit, \li \l Light::bakeMode, \li the engine's built-in lightmap baker. \endlist @@ -190,6 +190,18 @@ QT_BEGIN_NAMESPACE while still removing the noise. */ +/*! + \qmlproperty real Lightmapper::texelsPerUnit + \since 6.10 + \default 1 + + This property defines the unit to texel scale, meaning a \c{1x1} quad with + texelsPerUnit of \c{32} will take up approximately \c{32x32} texels in the + lightmap. + + \sa Model::texelsPerUnit +*/ + float QQuick3DLightmapper::opacityThreshold() const { return m_opacityThreshold; @@ -339,4 +351,18 @@ void QQuick3DLightmapper::setDenoiseSigma(float newDenoiseSigma) emit changed(); } +float QQuick3DLightmapper::texelsPerUnit() const +{ + return m_texelsPerUnit; +} + +void QQuick3DLightmapper::setTexelsPerUnit(float newTexelsPerUnit) +{ + if (qFuzzyCompare(m_texelsPerUnit, newTexelsPerUnit)) + return; + m_texelsPerUnit = newTexelsPerUnit; + emit texelsPerUnitChanged(); + emit changed(); +} + QT_END_NAMESPACE diff --git a/src/quick3d/qquick3dlightmapper_p.h b/src/quick3d/qquick3dlightmapper_p.h index 0ae204ef..9b0dccce 100644 --- a/src/quick3d/qquick3dlightmapper_p.h +++ b/src/quick3d/qquick3dlightmapper_p.h @@ -32,6 +32,7 @@ class Q_QUICK3D_EXPORT QQuick3DLightmapper : public QObject Q_PROPERTY(float indirectLightFactor READ indirectLightFactor WRITE setIndirectLightFactor NOTIFY indirectLightFactorChanged) Q_PROPERTY(QString source READ source WRITE setSource NOTIFY sourceChanged FINAL REVISION(6, 10)) Q_PROPERTY(float denoiseSigma READ denoiseSigma WRITE setDenoiseSigma NOTIFY denoiseSigmaChanged FINAL REVISION(6, 10)) + Q_PROPERTY(float texelsPerUnit READ texelsPerUnit WRITE setTexelsPerUnit NOTIFY texelsPerUnitChanged FINAL REVISION(6, 10)) QML_NAMED_ELEMENT(Lightmapper) @@ -46,6 +47,7 @@ public: float indirectLightFactor() const; Q_REVISION(6, 10) QString source() const; Q_REVISION(6, 10) float denoiseSigma() const; + Q_REVISION(6, 10) float texelsPerUnit() const; public Q_SLOTS: void setOpacityThreshold(float opacity); @@ -58,6 +60,7 @@ public Q_SLOTS: void setIndirectLightFactor(float factor); Q_REVISION(6, 10) void setSource(const QString &source); Q_REVISION(6, 10) void setDenoiseSigma(float newDenoiseSigma); + Q_REVISION(6, 10) void setTexelsPerUnit(float newTexelsPerUnit); Q_SIGNALS: void changed(); @@ -71,6 +74,7 @@ Q_SIGNALS: void indirectLightFactorChanged(); Q_REVISION(6, 10) void sourceChanged(); Q_REVISION(6, 10) void denoiseSigmaChanged(); + Q_REVISION(6, 10) void texelsPerUnitChanged(); private: // keep the defaults in sync with the default values in QSSGLightmapperOptions @@ -84,6 +88,7 @@ private: float m_indirectFactor = 1.0f; QString m_source = QStringLiteral("lightmaps.bin"); float m_denoiseSigma = 8.f; + float m_texelsPerUnit = 1.f; }; QT_END_NAMESPACE diff --git a/src/quick3d/qquick3dmodel.cpp b/src/quick3d/qquick3dmodel.cpp index 99048635..f72586ae 100644 --- a/src/quick3d/qquick3dmodel.cpp +++ b/src/quick3d/qquick3dmodel.cpp @@ -472,34 +472,7 @@ bool QQuick3DModel::isUsedInBakedLighting() const /*! \qmlproperty int Model::lightmapBaseResolution - Defines the approximate size of the lightmap for this model. The default - value is 1024, indicating 1024x1024 as the base size. The actual size of - the lightmap texture is likely to be different, often bigger, depending on - the mesh. - - For simpler, smaller meshes, or when it is known that using a bigger - lightmap is unnecessary, the value can be set to something smaller, for - example, 512 or 256. - - The minimum value is 128. - - This setting applies both to persistently stored and for intermediate, - partial lightmaps. When baking lightmaps, all models that have \l - usedInBakedLighting enabled are part of the path-traced scene. Thus all of - them need to have lightmap UV unwrapping performed and the rasterization - steps necessary to compute direct lighting which then can be taken into - account for indirect light bounces in the scene. However, for models that - just contribute to, but do not store a lightmap the default value is often - sufficient. Fine-tuning is more relevant for models that store and then use - the generated lightmaps. - - This property is relevant only when baking lightmaps. It has no effect - afterwards, when using the generated lightmaps during rendering. - - Models that have lightmap UV data pre-generated during asset import time - (e.g. via the balsam tool) will ignore this property because the lightmap - UV unwrapping and the lightmap size hint evaluation have already been done, - and will not be performed again during lightmap baking. + \deprecated [6.10] This has no effect. Use Model::texelsPerUnit instead. */ int QQuick3DModel::lightmapBaseResolution() const { @@ -748,6 +721,8 @@ void QQuick3DModel::setLightmapBaseResolution(int resolution) if (m_lightmapBaseResolution == resolution) return; + qWarning() << "Model::lightmapBaseResolution is deprecated and will have no effect."; + m_lightmapBaseResolution = resolution; emit lightmapBaseResolutionChanged(); markDirty(PropertyDirty); @@ -927,7 +902,7 @@ QSSGRenderGraphObject *QQuick3DModel::updateSpatialNode(QSSGRenderGraphObject *n if (m_dirtyAttributes & PropertyDirty) { modelNode->m_depthBiasSq = QSSGRenderModel::signedSquared(m_depthBias); modelNode->usedInBakedLighting = m_usedInBakedLighting; - modelNode->lightmapBaseResolution = uint(m_lightmapBaseResolution); + modelNode->texelsPerUnit = m_texelsPerUnit; if (m_bakedLightmap && m_bakedLightmap->isEnabled()) { modelNode->lightmapKey = m_bakedLightmap->key(); } else { @@ -1198,4 +1173,30 @@ void QQuick3DModel::setLevelOfDetailBias(float newLevelOfDetailBias) markDirty(QQuick3DModel::PropertyDirty); } +/*! + \qmlproperty real Model::texelsPerUnit + \since 6.10 + \default 0.0 + + A value greater than zero means this value will override the + SceneEnvironment::texelsPerUnit value for this specific model during + lightmap baking. + + \sa SceneEnvironment::texelsPerUnit +*/ + +float QQuick3DModel::texelsPerUnit() const +{ + return m_texelsPerUnit; +} + +void QQuick3DModel::setTexelsPerUnit(float newTexelsPerUnit) +{ + if (qFuzzyCompare(m_texelsPerUnit, newTexelsPerUnit)) + return; + m_texelsPerUnit = newTexelsPerUnit; + emit texelsPerUnitChanged(); + markDirty(PropertyDirty); +} + QT_END_NAMESPACE diff --git a/src/quick3d/qquick3dmodel_p.h b/src/quick3d/qquick3dmodel_p.h index c884d4ff..643cb077 100644 --- a/src/quick3d/qquick3dmodel_p.h +++ b/src/quick3d/qquick3dmodel_p.h @@ -82,6 +82,7 @@ class Q_QUICK3D_EXPORT QQuick3DModel : public QQuick3DNode Q_PROPERTY(float instancingLodMin READ instancingLodMin WRITE setInstancingLodMin NOTIFY instancingLodMinChanged REVISION(6, 5)) Q_PROPERTY(float instancingLodMax READ instancingLodMax WRITE setInstancingLodMax NOTIFY instancingLodMaxChanged REVISION(6, 5)) Q_PROPERTY(float levelOfDetailBias READ levelOfDetailBias WRITE setLevelOfDetailBias NOTIFY levelOfDetailBiasChanged REVISION(6, 5)) + Q_PROPERTY(float texelsPerUnit READ texelsPerUnit WRITE setTexelsPerUnit NOTIFY texelsPerUnitChanged FINAL REVISION(6, 10)) QML_NAMED_ELEMENT(Model) @@ -119,6 +120,9 @@ public: Q_REVISION(6, 5) float instancingLodMax() const; Q_REVISION(6, 5) float levelOfDetailBias() const; + Q_REVISION(6, 10) float texelsPerUnit() const; + Q_REVISION(6, 10) void setTexelsPerUnit(float newTexelsPerUnit); + public Q_SLOTS: void setSource(const QUrl &source); void setCastsShadows(bool castsShadows); @@ -166,6 +170,8 @@ Q_SIGNALS: Q_REVISION(6, 5) void instancingLodMaxChanged(); Q_REVISION(6, 5) void levelOfDetailBiasChanged(); + Q_REVISION(6, 10) void texelsPerUnitChanged(); + protected: QSSGRenderGraphObject *updateSpatialNode(QSSGRenderGraphObject *node) override; void markAllDirty() override; @@ -238,6 +244,7 @@ private: float m_instancingLodMin = -1; float m_instancingLodMax = -1; float m_levelOfDetailBias = 1.0f; + float m_texelsPerUnit = 0.0f; }; QT_END_NAMESPACE diff --git a/src/quick3d/qquick3dscenerenderer.cpp b/src/quick3d/qquick3dscenerenderer.cpp index 95cf6859..8321b766 100644 --- a/src/quick3d/qquick3dscenerenderer.cpp +++ b/src/quick3d/qquick3dscenerenderer.cpp @@ -1270,6 +1270,7 @@ void QQuick3DSceneRenderer::updateLayerNode(QSSGRenderLayer &layerNode, layerNode.lmOptions.indirectLightFactor = lightmapper->indirectLightFactor(); layerNode.lmOptions.source = lightmapper->source(); layerNode.lmOptions.sigma = lightmapper->denoiseSigma(); + layerNode.lmOptions.texelsPerUnit = lightmapper->texelsPerUnit(); } else { layerNode.lmOptions = {}; } |