summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMika Salmela <mika.salmela@theqtcompany.com>2015-06-23 16:56:59 +0300
committerMika Salmela <mika.salmela@theqtcompany.com>2015-06-23 14:06:17 +0000
commit5cc86303d61264d98b51c7130dd36f50131a67ee (patch)
tree3032e743a383c56c49af1dcee109b772c06234e9
parentdbe0950dfa2e6351af45a564e62b7a47ba6e7be2 (diff)
Add ES2 support to planets-qml example
Change-Id: Ic5208d2149efbd03b82417ce3af17747375663f5 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@theqtcompany.com>
-rw-r--r--examples/qt3d/planets-qml/CloudEffectDS.qml69
-rw-r--r--examples/qt3d/planets-qml/Light.qml2
-rw-r--r--examples/qt3d/planets-qml/Planet.qml2
-rw-r--r--examples/qt3d/planets-qml/PlanetButton.qml3
-rw-r--r--examples/qt3d/planets-qml/PlanetEffectD.qml83
-rw-r--r--examples/qt3d/planets-qml/PlanetEffectDB.qml83
-rw-r--r--examples/qt3d/planets-qml/PlanetEffectDS.qml73
-rw-r--r--examples/qt3d/planets-qml/PlanetEffectDSB.qml73
-rw-r--r--examples/qt3d/planets-qml/PlanetFrameGraph.qml (renamed from examples/qt3d/planets-qml/ShadowMapFrameGraph.qml)63
-rw-r--r--examples/qt3d/planets-qml/PlanetMaterial.qml26
-rw-r--r--examples/qt3d/planets-qml/PlanetsMain.qml8
-rw-r--r--examples/qt3d/planets-qml/Ring.qml2
-rw-r--r--examples/qt3d/planets-qml/SolarSystem.qml11
-rw-r--r--examples/qt3d/planets-qml/android/AndroidManifest.xml56
-rw-r--r--examples/qt3d/planets-qml/android/res/drawable-hdpi/icon.pngbin0 -> 69493 bytes
-rw-r--r--examples/qt3d/planets-qml/android/res/drawable-ldpi/icon.pngbin0 -> 69493 bytes
-rw-r--r--examples/qt3d/planets-qml/android/res/drawable-mdpi/icon.pngbin0 -> 69493 bytes
-rw-r--r--examples/qt3d/planets-qml/planets-qml.pro10
-rw-r--r--examples/qt3d/planets-qml/planets-qml.qrc24
-rw-r--r--examples/qt3d/planets-qml/shaders/es2/planetD.frag93
-rw-r--r--examples/qt3d/planets-qml/shaders/es2/planetD.vert69
-rw-r--r--examples/qt3d/planets-qml/shaders/es2/planetDB.frag89
-rw-r--r--examples/qt3d/planets-qml/shaders/es2/planetDB.vert94
-rw-r--r--examples/qt3d/planets-qml/shaders/es2/planetDS.frag94
-rw-r--r--examples/qt3d/planets-qml/shaders/es2/planetDSB.frag94
-rw-r--r--examples/qt3d/planets-qml/shaders/gl3/planetD.frag (renamed from examples/qt3d/planets-qml/shaders/planetD.frag)0
-rw-r--r--examples/qt3d/planets-qml/shaders/gl3/planetD.vert (renamed from examples/qt3d/planets-qml/shaders/planetD.vert)0
-rw-r--r--examples/qt3d/planets-qml/shaders/gl3/planetDB.frag (renamed from examples/qt3d/planets-qml/shaders/planetDB.frag)0
-rw-r--r--examples/qt3d/planets-qml/shaders/gl3/planetDB.vert (renamed from examples/qt3d/planets-qml/shaders/planetDB.vert)0
-rw-r--r--examples/qt3d/planets-qml/shaders/gl3/planetDS.frag (renamed from examples/qt3d/planets-qml/shaders/planetDS.frag)0
-rw-r--r--examples/qt3d/planets-qml/shaders/gl3/planetDSB.frag (renamed from examples/qt3d/planets-qml/shaders/planetDSB.frag)0
-rw-r--r--examples/qt3d/planets-qml/shaders/gl3/shadowmap.frag (renamed from examples/qt3d/planets-qml/shaders/shadowmap.frag)0
-rw-r--r--examples/qt3d/planets-qml/shaders/gl3/shadowmap.vert (renamed from examples/qt3d/planets-qml/shaders/shadowmap.vert)0
33 files changed, 1025 insertions, 96 deletions
diff --git a/examples/qt3d/planets-qml/CloudEffectDS.qml b/examples/qt3d/planets-qml/CloudEffectDS.qml
index 3088f996a..ea043d22b 100644
--- a/examples/qt3d/planets-qml/CloudEffectDS.qml
+++ b/examples/qt3d/planets-qml/CloudEffectDS.qml
@@ -36,7 +36,7 @@
****************************************************************************/
import Qt3D 2.0
-import Qt3D.Render 2.0
+import Qt3D.Renderer 2.0
Effect {
id: root
@@ -58,9 +58,72 @@ Effect {
minorVersion: 2
}
+ annotations: [ Annotation { name: "name"; value: "Desktop" } ]
+
+ renderPasses: [
+ RenderPass {
+ annotations: [ Annotation { name : "pass"; value : "forward" } ]
+ bindings: [
+ // Uniforms (those provided by the user)
+ ParameterMapping {
+ parameterName: "ambient";
+ shaderVariableName: "ka";
+ bindingType: ParameterMapping.Uniform
+ }
+ ]
+
+ shaderProgram: ShaderProgram {
+ vertexShaderCode: loadSource("qrc:/shaders/gl3/planetD.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/gl3/planetDS.frag")
+ }
+
+ // no special render state set => use the default set of states
+ }
+ ]
+ },
+ Technique {
+ openGLFilter {
+ api: OpenGLFilter.Desktop
+ majorVersion: 2
+ }
+
+ annotations: [ Annotation { name: "name"; value: "ES2" } ]
+
renderPasses: [
RenderPass {
annotations: [ Annotation { name : "pass"; value : "forward" } ]
+
+ bindings: [
+ // Uniforms (those provided by the user)
+ ParameterMapping {
+ parameterName: "ambient";
+ shaderVariableName: "ka";
+ bindingType: ParameterMapping.Uniform
+ }
+ ]
+
+ shaderProgram: ShaderProgram {
+ vertexShaderCode: loadSource("qrc:/shaders/es2/planetD.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/es2/planetDS.frag")
+ }
+
+ // no special render state set => use the default set of states
+ }
+ ]
+ },
+ Technique {
+ openGLFilter {
+ api: OpenGLFilter.ES
+ majorVersion: 2
+ minorVersion: 0
+ }
+
+ annotations: [ Annotation { name: "name"; value: "ES2" } ]
+
+ renderPasses: [
+ RenderPass {
+ annotations: [ Annotation { name : "pass"; value : "forward" } ]
+
bindings: [
// Uniforms (those provided by the user)
ParameterMapping {
@@ -71,8 +134,8 @@ Effect {
]
shaderProgram: ShaderProgram {
- vertexShaderCode: loadSource("qrc:/shaders/planetD.vert")
- fragmentShaderCode: loadSource("qrc:/shaders/planetDS.frag")
+ vertexShaderCode: loadSource("qrc:/shaders/es2/planetD.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/es2/planetDS.frag")
}
// no special render state set => use the default set of states
diff --git a/examples/qt3d/planets-qml/Light.qml b/examples/qt3d/planets-qml/Light.qml
index ab63bf1e0..199d3f30a 100644
--- a/examples/qt3d/planets-qml/Light.qml
+++ b/examples/qt3d/planets-qml/Light.qml
@@ -36,7 +36,7 @@
****************************************************************************/
import Qt3D 2.0
-import Qt3D.Render 2.0
+import Qt3D.Renderer 2.0
Entity {
id: root
diff --git a/examples/qt3d/planets-qml/Planet.qml b/examples/qt3d/planets-qml/Planet.qml
index 005312b5d..4381ebdb1 100644
--- a/examples/qt3d/planets-qml/Planet.qml
+++ b/examples/qt3d/planets-qml/Planet.qml
@@ -34,7 +34,7 @@
**
****************************************************************************/
-import Qt3D.Render 2.0
+import Qt3D.Renderer 2.0
SphereMesh {
property real r: 0
diff --git a/examples/qt3d/planets-qml/PlanetButton.qml b/examples/qt3d/planets-qml/PlanetButton.qml
index f68c70052..e530312dc 100644
--- a/examples/qt3d/planets-qml/PlanetButton.qml
+++ b/examples/qt3d/planets-qml/PlanetButton.qml
@@ -59,7 +59,8 @@ Rectangle {
hoverEnabled: true
onClicked: { planetSelector.focusedPlanet = focusPlanet }
onEntered: PropertyAnimation { target: planetText; property: "opacity"; to: 1 }
- onExited: PropertyAnimation { target: planetText;
+ onExited: PropertyAnimation {
+ target: planetText
property: "opacity"
to: {
if (planetText.text != "Solar System")
diff --git a/examples/qt3d/planets-qml/PlanetEffectD.qml b/examples/qt3d/planets-qml/PlanetEffectD.qml
index 5d3f64f89..e5fcc8ae0 100644
--- a/examples/qt3d/planets-qml/PlanetEffectD.qml
+++ b/examples/qt3d/planets-qml/PlanetEffectD.qml
@@ -36,7 +36,7 @@
****************************************************************************/
import Qt3D 2.0
-import Qt3D.Render 2.0
+import Qt3D.Renderer 2.0
Effect {
id: root
@@ -60,13 +60,15 @@ Effect {
minorVersion: 2
}
+ annotations: [ Annotation { name: "name"; value: "Desktop" } ]
+
renderPasses: [
RenderPass {
annotations: [ Annotation { name: "pass"; value: "shadowmap" } ]
shaderProgram: ShaderProgram {
- vertexShaderCode: loadSource("qrc:/shaders/shadowmap.vert")
- fragmentShaderCode: loadSource("qrc:/shaders/shadowmap.frag")
+ vertexShaderCode: loadSource("qrc:/shaders/gl3/shadowmap.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/gl3/shadowmap.frag")
}
renderStates: [
@@ -92,8 +94,79 @@ Effect {
]
shaderProgram: ShaderProgram {
- vertexShaderCode: loadSource("qrc:/shaders/planetD.vert")
- fragmentShaderCode: loadSource("qrc:/shaders/planetD.frag")
+ vertexShaderCode: loadSource("qrc:/shaders/gl3/planetD.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/gl3/planetD.frag")
+ }
+
+ // no special render state set => use the default set of states
+ }
+ ]
+ },
+ Technique {
+ openGLFilter {
+ api: OpenGLFilter.Desktop
+ majorVersion: 2
+ }
+
+ annotations: [ Annotation { name: "name"; value: "ES2" } ]
+
+ renderPasses: [
+ RenderPass {
+ annotations: [ Annotation { name : "pass"; value : "forward" } ]
+
+ bindings: [
+ // Uniforms (those provided by the user)
+ ParameterMapping {
+ parameterName: "ambient";
+ shaderVariableName: "ka";
+ bindingType: ParameterMapping.Uniform
+ },
+ ParameterMapping {
+ parameterName: "specular";
+ shaderVariableName: "ks";
+ bindingType: ParameterMapping.Uniform
+ }
+ ]
+
+ shaderProgram: ShaderProgram {
+ vertexShaderCode: loadSource("qrc:/shaders/es2/planetD.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/es2/planetD.frag")
+ }
+
+ // no special render state set => use the default set of states
+ }
+ ]
+ },
+ Technique {
+ openGLFilter {
+ api: OpenGLFilter.ES
+ majorVersion: 2
+ minorVersion: 0
+ }
+
+ annotations: [ Annotation { name: "name"; value: "ES2" } ]
+
+ renderPasses: [
+ RenderPass {
+ annotations: [ Annotation { name : "pass"; value : "forward" } ]
+
+ bindings: [
+ // Uniforms (those provided by the user)
+ ParameterMapping {
+ parameterName: "ambient";
+ shaderVariableName: "ka";
+ bindingType: ParameterMapping.Uniform
+ },
+ ParameterMapping {
+ parameterName: "specular";
+ shaderVariableName: "ks";
+ bindingType: ParameterMapping.Uniform
+ }
+ ]
+
+ shaderProgram: ShaderProgram {
+ vertexShaderCode: loadSource("qrc:/shaders/es2/planetD.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/es2/planetD.frag")
}
// no special render state set => use the default set of states
diff --git a/examples/qt3d/planets-qml/PlanetEffectDB.qml b/examples/qt3d/planets-qml/PlanetEffectDB.qml
index a36cdf427..ad9d2035e 100644
--- a/examples/qt3d/planets-qml/PlanetEffectDB.qml
+++ b/examples/qt3d/planets-qml/PlanetEffectDB.qml
@@ -36,7 +36,7 @@
****************************************************************************/
import Qt3D 2.0
-import Qt3D.Render 2.0
+import Qt3D.Renderer 2.0
Effect {
id: root
@@ -60,13 +60,15 @@ Effect {
minorVersion: 2
}
+ annotations: [ Annotation { name: "name"; value: "Desktop" } ]
+
renderPasses: [
RenderPass {
annotations: [ Annotation { name: "pass"; value: "shadowmap" } ]
shaderProgram: ShaderProgram {
- vertexShaderCode: loadSource("qrc:/shaders/shadowmap.vert")
- fragmentShaderCode: loadSource("qrc:/shaders/shadowmap.frag")
+ vertexShaderCode: loadSource("qrc:/shaders/gl3/shadowmap.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/gl3/shadowmap.frag")
}
renderStates: [
@@ -92,8 +94,79 @@ Effect {
]
shaderProgram: ShaderProgram {
- vertexShaderCode: loadSource("qrc:/shaders/planetDB.vert")
- fragmentShaderCode: loadSource("qrc:/shaders/planetDB.frag")
+ vertexShaderCode: loadSource("qrc:/shaders/gl3/planetDB.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/gl3/planetDB.frag")
+ }
+
+ // no special render state set => use the default set of states
+ }
+ ]
+ },
+ Technique {
+ openGLFilter {
+ api: OpenGLFilter.Desktop
+ majorVersion: 2
+ }
+
+ annotations: [ Annotation { name: "name"; value: "ES2" } ]
+
+ renderPasses: [
+ RenderPass {
+ annotations: [ Annotation { name : "pass"; value : "forward" } ]
+
+ bindings: [
+ // Uniforms (those provided by the user)
+ ParameterMapping {
+ parameterName: "ambient";
+ shaderVariableName: "ka";
+ bindingType: ParameterMapping.Uniform
+ },
+ ParameterMapping {
+ parameterName: "specular";
+ shaderVariableName: "ks";
+ bindingType: ParameterMapping.Uniform
+ }
+ ]
+
+ shaderProgram: ShaderProgram {
+ vertexShaderCode: loadSource("qrc:/shaders/es2/planetDB.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/es2/planetDB.frag")
+ }
+
+ // no special render state set => use the default set of states
+ }
+ ]
+ },
+ Technique {
+ openGLFilter {
+ api: OpenGLFilter.ES
+ majorVersion: 2
+ minorVersion: 0
+ }
+
+ annotations: [ Annotation { name: "name"; value: "ES2" } ]
+
+ renderPasses: [
+ RenderPass {
+ annotations: [ Annotation { name : "pass"; value : "forward" } ]
+
+ bindings: [
+ // Uniforms (those provided by the user)
+ ParameterMapping {
+ parameterName: "ambient";
+ shaderVariableName: "ka";
+ bindingType: ParameterMapping.Uniform
+ },
+ ParameterMapping {
+ parameterName: "specular";
+ shaderVariableName: "ks";
+ bindingType: ParameterMapping.Uniform
+ }
+ ]
+
+ shaderProgram: ShaderProgram {
+ vertexShaderCode: loadSource("qrc:/shaders/es2/planetDB.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/es2/planetDB.frag")
}
// no special render state set => use the default set of states
diff --git a/examples/qt3d/planets-qml/PlanetEffectDS.qml b/examples/qt3d/planets-qml/PlanetEffectDS.qml
index 670fccc15..1d3512d86 100644
--- a/examples/qt3d/planets-qml/PlanetEffectDS.qml
+++ b/examples/qt3d/planets-qml/PlanetEffectDS.qml
@@ -36,7 +36,7 @@
****************************************************************************/
import Qt3D 2.0
-import Qt3D.Render 2.0
+import Qt3D.Renderer 2.0
Effect {
id: root
@@ -60,13 +60,15 @@ Effect {
minorVersion: 2
}
+ annotations: [ Annotation { name: "name"; value: "Desktop" } ]
+
renderPasses: [
RenderPass {
annotations: [ Annotation { name: "pass"; value: "shadowmap" } ]
shaderProgram: ShaderProgram {
- vertexShaderCode: loadSource("qrc:/shaders/shadowmap.vert")
- fragmentShaderCode: loadSource("qrc:/shaders/shadowmap.frag")
+ vertexShaderCode: loadSource("qrc:/shaders/gl3/shadowmap.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/gl3/shadowmap.frag")
}
renderStates: [
@@ -87,8 +89,69 @@ Effect {
]
shaderProgram: ShaderProgram {
- vertexShaderCode: loadSource("qrc:/shaders/planetD.vert")
- fragmentShaderCode: loadSource("qrc:/shaders/planetDS.frag")
+ vertexShaderCode: loadSource("qrc:/shaders/gl3/planetD.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/gl3/planetDS.frag")
+ }
+
+ // no special render state set => use the default set of states
+ }
+ ]
+ },
+ Technique {
+ openGLFilter {
+ api: OpenGLFilter.Desktop
+ majorVersion: 2
+ }
+
+ annotations: [ Annotation { name: "name"; value: "ES2" } ]
+
+ renderPasses: [
+ RenderPass {
+ annotations: [ Annotation { name : "pass"; value : "forward" } ]
+
+ bindings: [
+ // Uniforms (those provided by the user)
+ ParameterMapping {
+ parameterName: "ambient";
+ shaderVariableName: "ka";
+ bindingType: ParameterMapping.Uniform
+ }
+ ]
+
+ shaderProgram: ShaderProgram {
+ vertexShaderCode: loadSource("qrc:/shaders/es2/planetD.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/es2/planetDS.frag")
+ }
+
+ // no special render state set => use the default set of states
+ }
+ ]
+ },
+ Technique {
+ openGLFilter {
+ api: OpenGLFilter.ES
+ majorVersion: 2
+ minorVersion: 0
+ }
+
+ annotations: [ Annotation { name: "name"; value: "ES2" } ]
+
+ renderPasses: [
+ RenderPass {
+ annotations: [ Annotation { name : "pass"; value : "forward" } ]
+
+ bindings: [
+ // Uniforms (those provided by the user)
+ ParameterMapping {
+ parameterName: "ambient";
+ shaderVariableName: "ka";
+ bindingType: ParameterMapping.Uniform
+ }
+ ]
+
+ shaderProgram: ShaderProgram {
+ vertexShaderCode: loadSource("qrc:/shaders/es2/planetD.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/es2/planetDS.frag")
}
// no special render state set => use the default set of states
diff --git a/examples/qt3d/planets-qml/PlanetEffectDSB.qml b/examples/qt3d/planets-qml/PlanetEffectDSB.qml
index 1b035406a..78b00bd32 100644
--- a/examples/qt3d/planets-qml/PlanetEffectDSB.qml
+++ b/examples/qt3d/planets-qml/PlanetEffectDSB.qml
@@ -36,7 +36,7 @@
****************************************************************************/
import Qt3D 2.0
-import Qt3D.Render 2.0
+import Qt3D.Renderer 2.0
Effect {
id: root
@@ -60,13 +60,15 @@ Effect {
minorVersion: 2
}
+ annotations: [ Annotation { name: "name"; value: "Desktop" } ]
+
renderPasses: [
RenderPass {
annotations: [ Annotation { name: "pass"; value: "shadowmap" } ]
shaderProgram: ShaderProgram {
- vertexShaderCode: loadSource("qrc:/shaders/shadowmap.vert")
- fragmentShaderCode: loadSource("qrc:/shaders/shadowmap.frag")
+ vertexShaderCode: loadSource("qrc:/shaders/gl3/shadowmap.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/gl3/shadowmap.frag")
}
renderStates: [
@@ -87,8 +89,69 @@ Effect {
]
shaderProgram: ShaderProgram {
- vertexShaderCode: loadSource("qrc:/shaders/planetDB.vert")
- fragmentShaderCode: loadSource("qrc:/shaders/planetDSB.frag")
+ vertexShaderCode: loadSource("qrc:/shaders/gl3/planetDB.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/gl3/planetDSB.frag")
+ }
+
+ // no special render state set => use the default set of states
+ }
+ ]
+ },
+ Technique {
+ openGLFilter {
+ api: OpenGLFilter.Desktop
+ majorVersion: 2
+ }
+
+ annotations: [ Annotation { name: "name"; value: "ES2" } ]
+
+ renderPasses: [
+ RenderPass {
+ annotations: [ Annotation { name : "pass"; value : "forward" } ]
+
+ bindings: [
+ // Uniforms (those provided by the user)
+ ParameterMapping {
+ parameterName: "ambient";
+ shaderVariableName: "ka";
+ bindingType: ParameterMapping.Uniform
+ }
+ ]
+
+ shaderProgram: ShaderProgram {
+ vertexShaderCode: loadSource("qrc:/shaders/es2/planetDB.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/es2/planetDSB.frag")
+ }
+
+ // no special render state set => use the default set of states
+ }
+ ]
+ },
+ Technique {
+ openGLFilter {
+ api: OpenGLFilter.ES
+ majorVersion: 2
+ minorVersion: 0
+ }
+
+ annotations: [ Annotation { name: "name"; value: "ES2" } ]
+
+ renderPasses: [
+ RenderPass {
+ annotations: [ Annotation { name : "pass"; value : "forward" } ]
+
+ bindings: [
+ // Uniforms (those provided by the user)
+ ParameterMapping {
+ parameterName: "ambient";
+ shaderVariableName: "ka";
+ bindingType: ParameterMapping.Uniform
+ }
+ ]
+
+ shaderProgram: ShaderProgram {
+ vertexShaderCode: loadSource("qrc:/shaders/es2/planetDB.vert")
+ fragmentShaderCode: loadSource("qrc:/shaders/es2/planetDSB.frag")
}
// no special render state set => use the default set of states
diff --git a/examples/qt3d/planets-qml/ShadowMapFrameGraph.qml b/examples/qt3d/planets-qml/PlanetFrameGraph.qml
index 8b52e42d4..6034505d2 100644
--- a/examples/qt3d/planets-qml/ShadowMapFrameGraph.qml
+++ b/examples/qt3d/planets-qml/PlanetFrameGraph.qml
@@ -36,8 +36,7 @@
****************************************************************************/
import Qt3D 2.0
-import Qt3D.Render 2.0
-import QtQuick 2.2 as QQ2
+import Qt3D.Renderer 2.0
FrameGraph {
id: root
@@ -50,39 +49,43 @@ FrameGraph {
rect: Qt.rect(0.0, 0.0, 1.0, 1.0)
clearColor: Qt.rgba(0.0, 0.0, 0.0, 1.0)
- RenderPassFilter {
- includes: [ Annotation { name: "pass"; value: "shadowmap" } ]
+ TechniqueFilter {
+ requires: [ Annotation { name: "name"; value: "Desktop" } ]
+
+ RenderPassFilter {
+ includes: [ Annotation { name: "pass"; value: "shadowmap" } ]
- RenderTargetSelector {
- target: RenderTarget {
- attachments: [
- RenderAttachment {
- name: "depth"
- type: RenderAttachment.DepthAttachment
- texture: Texture2D {
- id: depthTexture
- width: mainview.width
- height: mainview.height
- format: Texture.DepthFormat
- generateMipMaps: false
- magnificationFilter: Texture.Linear
- minificationFilter: Texture.Linear
- wrapMode {
- x: WrapMode.ClampToEdge
- y: WrapMode.ClampToEdge
+ RenderTargetSelector {
+ target: RenderTarget {
+ attachments: [
+ RenderAttachment {
+ name: "depth"
+ type: RenderAttachment.DepthAttachment
+ texture: Texture2D {
+ id: depthTexture
+ width: mainview.width
+ height: mainview.height
+ format: Texture.D24
+ generateMipMaps: false
+ magnificationFilter: Texture.Nearest
+ minificationFilter: Texture.Nearest
+ wrapMode {
+ x: WrapMode.ClampToEdge
+ y: WrapMode.ClampToEdge
+ }
+ comparisonFunction: Texture.CompareLessEqual
+ comparisonMode: Texture.CompareRefToTexture
}
- comparisonFunction: Texture.CompareLessEqual
- comparisonMode: Texture.CompareRefToTexture
}
- }
- ]
- }
+ ]
+ }
- ClearBuffer {
- buffers: ClearBuffer.DepthBuffer
+ ClearBuffer {
+ buffers: ClearBuffer.DepthBuffer
- CameraSelector {
- id: lightCameraSelector
+ CameraSelector {
+ id: lightCameraSelector
+ }
}
}
}
diff --git a/examples/qt3d/planets-qml/PlanetMaterial.qml b/examples/qt3d/planets-qml/PlanetMaterial.qml
index 5fd259e45..e754394b0 100644
--- a/examples/qt3d/planets-qml/PlanetMaterial.qml
+++ b/examples/qt3d/planets-qml/PlanetMaterial.qml
@@ -36,7 +36,7 @@
****************************************************************************/
import Qt3D 2.0
-import Qt3D.Render 2.0
+import Qt3D.Renderer 2.0
import QtQuick 2.1
Material {
@@ -53,19 +53,19 @@ Material {
parameters: [
Parameter {
- name: "ambient";
+ name: "ambient"
value: Qt.vector3d(root.ambientLight.r, root.ambientLight.g, root.ambientLight.b)
},
Parameter {
- name: "diffuse";
+ name: "diffuse"
value: Qt.vector3d(root.diffuseColor.r, root.diffuseColor.g, root.diffuseColor.b)
},
Parameter {
- name: "specular";
+ name: "specular"
value: Qt.vector3d(root.specularColor.r, root.specularColor.g, root.specularColor.b)
},
Parameter {
- name: "shininess";
+ name: "shininess"
value: root.shininess
},
Parameter {
@@ -80,10 +80,11 @@ Material {
}
generateMipMaps: true
maximumAnisotropy: 16.0
- TextureImage { id: diffuseTextureImage; }
+ TextureImage { id: diffuseTextureImage }
}
},
- Parameter { name: "specularTexture";
+ Parameter {
+ name: "specularTexture"
value: Texture2D {
id: specularTexture
minificationFilter: Texture.LinearMipMapLinear
@@ -94,10 +95,11 @@ Material {
}
generateMipMaps: true
maximumAnisotropy: 16.0
- TextureImage { id: specularTextureImage; }
+ TextureImage { id: specularTextureImage }
}
},
- Parameter { name: "normalTexture";
+ Parameter {
+ name: "normalTexture"
value: Texture2D {
id: normalTexture
minificationFilter: Texture.Linear
@@ -107,15 +109,15 @@ Material {
y: WrapMode.Repeat
}
maximumAnisotropy: 16.0
- TextureImage { id: normalTextureImage; }
+ TextureImage { id: normalTextureImage }
}
},
Parameter {
- name: "texCoordScale";
+ name: "texCoordScale"
value: textureScale
},
Parameter {
- name: "opacity";
+ name: "opacity"
value: opacity
}
]
diff --git a/examples/qt3d/planets-qml/PlanetsMain.qml b/examples/qt3d/planets-qml/PlanetsMain.qml
index 84705e696..f72c93715 100644
--- a/examples/qt3d/planets-qml/PlanetsMain.qml
+++ b/examples/qt3d/planets-qml/PlanetsMain.qml
@@ -55,7 +55,6 @@ Item {
anchors.fill: parent
anchors.margins: 10
focus: true
- aspects: "input"
SolarSystem { id: solarsystem }
}
@@ -64,18 +63,13 @@ Item {
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton
- onClicked: {
- solarsystem.setFreeCamera(false)
+ onClicked:
focusedPlanet = 100
- }
- onDoubleClicked:
- solarsystem.setFreeCamera(true)
}
}
//! [1]
onFocusedPlanetChanged: {
- solarsystem.setFreeCamera(false)
if (focusedPlanet == 100) {
info.opacity = 0
updatePlanetInfo()
diff --git a/examples/qt3d/planets-qml/Ring.qml b/examples/qt3d/planets-qml/Ring.qml
index 7bf585805..1dcb59618 100644
--- a/examples/qt3d/planets-qml/Ring.qml
+++ b/examples/qt3d/planets-qml/Ring.qml
@@ -34,7 +34,7 @@
**
****************************************************************************/
-import Qt3D.Render 2.0
+import Qt3D.Renderer 2.0
// TODO: Once support for meshes from arrays is implemented, replace ring.obj with that
Mesh {
diff --git a/examples/qt3d/planets-qml/SolarSystem.qml b/examples/qt3d/planets-qml/SolarSystem.qml
index d34627735..515e2d8d7 100644
--- a/examples/qt3d/planets-qml/SolarSystem.qml
+++ b/examples/qt3d/planets-qml/SolarSystem.qml
@@ -35,7 +35,7 @@
****************************************************************************/
import Qt3D 2.0
-import Qt3D.Render 2.0
+import Qt3D.Renderer 2.0
import QtQuick 2.0 as QQ2
import "planets.js" as Planets
@@ -44,7 +44,6 @@ Entity {
id: sceneRoot
property bool ready: false
- property bool freeCamera: false
property real cameraNear: 0
property real xLookAtOffset: 0
@@ -120,7 +119,7 @@ Entity {
}
components: [
- ShadowMapFrameGraph {
+ PlanetFrameGraph {
id: framegraph
viewCamera: camera
lightCamera: light.lightCamera
@@ -231,10 +230,6 @@ Entity {
checkScaling(focusedPlanet)
}
- function setFreeCamera(free) {
- freeCamera = free
- }
-
function setScale(value, focused) {
// Save actual scale
if (!focused)
@@ -414,7 +409,7 @@ Entity {
//! [3]
function animate(focusedPlanet) {
- if (!ready || freeCamera)
+ if (!ready)
return
advanceTime(focusedPlanet)
diff --git a/examples/qt3d/planets-qml/android/AndroidManifest.xml b/examples/qt3d/planets-qml/android/AndroidManifest.xml
new file mode 100644
index 000000000..0c768c546
--- /dev/null
+++ b/examples/qt3d/planets-qml/android/AndroidManifest.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0"?>
+<manifest package="org.qtproject.planets.qml" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" android:versionCode="1" android:installLocation="auto">
+ <application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="-- %%INSERT_APP_NAME%% --" android:icon="@drawable/icon">
+ <activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="-- %%INSERT_APP_NAME%% --" android:screenOrientation="unspecified" android:launchMode="singleTop">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN"/>
+ <category android:name="android.intent.category.LAUNCHER"/>
+ </intent-filter>
+ <meta-data android:name="android.app.lib_name" android:value="-- %%INSERT_APP_LIB_NAME%% --"/>
+ <meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
+ <meta-data android:name="android.app.repository" android:value="default"/>
+ <meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
+ <meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
+ <!-- Deploy Qt libs as part of package -->
+ <meta-data android:name="android.app.bundle_local_qt_libs" android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --"/>
+ <meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/>
+ <meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/>
+ <!-- Run with local libs -->
+ <meta-data android:name="android.app.use_local_qt_libs" android:value="-- %%USE_LOCAL_QT_LIBS%% --"/>
+ <meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
+ <meta-data android:name="android.app.load_local_libs" android:value="-- %%INSERT_LOCAL_LIBS%% --"/>
+ <meta-data android:name="android.app.load_local_jars" android:value="-- %%INSERT_LOCAL_JARS%% --"/>
+ <meta-data android:name="android.app.static_init_classes" android:value="-- %%INSERT_INIT_CLASSES%% --"/>
+ <!-- Messages maps -->
+ <meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/>
+ <meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/>
+ <meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>
+ <!-- Messages maps -->
+
+ <!-- Splash screen -->
+ <!--
+ <meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/>
+ -->
+ <!-- Splash screen -->
+
+ <!-- Background running -->
+ <!-- Warning: changing this value to true may cause unexpected crashes if the
+ application still try to draw after
+ "applicationStateChanged(Qt::ApplicationSuspended)"
+ signal is sent! -->
+ <meta-data android:name="android.app.background_running" android:value="false"/>
+ <!-- Background running -->
+ </activity>
+ </application>
+ <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="14"/>
+ <supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
+
+ <!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
+ Remove the comment if you do not require these default permissions. -->
+ <!-- %%INSERT_PERMISSIONS -->
+
+ <!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
+ Remove the comment if you do not require these default features. -->
+ <!-- %%INSERT_FEATURES -->
+
+</manifest>
diff --git a/examples/qt3d/planets-qml/android/res/drawable-hdpi/icon.png b/examples/qt3d/planets-qml/android/res/drawable-hdpi/icon.png
new file mode 100644
index 000000000..c62530326
--- /dev/null
+++ b/examples/qt3d/planets-qml/android/res/drawable-hdpi/icon.png
Binary files differ
diff --git a/examples/qt3d/planets-qml/android/res/drawable-ldpi/icon.png b/examples/qt3d/planets-qml/android/res/drawable-ldpi/icon.png
new file mode 100644
index 000000000..c62530326
--- /dev/null
+++ b/examples/qt3d/planets-qml/android/res/drawable-ldpi/icon.png
Binary files differ
diff --git a/examples/qt3d/planets-qml/android/res/drawable-mdpi/icon.png b/examples/qt3d/planets-qml/android/res/drawable-mdpi/icon.png
new file mode 100644
index 000000000..c62530326
--- /dev/null
+++ b/examples/qt3d/planets-qml/android/res/drawable-mdpi/icon.png
Binary files differ
diff --git a/examples/qt3d/planets-qml/planets-qml.pro b/examples/qt3d/planets-qml/planets-qml.pro
index 7c27fc579..58a8b30fd 100644
--- a/examples/qt3d/planets-qml/planets-qml.pro
+++ b/examples/qt3d/planets-qml/planets-qml.pro
@@ -2,7 +2,7 @@
error( "Couldn't find the examples.pri file!" )
}
-QT += qml quick 3dinput
+QT += qml quick
SOURCES += \
main.cpp
@@ -10,7 +10,8 @@ SOURCES += \
OTHER_FILES += \
*.qml \
planets.js \
- shaders/*.* \
+ shaders/gl3/*.* \
+ shaders/es2/*.* \
doc/src/*.* \
doc/images/*.*
@@ -19,4 +20,7 @@ RESOURCES += \
planets-qml-images.qrc
DISTFILES += \
- PlanetsMain.qml
+ PlanetsMain.qml \
+ android/AndroidManifest.xml
+
+ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
diff --git a/examples/qt3d/planets-qml/planets-qml.qrc b/examples/qt3d/planets-qml/planets-qml.qrc
index f8efcbd44..04a67b7d7 100644
--- a/examples/qt3d/planets-qml/planets-qml.qrc
+++ b/examples/qt3d/planets-qml/planets-qml.qrc
@@ -15,17 +15,23 @@
<file>PlanetEffectDS.qml</file>
<file>PlanetEffectDSB.qml</file>
<file>PlanetMaterial.qml</file>
- <file>ShadowMapFrameGraph.qml</file>
+ <file>PlanetFrameGraph.qml</file>
<file>planets.js</file>
<file>meshes/starfield.obj</file>
<file>meshes/ring.obj</file>
- <file>shaders/shadowmap.frag</file>
- <file>shaders/shadowmap.vert</file>
- <file>shaders/planetD.frag</file>
- <file>shaders/planetD.vert</file>
- <file>shaders/planetDB.frag</file>
- <file>shaders/planetDB.vert</file>
- <file>shaders/planetDS.frag</file>
- <file>shaders/planetDSB.frag</file>
+ <file>shaders/gl3/shadowmap.frag</file>
+ <file>shaders/gl3/shadowmap.vert</file>
+ <file>shaders/gl3/planetD.frag</file>
+ <file>shaders/gl3/planetD.vert</file>
+ <file>shaders/gl3/planetDB.frag</file>
+ <file>shaders/gl3/planetDB.vert</file>
+ <file>shaders/gl3/planetDS.frag</file>
+ <file>shaders/gl3/planetDSB.frag</file>
+ <file>shaders/es2/planetD.frag</file>
+ <file>shaders/es2/planetD.vert</file>
+ <file>shaders/es2/planetDB.frag</file>
+ <file>shaders/es2/planetDB.vert</file>
+ <file>shaders/es2/planetDS.frag</file>
+ <file>shaders/es2/planetDSB.frag</file>
</qresource>
</RCC>
diff --git a/examples/qt3d/planets-qml/shaders/es2/planetD.frag b/examples/qt3d/planets-qml/shaders/es2/planetD.frag
new file mode 100644
index 000000000..6df16b5b4
--- /dev/null
+++ b/examples/qt3d/planets-qml/shaders/es2/planetD.frag
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+uniform highp mat4 viewMatrix;
+
+uniform highp vec3 lightPosition;
+uniform highp vec3 lightIntensity;
+
+uniform highp vec3 ka; // Ambient reflectivity
+uniform highp vec3 ks; // Specular reflectivity
+uniform highp float shininess; // Specular shininess factor
+uniform highp float opacity; // Alpha channel
+
+uniform sampler2D diffuseTexture;
+
+varying highp vec4 positionInLightSpace;
+
+varying highp vec3 position;
+varying highp vec3 normal;
+varying highp vec2 texCoord;
+
+highp vec3 dModel(const highp vec2 flipYTexCoord)
+{
+ // Calculate the vector from the light to the fragment
+ highp vec3 s = normalize(vec3(viewMatrix * vec4(lightPosition, 1.0)) - position);
+
+ // Calculate the vector from the fragment to the eye position
+ // (origin since this is in "eye" or "camera" space)
+ highp vec3 v = normalize(-position);
+
+ // Reflect the light beam using the normal at this fragment
+ highp vec3 r = reflect(-s, normal);
+
+ // Calculate the diffuse component
+ highp float diffuse = max(dot(s, normal), 0.0);
+
+ // Calculate the specular component
+ highp float specular = 0.0;
+ if (dot(s, normal) > 0.0)
+ specular = (shininess / (8.0 * 3.14)) * pow(max(dot(r, v), 0.0), shininess);
+
+ // Lookup diffuse and specular factors
+ highp vec3 diffuseColor = texture2D(diffuseTexture, flipYTexCoord).rgb;
+
+ // Combine the ambient, diffuse and specular contributions
+ return lightIntensity * ((ka + diffuse) * diffuseColor + specular * ks);
+}
+
+void main()
+{
+ highp vec2 flipYTexCoord = texCoord;
+ flipYTexCoord.y = 1.0 - texCoord.y;
+
+ highp vec3 result = dModel(flipYTexCoord);
+
+ highp float alpha = opacity * texture2D(diffuseTexture, flipYTexCoord).a;
+
+ gl_FragColor = vec4(result, alpha);
+}
diff --git a/examples/qt3d/planets-qml/shaders/es2/planetD.vert b/examples/qt3d/planets-qml/shaders/es2/planetD.vert
new file mode 100644
index 000000000..12f19768c
--- /dev/null
+++ b/examples/qt3d/planets-qml/shaders/es2/planetD.vert
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+attribute vec3 vertexPosition;
+attribute vec3 vertexNormal;
+attribute vec2 vertexTexCoord;
+
+varying vec4 positionInLightSpace;
+varying vec3 position;
+varying vec3 normal;
+varying vec2 texCoord;
+
+uniform mat4 lightViewProjection;
+uniform mat4 modelMatrix;
+uniform mat4 modelView;
+uniform mat3 modelViewNormal;
+uniform mat4 mvp;
+
+uniform float texCoordScale;
+
+void main()
+{
+ const mat4 shadowMatrix = mat4(0.5, 0.0, 0.0, 0.0,
+ 0.0, 0.5, 0.0, 0.0,
+ 0.0, 0.0, 0.5, 0.0,
+ 0.5, 0.5, 0.5, 1.0);
+
+ positionInLightSpace = shadowMatrix * lightViewProjection * modelMatrix * vec4(vertexPosition, 1.0);
+
+ texCoord = vertexTexCoord * texCoordScale;
+ normal = normalize(modelViewNormal * vertexNormal);
+ position = vec3(modelView * vec4(vertexPosition, 1.0));
+
+ gl_Position = mvp * vec4(vertexPosition, 1.0);
+}
diff --git a/examples/qt3d/planets-qml/shaders/es2/planetDB.frag b/examples/qt3d/planets-qml/shaders/es2/planetDB.frag
new file mode 100644
index 000000000..0a2cc87ee
--- /dev/null
+++ b/examples/qt3d/planets-qml/shaders/es2/planetDB.frag
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+uniform highp mat4 viewMatrix;
+
+uniform highp vec3 lightPosition;
+uniform highp vec3 lightIntensity;
+
+uniform highp vec3 ka; // Ambient reflectivity
+uniform highp vec3 ks; // Specular reflectivity
+uniform highp float shininess; // Specular shininess factor
+uniform highp float opacity; // Alpha channel
+
+uniform sampler2D diffuseTexture;
+uniform sampler2D normalTexture;
+
+varying highp vec4 positionInLightSpace;
+
+varying highp vec3 lightDir;
+varying highp vec3 viewDir;
+varying highp vec2 texCoord;
+
+highp vec3 dbModel(const highp vec3 norm, const highp vec2 flipYTexCoord)
+{
+ // Reflection of light direction about normal
+ highp vec3 r = reflect(-lightDir, norm);
+
+ highp vec3 diffuseColor = texture2D(diffuseTexture, flipYTexCoord).rgb;
+
+ // Calculate the ambient contribution
+ highp vec3 ambient = lightIntensity * ka * diffuseColor;
+
+ // Calculate the diffuse contribution
+ highp float sDotN = max(dot(lightDir, norm), 0.0);
+ highp vec3 diffuse = lightIntensity * diffuseColor * sDotN;
+
+ // Calculate the specular highlight contribution
+ highp vec3 specular = vec3(0.0);
+ if (sDotN > 0.0)
+ specular = (lightIntensity * ks) * pow(max(dot(r, viewDir), 0.0), shininess);
+
+ return ambient + diffuse + specular;
+}
+
+void main()
+{
+ highp vec2 flipYTexCoord = texCoord;
+ flipYTexCoord.y = 1.0 - texCoord.y;
+
+ highp vec4 normal = 2.0 * texture2D(normalTexture, flipYTexCoord) - vec4(1.0);
+
+ highp vec3 result = dbModel(normalize(normal.xyz), flipYTexCoord);
+
+ gl_FragColor = vec4(result, opacity);
+}
diff --git a/examples/qt3d/planets-qml/shaders/es2/planetDB.vert b/examples/qt3d/planets-qml/shaders/es2/planetDB.vert
new file mode 100644
index 000000000..423e337c9
--- /dev/null
+++ b/examples/qt3d/planets-qml/shaders/es2/planetDB.vert
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+attribute vec3 vertexPosition;
+attribute vec3 vertexNormal;
+attribute vec2 vertexTexCoord;
+attribute vec4 vertexTangent;
+
+varying vec4 positionInLightSpace;
+varying vec3 lightDir;
+varying vec3 viewDir;
+varying vec2 texCoord;
+
+uniform mat4 viewMatrix;
+uniform mat4 lightViewProjection;
+uniform mat4 modelMatrix;
+uniform mat4 modelView;
+uniform mat3 modelViewNormal;
+uniform mat4 mvp;
+
+uniform float texCoordScale;
+
+uniform vec3 lightPosition;
+
+void main()
+{
+ const mat4 shadowMatrix = mat4(0.5, 0.0, 0.0, 0.0,
+ 0.0, 0.5, 0.0, 0.0,
+ 0.0, 0.0, 0.5, 0.0,
+ 0.5, 0.5, 0.5, 1.0);
+
+ positionInLightSpace = shadowMatrix * lightViewProjection * modelMatrix * vec4(vertexPosition, 1.0);
+
+ // Pass through texture coordinates
+ texCoord = vertexTexCoord * texCoordScale;
+
+ // Transform position, normal, and tangent to eye coords
+ vec3 normal = normalize(modelViewNormal * vertexNormal);
+ vec3 tangent = normalize(modelViewNormal * vertexTangent.xyz);
+ vec3 position = vec3(modelView * vec4(vertexPosition, 1.0));
+
+ // Calculate binormal vector
+ vec3 binormal = normalize(cross(normal, tangent));
+
+ // Construct matrix to transform from eye coords to tangent space
+ mat3 tangentMatrix = mat3 (
+ tangent.x, binormal.x, normal.x,
+ tangent.y, binormal.y, normal.y,
+ tangent.z, binormal.z, normal.z);
+
+ // Transform light direction and view direction to tangent space
+ vec3 s = lightPosition - position;
+ lightDir = normalize(tangentMatrix * vec3(viewMatrix * vec4(s, 1.0)));
+
+ vec3 v = -position;
+ viewDir = normalize(tangentMatrix * v);
+
+ // Calculate vertex position in clip coordinates
+ gl_Position = mvp * vec4(vertexPosition, 1.0);
+}
diff --git a/examples/qt3d/planets-qml/shaders/es2/planetDS.frag b/examples/qt3d/planets-qml/shaders/es2/planetDS.frag
new file mode 100644
index 000000000..9b35ce10c
--- /dev/null
+++ b/examples/qt3d/planets-qml/shaders/es2/planetDS.frag
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+uniform highp mat4 viewMatrix;
+
+uniform highp vec3 lightPosition;
+uniform highp vec3 lightIntensity;
+
+uniform highp vec3 ka; // Ambient reflectivity
+uniform highp float shininess; // Specular shininess factor
+uniform highp float opacity; // Alpha channel
+
+uniform sampler2D diffuseTexture;
+uniform sampler2D specularTexture;
+
+varying highp vec4 positionInLightSpace;
+
+varying highp vec3 position;
+varying highp vec3 normal;
+varying highp vec2 texCoord;
+
+highp vec3 dsModel(const highp vec2 flipYTexCoord)
+{
+ // Calculate the vector from the light to the fragment
+ highp vec3 s = normalize(vec3(viewMatrix * vec4(lightPosition, 1.0)) - position);
+
+ // Calculate the vector from the fragment to the eye position
+ // (origin since this is in "eye" or "camera" space)
+ highp vec3 v = normalize(-position);
+
+ // Reflect the light beam using the normal at this fragment
+ highp vec3 r = reflect(-s, normal);
+
+ // Calculate the diffuse component
+ highp float diffuse = max(dot(s, normal), 0.0);
+
+ // Calculate the specular component
+ highp float specular = 0.0;
+ if (dot(s, normal) > 0.0)
+ specular = (shininess / (8.0 * 3.14)) * pow(max(dot(r, v), 0.0), shininess);
+
+ // Lookup diffuse and specular factors
+ highp vec3 diffuseColor = texture2D(diffuseTexture, flipYTexCoord).rgb;
+ highp vec3 specularColor = texture2D(specularTexture, flipYTexCoord).rgb;
+
+ // Combine the ambient, diffuse and specular contributions
+ return lightIntensity * ((ka + diffuse) * diffuseColor + specular * specularColor);
+}
+
+void main()
+{
+ highp vec2 flipYTexCoord = texCoord;
+ flipYTexCoord.y = 1.0 - texCoord.y;
+
+ highp vec3 result = dsModel(flipYTexCoord);
+
+ highp float alpha = opacity * texture2D(diffuseTexture, flipYTexCoord).a;
+
+ gl_FragColor = vec4(result, alpha);
+}
diff --git a/examples/qt3d/planets-qml/shaders/es2/planetDSB.frag b/examples/qt3d/planets-qml/shaders/es2/planetDSB.frag
new file mode 100644
index 000000000..cbbdae353
--- /dev/null
+++ b/examples/qt3d/planets-qml/shaders/es2/planetDSB.frag
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** 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 http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+uniform highp mat4 viewMatrix;
+
+uniform highp vec3 lightPosition;
+uniform highp vec3 lightIntensity;
+
+uniform highp vec3 ka; // Ambient reflectivity
+uniform highp float shininess; // Specular shininess factor
+uniform highp float opacity; // Alpha channel
+
+uniform sampler2D diffuseTexture;
+uniform sampler2D specularTexture;
+uniform sampler2D normalTexture;
+
+varying highp vec4 positionInLightSpace;
+
+varying highp vec3 lightDir;
+varying highp vec3 viewDir;
+varying highp vec2 texCoord;
+
+highp vec3 dsbModel(const highp vec3 norm, const highp vec2 flipYTexCoord)
+{
+ // Reflection of light direction about normal
+ highp vec3 r = reflect(-lightDir, norm);
+
+ highp vec3 diffuseColor = texture2D(diffuseTexture, flipYTexCoord).rgb;
+ highp vec3 specularColor = texture2D(specularTexture, flipYTexCoord).rgb;
+
+ // Calculate the ambient contribution
+ highp vec3 ambient = lightIntensity * ka * diffuseColor;
+
+ // Calculate the diffuse contribution
+ highp float sDotN = max(dot(lightDir, norm), 0.0);
+ highp vec3 diffuse = lightIntensity * diffuseColor * sDotN;
+
+ // Calculate the specular highlight contribution
+ highp vec3 specular = vec3(0.0);
+ if (sDotN > 0.0)
+ specular = (lightIntensity * (shininess / (8.0 * 3.14))) * pow(max(dot(r, viewDir), 0.0), shininess);
+
+ specular *= specularColor;
+
+ return ambient + diffuse + specular;
+}
+
+void main()
+{
+ highp vec2 flipYTexCoord = texCoord;
+ flipYTexCoord.y = 1.0 - texCoord.y;
+
+ // Sample the textures at the interpolated texCoords
+ highp vec4 normal = 2.0 * texture2D(normalTexture, flipYTexCoord) - vec4(1.0);
+
+ highp vec3 result = dsbModel(normalize(normal.xyz), flipYTexCoord);
+
+ // Combine spec with ambient+diffuse for final fragment color
+ gl_FragColor = vec4(result, opacity);
+}
diff --git a/examples/qt3d/planets-qml/shaders/planetD.frag b/examples/qt3d/planets-qml/shaders/gl3/planetD.frag
index 62d941d25..62d941d25 100644
--- a/examples/qt3d/planets-qml/shaders/planetD.frag
+++ b/examples/qt3d/planets-qml/shaders/gl3/planetD.frag
diff --git a/examples/qt3d/planets-qml/shaders/planetD.vert b/examples/qt3d/planets-qml/shaders/gl3/planetD.vert
index 41a1db6e4..41a1db6e4 100644
--- a/examples/qt3d/planets-qml/shaders/planetD.vert
+++ b/examples/qt3d/planets-qml/shaders/gl3/planetD.vert
diff --git a/examples/qt3d/planets-qml/shaders/planetDB.frag b/examples/qt3d/planets-qml/shaders/gl3/planetDB.frag
index bf53a127b..bf53a127b 100644
--- a/examples/qt3d/planets-qml/shaders/planetDB.frag
+++ b/examples/qt3d/planets-qml/shaders/gl3/planetDB.frag
diff --git a/examples/qt3d/planets-qml/shaders/planetDB.vert b/examples/qt3d/planets-qml/shaders/gl3/planetDB.vert
index e30394aa3..e30394aa3 100644
--- a/examples/qt3d/planets-qml/shaders/planetDB.vert
+++ b/examples/qt3d/planets-qml/shaders/gl3/planetDB.vert
diff --git a/examples/qt3d/planets-qml/shaders/planetDS.frag b/examples/qt3d/planets-qml/shaders/gl3/planetDS.frag
index 2a1b78bfa..2a1b78bfa 100644
--- a/examples/qt3d/planets-qml/shaders/planetDS.frag
+++ b/examples/qt3d/planets-qml/shaders/gl3/planetDS.frag
diff --git a/examples/qt3d/planets-qml/shaders/planetDSB.frag b/examples/qt3d/planets-qml/shaders/gl3/planetDSB.frag
index deb9565d4..deb9565d4 100644
--- a/examples/qt3d/planets-qml/shaders/planetDSB.frag
+++ b/examples/qt3d/planets-qml/shaders/gl3/planetDSB.frag
diff --git a/examples/qt3d/planets-qml/shaders/shadowmap.frag b/examples/qt3d/planets-qml/shaders/gl3/shadowmap.frag
index 63f203da6..63f203da6 100644
--- a/examples/qt3d/planets-qml/shaders/shadowmap.frag
+++ b/examples/qt3d/planets-qml/shaders/gl3/shadowmap.frag
diff --git a/examples/qt3d/planets-qml/shaders/shadowmap.vert b/examples/qt3d/planets-qml/shaders/gl3/shadowmap.vert
index ca93360c6..ca93360c6 100644
--- a/examples/qt3d/planets-qml/shaders/shadowmap.vert
+++ b/examples/qt3d/planets-qml/shaders/gl3/shadowmap.vert