5#include <QtQuick3DRuntimeRender/private/qssgrendercustommaterial_p.h>
6#include <QtQuick3DRuntimeRender/private/qssgrendercontextcore_p.h>
7#include <QtQuick3DRuntimeRender/private/qssgshadermaterialadapter_p.h>
8#include <QtQuick/QQuickWindow>
1316 if (m_srcBlend ==
mode)
1331 if (m_dstBlend ==
mode)
1341 return m_shadingMode;
1346 if (m_shadingMode ==
mode)
1349 m_shadingMode =
mode;
1356 return m_vertexShader;
1361 if (m_vertexShader ==
url)
1364 m_vertexShader =
url;
1371 return m_fragmentShader;
1376 if (m_fragmentShader ==
url)
1379 m_fragmentShader =
url;
1393 m_lineWidth =
width;
1414 return m_alwaysDirty;
1458 if (!renderContext) {
1459 qWarning(
"QQuick3DCustomMaterial: No render context interface?");
1465 bool newBackendNode =
false;
1466 bool shadersMayChange =
false;
1467 if (!customMaterial) {
1469 newBackendNode =
true;
1471 shadersMayChange =
true;
1474 if (newBackendNode || shadersMayChange) {
1483 const int idx =
metaObject()->indexOfSlot(
"onPropertyDirty()");
1485 propertyDirtyMethod =
metaObject()->method(idx);
1488 int propOffset =
metaObject()->propertyOffset();
1492 while (superClass &&
qstrcmp(superClass->
className(),
"QQuick3DCustomMaterial") != 0) {
1505 const auto name =
property.name();
1506 QMetaType propType =
property.metaType();
1507 QVariant propValue =
property.read(
this);
1512 if (propType.
id() == qMetaTypeId<QQuick3DShaderUtilsTextureInput *>()) {
1516 }
else if (propType ==
QMetaType(QMetaType::QObjectStar)) {
1520 const auto type = uniformType(propType);
1522 uniforms.
append({ uniformTypeName(propType),
name });
1524 if (newBackendNode) {
1545 if (newBackendNode) {
1561 for (
const auto &textureProperty : std::as_const(textureProperties))
1562 processTextureProperty(*textureProperty.first, textureProperty.second);
1573 if (propType.
id() == qMetaTypeId<QQuick3DShaderUtilsTextureInput *>()) {
1577 }
else if (propType.
id() == QMetaType::QObjectStar) {
1581 const auto type = uniformType(propType);
1583 uniforms.
append({ uniformTypeName(propType),
name });
1585 uniformType(propType), -1 });
1590 qWarning(
"No known uniform conversion found for custom material property %s. Skipping",
name.constData());
1595 for (
const auto &
property : std::as_const(textureProperties))
1602 QByteArray shaderPathKey(
"custom material --");
1606 if (!m_vertexShader.
isEmpty()) {
1614 vertex.
append(shaderCodeMeta);
1615 vertexMeta =
result.second;
1623 if (!m_fragmentShader.
isEmpty()) {
1631 fragment.
append(shaderCodeMeta);
1632 fragmentMeta =
result.second;
1661 customMaterial->setAlwaysDirty(m_alwaysDirty);
1662 if (m_srcBlend != BlendMode::NoBlend && m_dstBlend != BlendMode::NoBlend) {
1669 customMaterial->m_lineWidth = m_lineWidth;
1673 if (m_dirtyAttributes & Dirty::PropertyDirty) {
1674 for (
auto &prop : customMaterial->m_properties) {
1677 prop.value =
p.read(
this);
1681 if (m_dirtyAttributes & Dirty::TextureDirty) {
1685 if (prop.texInput->enabled)
1688 prop.texImage =
nullptr;
1703 prop.texImage =
nullptr;
1706 if (tex != prop.lastConnectedTexture) {
1707 prop.lastConnectedTexture = tex;
1711 disconnect(prop.horizontalTilingChangedConn);
1724 m_dirtyAttributes = 0;
1726 return customMaterial;
1732 if (change == QQuick3DObject::ItemSceneChange) {
1733 if (
auto sceneManager =
value.sceneManager) {
1734 for (
const auto &
it : std::as_const(m_dynamicTextureMaps)) {
1735 if (
auto tex =
it->texture())
1739 for (
const auto &
it : std::as_const(m_dynamicTextureMaps)) {
1740 if (
auto tex =
it->texture())
1747void QQuick3DCustomMaterial::onPropertyDirty()
1753void QQuick3DCustomMaterial::onTextureDirty()
1763 auto it = m_dynamicTextureMaps.
constFind(textureMap);
1768 auto it = m_dynamicTextureMaps.
constFind(textureMap);
1770 m_dynamicTextureMaps.
erase(
it);
1772 m_dynamicTextureMaps.
insert(textureMap);
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
QByteArray first(qsizetype n) const
QByteArray & append(char c)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static QByteArray hash(QByteArrayView data, Algorithm method)
Returns the hash of data using method.
void push_back(parameter_type t)
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
QList< QByteArray > dynamicPropertyNames() const
void destroyed(QObject *=nullptr)
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointe...
The QQmlContext class defines a context within a QML engine.
void setAlwaysDirty(bool alwaysDirty)
QQuick3DCustomMaterial(QQuick3DObject *parent=nullptr)
void fragmentShaderChanged()
void markAllDirty() override
BlendMode dstBlend() const
void setFragmentShader(const QUrl &url)
void shadingModeChanged()
~QQuick3DCustomMaterial() override
void setSrcBlend(QQuick3DCustomMaterial::BlendMode mode)
BlendMode srcBlend() const
void vertexShaderChanged()
static void markDirty(QQuick3DCustomMaterial &that, QQuick3DCustomMaterial::Dirty type)
void setLineWidth(float width)
void alwaysDirtyChanged()
void itemChange(ItemChange, const ItemChangeData &) override
void setVertexShader(const QUrl &url)
QSSGRenderGraphObject * updateSpatialNode(QSSGRenderGraphObject *node) override
void setDstBlend(QQuick3DCustomMaterial::BlendMode mode)
void setShadingMode(QQuick3DCustomMaterial::ShadingMode mode)
QSSGRenderGraphObject * updateSpatialNode(QSSGRenderGraphObject *node) override
void itemChange(ItemChange, const ItemChangeData &) override
QPointer< QQuick3DSceneManager > sceneManager
void refSceneManager(QQuick3DSceneManager &)
static QQuick3DObjectPrivate * get(QQuick3DObject *item)
\qmltype Object3D \inqmlmodule QtQuick3D \instantiates QQuick3DObject \inherits QtObject
virtual void markAllDirty()
QPointer< QQuick3DWindowAttachment > wattached
int depth() const
Returns the depth of the texture data in pixels.
void horizontalTilingChanged()
void verticalTilingChanged()
QQuick3DTextureData * textureData
QSSGRenderImage * getRenderImage()
TilingMode verticalTiling() const
\qmlproperty enumeration QtQuick3D::Texture::tilingModeVertical
TilingMode horizontalTiling() const
\qmlproperty enumeration QtQuick3D::Texture::tilingModeHorizontal
const std::shared_ptr< QSSGRenderContextInterface > & rci() const
BlendFactor
Specifies the blend factor.
const_iterator constEnd() const noexcept
iterator erase(const_iterator i)
const_iterator constFind(const T &value) const
iterator insert(const T &value)
bool isEmpty() const
Returns true if the URL has no data; otherwise returns false.
QMetaType metaType() const
QSet< QString >::iterator it
\qmltype Shader \inherits Object \inqmlmodule QtQuick3D
QByteArray resolveShader(const QUrl &fileUrl, const QQmlContext *context, QByteArray &shaderPathKey)
Combined button and popup list for selecting options.
#define QByteArrayLiteral(str)
Q_CORE_EXPORT int qstrcmp(const char *str1, const char *str2)
std::pair< T1, T2 > QPair
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
GLenum GLuint GLsizei propCount
QQmlContext * qmlContext(const QObject *obj)
static QT_BEGIN_NAMESPACE QRhiGraphicsPipeline::BlendFactor toRhiBlendFactor(QQuick3DCustomMaterial::BlendMode mode)
\qmlproperty url CustomMaterial::vertexShader
static void setCustomMaterialFlagsFromShader(QSSGRenderCustomMaterial *material, const QSSGCustomShaderMetaData &meta)
QSSGRenderTextureFilterOp
QUrl url("example.com")
[constructor-url-reference]
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)
obj metaObject() -> className()
myObject disconnect()
[26]
QQuick3DShaderUtilsTextureInput * texInput
QSSGRenderShaderDataType shaderDataType
CustomShaderPresence m_customShaderPresence
bool incompleteBuildTimeObject
RenderFlags m_renderFlags
ShadingMode m_shadingMode
PropertyList m_properties
TexturePropertyList m_textureProperties
@ InverseProjectionMatrix
QByteArray m_shaderPathKey
bool m_usesSharedVariables
static ShaderCodeAndMetaData prepareCustomShader(QByteArray &dst, const QByteArray &shaderCode, QSSGShaderCache::ShaderType type, const StringPairList &baseUniforms, const StringPairList &baseInputs=StringPairList(), const StringPairList &baseOutputs=StringPairList())
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent