From e382c22ca087c5cdd5f93012c6fefc21f783a56b Mon Sep 17 00:00:00 2001
From: Miikka Heikkinen <miikka.heikkinen@qt.io>
Date: Mon, 17 Aug 2020 15:20:55 +0300
Subject: [PATCH] Add QDS template for CustomMaterial and Effect
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Change-Id: Ia4c07be32fc2e88ca864b267f6ddf4c20b6772c2
Fixes: QDS-2604
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
---
 src/imports/effectlib/designer/designer.pri   |  3 +-
 .../effectlib/designer/effectlib.metainfo     |  1 +
 .../designer/source/effect_template.qml       | 47 +++++++++++++++
 src/imports/materiallib/designer/designer.pri |  3 +-
 .../materiallib/designer/materiallib.metainfo |  1 +
 .../source/custommaterial_template.qml        | 60 +++++++++++++++++++
 6 files changed, 113 insertions(+), 2 deletions(-)
 create mode 100644 src/imports/effectlib/designer/source/effect_template.qml
 create mode 100644 src/imports/materiallib/designer/source/custommaterial_template.qml

diff --git a/src/imports/effectlib/designer/designer.pri b/src/imports/effectlib/designer/designer.pri
index 91beef193..6a40032f3 100644
--- a/src/imports/effectlib/designer/designer.pri
+++ b/src/imports/effectlib/designer/designer.pri
@@ -46,7 +46,8 @@ AUX_QML_FILES += \
     $$PWD/VignetteSection.qml \
     $$PWD/VignetteSpecifics.qml \
     $$PWD/EffectSection.qml \
-    $$PWD/EffectSpecifics.qml
+    $$PWD/EffectSpecifics.qml \
+    $$PWD/source/effect_template.qml
 
 AUX_QML_FILES += \
     $$PWD/images/effect.png \
diff --git a/src/imports/effectlib/designer/effectlib.metainfo b/src/imports/effectlib/designer/effectlib.metainfo
index dadd9d887..91224b3ab 100644
--- a/src/imports/effectlib/designer/effectlib.metainfo
+++ b/src/imports/effectlib/designer/effectlib.metainfo
@@ -414,6 +414,7 @@ MetaInfo {
             libraryIcon: "images/effect.png"
             version: "1.15"
             requiredImport: "QtQuick3D.Effects"
+            QmlSource { source: "./source/effect_template.qml" }
         }
     }
 }
diff --git a/src/imports/effectlib/designer/source/effect_template.qml b/src/imports/effectlib/designer/source/effect_template.qml
new file mode 100644
index 000000000..501c91623
--- /dev/null
+++ b/src/imports/effectlib/designer/source/effect_template.qml
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Quick 3D.
+**
+** $QT_BEGIN_LICENSE:GPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.15
+import QtQuick3D 1.15
+import QtQuick3D.Effects 1.15
+
+Effect {
+    passes: renderPass
+
+    Pass {
+        id: renderPass
+        shaders: [fragShader]
+    }
+
+    Shader {
+        id: fragShader
+        stage: Shader.Fragment
+        shader: "/* Set to a fragment shader file */"
+    }
+}
diff --git a/src/imports/materiallib/designer/designer.pri b/src/imports/materiallib/designer/designer.pri
index a9c944215..9318237bb 100644
--- a/src/imports/materiallib/designer/designer.pri
+++ b/src/imports/materiallib/designer/designer.pri
@@ -34,7 +34,8 @@ AUX_QML_FILES += \
     $$PWD/SteelMilledConcentricMaterialSection.qml \
     $$PWD/SteelMilledConcentricMaterialSpecifics.qml \
     $$PWD/CustomMaterialSection.qml \
-    $$PWD/CustomMaterialSpecifics.qml
+    $$PWD/CustomMaterialSpecifics.qml \
+    $$PWD/source/custommaterial_template.qml
 
 AUX_QML_FILES += \
     $$PWD/images/custommaterial.png \
diff --git a/src/imports/materiallib/designer/materiallib.metainfo b/src/imports/materiallib/designer/materiallib.metainfo
index c24882cba..0f63c0b7d 100644
--- a/src/imports/materiallib/designer/materiallib.metainfo
+++ b/src/imports/materiallib/designer/materiallib.metainfo
@@ -300,6 +300,7 @@ MetaInfo {
             libraryIcon: "images/custommaterial.png"
             version: "1.14"
             requiredImport: "QtQuick3D.Materials"
+            QmlSource { source: "./source/custommaterial_template.qml" }
         }
     }
 }
diff --git a/src/imports/materiallib/designer/source/custommaterial_template.qml b/src/imports/materiallib/designer/source/custommaterial_template.qml
new file mode 100644
index 000000000..1deeb9e4b
--- /dev/null
+++ b/src/imports/materiallib/designer/source/custommaterial_template.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Quick 3D.
+**
+** $QT_BEGIN_LICENSE:GPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.15
+import QtQuick3D 1.15
+import QtQuick3D.Materials 1.15
+
+CustomMaterial {
+    shaderInfo: shaderInfo
+    passes: renderPass
+
+    ShaderInfo {
+        id: shaderInfo
+        type: "GLSL"
+        version: "330"
+    }
+
+    Pass {
+        id: renderPass
+        shaders: [vertShader, fragShader]
+    }
+
+    Shader {
+        id: vertShader
+        stage: Shader.Vertex
+        shader: "/* Set to a vertex shader file */"
+    }
+
+    Shader {
+        id: fragShader
+        stage: Shader.Fragment
+        shader: "/* Set to a fragment shader file */"
+    }
+}
-- 
GitLab