diff --git a/examples/simple/main_simple.qml b/examples/simple/main_simple.qml
index 3b4ab40..ee204eb 100644
--- a/examples/simple/main_simple.qml
+++ b/examples/simple/main_simple.qml
@@ -56,7 +56,7 @@ ApplicationWindow {
components: [
ShaderBuilderMaterial {
id: material
- fragmentColor: StandardMaterial {
+ surface: StandardSurface {
color: "green"
normal: Bump {
texture: Noise {
diff --git a/src/imports/ShaderNodes/ShaderBuilderMaterial.qml b/src/imports/ShaderNodes/ShaderBuilderMaterial.qml
index 8a08c23..b28f51f 100644
--- a/src/imports/ShaderNodes/ShaderBuilderMaterial.qml
+++ b/src/imports/ShaderNodes/ShaderBuilderMaterial.qml
@@ -9,6 +9,7 @@ import QtQuick.Scene3D 2.0
Material {
id: root
+ property alias surface: shaderBuilderEffect.fragmentColor
property alias fragmentColor: shaderBuilderEffect.fragmentColor
property alias deferredColor: shaderBuilderEffect.deferredColor
property alias vertexPosition: shaderBuilderEffect.vertexPosition
diff --git a/src/imports/ShaderNodes/StandardMaterial.qml b/src/imports/ShaderNodes/StandardMaterial.qml
index 14c5b2f..5a65fce 100644
--- a/src/imports/ShaderNodes/StandardMaterial.qml
+++ b/src/imports/ShaderNodes/StandardMaterial.qml
@@ -1,58 +1,7 @@
-import QtQuick 2.5
-import ShaderNodes 1.0
+import QtQuick 2.0
-ShaderNode {
- property var color: "darkgrey"
- property var attenuationOffset: 0.0
- property var ambientColor: color
- property var diffuseColor: color
- property var specularColor: color
- property var ambientIntensity: 1.0
- property var diffuseIntensity: 1.0
- property var specularIntensity: 1.0
- property var hardness: 1.0
-
- property var normal: ShaderBuilderBinding {
- property: "normal"
- defaultValue: Qt.vector3d(0.0, 0.0, 1.0)
- }
- property var position: ShaderBuilderBinding {
- property: "position"
- defaultValue: Qt.vector3d(0.0, 0.0, 0.0)
- }
-
- property var lights: [_defaultLight]
-
- onLightsChanged: markDirty()
-
- property Light _defaultLight: Light {
- position: Qt.vector3d(46, 20, -10)
- attenuation: 0.0
- strength: 1.0
+StandardSurface {
+ Component.onCompleted: {
+ console.warn("WARNING: StandardMaterial is deprecated. Please use StandardSurface.")
}
-
- exportedTypeName: "StandardMaterial"
-
- arrayProperties: ["lights"]
-
- name: "diffuse"
- type: "vec4"
- source: {
- var output = ""
- output += "$this = vec4(0.0, 0.0, 0.0, 0.0);\n"
- output += "$this.a = $(diffuseColor, vec4).a;\n"
-
- for(var i in lights) {
- output += "$this.xyz += standardMaterialLight($lights[" + i + "], $(normal, vec3), $(position, vec3), eyePosition,\n"
- output += " $(ambientColor, vec3), $(diffuseColor, vec3), $(specularColor, vec3),\n"
- output += " 0.01 * $(ambientIntensity, float), $(diffuseIntensity, float), 0.01 * $(specularIntensity, float),\n"
- output += " 150.0 * $(hardness, float), $(attenuationOffset, float));\n"
- }
- return output
- }
-
- headerFiles: [
- "qrc:/ShaderNodes/shaders/light.glsl",
- "qrc:/ShaderNodes/shaders/standard_material.glsl"
- ]
}
diff --git a/src/imports/ShaderNodes/StandardSurface.qml b/src/imports/ShaderNodes/StandardSurface.qml
new file mode 100644
index 0000000..14c5b2f
--- /dev/null
+++ b/src/imports/ShaderNodes/StandardSurface.qml
@@ -0,0 +1,58 @@
+import QtQuick 2.5
+import ShaderNodes 1.0
+
+ShaderNode {
+ property var color: "darkgrey"
+ property var attenuationOffset: 0.0
+ property var ambientColor: color
+ property var diffuseColor: color
+ property var specularColor: color
+ property var ambientIntensity: 1.0
+ property var diffuseIntensity: 1.0
+ property var specularIntensity: 1.0
+ property var hardness: 1.0
+
+ property var normal: ShaderBuilderBinding {
+ property: "normal"
+ defaultValue: Qt.vector3d(0.0, 0.0, 1.0)
+ }
+ property var position: ShaderBuilderBinding {
+ property: "position"
+ defaultValue: Qt.vector3d(0.0, 0.0, 0.0)
+ }
+
+ property var lights: [_defaultLight]
+
+ onLightsChanged: markDirty()
+
+ property Light _defaultLight: Light {
+ position: Qt.vector3d(46, 20, -10)
+ attenuation: 0.0
+ strength: 1.0
+ }
+
+ exportedTypeName: "StandardMaterial"
+
+ arrayProperties: ["lights"]
+
+ name: "diffuse"
+ type: "vec4"
+ source: {
+ var output = ""
+ output += "$this = vec4(0.0, 0.0, 0.0, 0.0);\n"
+ output += "$this.a = $(diffuseColor, vec4).a;\n"
+
+ for(var i in lights) {
+ output += "$this.xyz += standardMaterialLight($lights[" + i + "], $(normal, vec3), $(position, vec3), eyePosition,\n"
+ output += " $(ambientColor, vec3), $(diffuseColor, vec3), $(specularColor, vec3),\n"
+ output += " 0.01 * $(ambientIntensity, float), $(diffuseIntensity, float), 0.01 * $(specularIntensity, float),\n"
+ output += " 150.0 * $(hardness, float), $(attenuationOffset, float));\n"
+ }
+ return output
+ }
+
+ headerFiles: [
+ "qrc:/ShaderNodes/shaders/light.glsl",
+ "qrc:/ShaderNodes/shaders/standard_material.glsl"
+ ]
+}
diff --git a/src/imports/ShaderNodes/qmldir b/src/imports/ShaderNodes/qmldir
index a249c79..efcfc4c 100644
--- a/src/imports/ShaderNodes/qmldir
+++ b/src/imports/ShaderNodes/qmldir
@@ -26,6 +26,7 @@ Split 1.0 Split.qml
ShaderBuilderMaterial 1.0 ShaderBuilderMaterial.qml
ShaderBuilderEffect 1.0 ShaderBuilderEffect.qml
StandardMaterial 1.0 StandardMaterial.qml
+StandardSurface 1.0 StandardSurface.qml
Subtract 1.0 Subtract.qml
Sum 1.0 Sum.qml
UniformValue 1.0 UniformValue.qml
diff --git a/src/imports/shadernodes_imports.qrc b/src/imports/shadernodes_imports.qrc
index 496d418..5b0ffe0 100644
--- a/src/imports/shadernodes_imports.qrc
+++ b/src/imports/shadernodes_imports.qrc
@@ -40,5 +40,6 @@
ShaderNodes/ShaderBuilderEffect.qml
ShaderNodes/CombineRgba.qml
ShaderNodes/CombineRgbVectorAlpha.qml
+ ShaderNodes/StandardSurface.qml