diff options
author | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2014-09-01 14:45:05 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2014-09-02 09:11:56 +0300 |
commit | 3c2d0623c74cc51d0c3b73e0b56b5f5052676ee4 (patch) | |
tree | a808859fae11c73df396768f5783c10b66d16592 /src/datavisualization/data/qcustom3dvolume.cpp | |
parent | a20806dac74415f3d8cb6679c9eae86ce074ddae (diff) |
Add option to use low definition volume shader.
Low definition volume shader samples the texture at even
intervals, so it will sometimes skip texels, causing flickering.
Change-Id: Iee6cb0e8893498b89ce1a40f34701a53d100283e
Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
Diffstat (limited to 'src/datavisualization/data/qcustom3dvolume.cpp')
-rw-r--r-- | src/datavisualization/data/qcustom3dvolume.cpp | 58 |
1 files changed, 56 insertions, 2 deletions
diff --git a/src/datavisualization/data/qcustom3dvolume.cpp b/src/datavisualization/data/qcustom3dvolume.cpp index 503d324d..789b7718 100644 --- a/src/datavisualization/data/qcustom3dvolume.cpp +++ b/src/datavisualization/data/qcustom3dvolume.cpp @@ -136,6 +136,24 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION */ /*! + * \qmlproperty bool Custom3DVolume::useHighDefShader + * + * If this property value is \c{true}, a high definition shader is used to render the volume. + * If it is \c{false}, a low definition shader is used. + * + * The high definition shader guarantees that every visible texel of the volume texture is sampled + * when the volume is rendered. + * The low definition shader renders only a rough approximation of the volume contents, + * but at much higher frame rate. The low definition shader doesn't guarantee every texel of the + * volume texture is sampled, so there may be flickering if the volume contains distinct thin + * features. + * + * \note This value doesn't affect the level of detail when rendering the slices of the volume. + * + * Defaults to \c{true}. + */ + +/*! * Constructs QCustom3DVolume with given \a parent. */ QCustom3DVolume::QCustom3DVolume(QObject *parent) : @@ -673,6 +691,40 @@ bool QCustom3DVolume::preserveOpacity() const } /*! + * \property QCustom3DVolume::useHighDefShader + * + * If this property value is \c{true}, a high definition shader is used to render the volume. + * If it is \c{false}, a low definition shader is used. + * + * The high definition shader guarantees that every visible texel of the volume texture is sampled + * when the volume is rendered. + * The low definition shader renders only a rough approximation of the volume contents, + * but at much higher frame rate. The low definition shader doesn't guarantee every texel of the + * volume texture is sampled, so there may be flickering if the volume contains distinct thin + * features. + * + * \note This value doesn't affect the level of detail when rendering the slices of the volume. + * + * Defaults to \c{true}. + * + * \sa renderSlice() + */ +void QCustom3DVolume::setUseHighDefShader(bool enable) +{ + if (dptr()->m_useHighDefShader != enable) { + dptr()->m_useHighDefShader = enable; + dptr()->m_dirtyBitsVolume.shaderDirty = true; + emit useHighDefShaderChanged(enable); + emit dptr()->needUpdate(); + } +} + +bool QCustom3DVolume::useHighDefShader() const +{ + return dptrc()->m_useHighDefShader; +} + +/*! * Renders the slice specified by \a index along \a axis into an image. * The texture format of this object is used. * @@ -712,7 +764,8 @@ QCustom3DVolumePrivate::QCustom3DVolumePrivate(QCustom3DVolume *q) : m_textureFormat(QImage::Format_ARGB32), m_textureData(0), m_alphaMultiplier(1.0f), - m_preserveOpacity(true) + m_preserveOpacity(true), + m_useHighDefShader(true) { m_isVolumeItem = true; m_meshFile = QStringLiteral(":/defaultMeshes/barFull"); @@ -736,7 +789,8 @@ QCustom3DVolumePrivate::QCustom3DVolumePrivate(QCustom3DVolume *q, const QVector m_colorTable(colorTable), m_textureData(textureData), m_alphaMultiplier(1.0f), - m_preserveOpacity(true) + m_preserveOpacity(true), + m_useHighDefShader(true) { m_isVolumeItem = true; m_shadowCasting = false; |