diff options
-rw-r--r-- | examples/qt3d/planets-qml/PlanetEffect.qml (renamed from examples/qt3d/planets-qml/PlanetEffectD.qml) | 75 | ||||
-rw-r--r-- | examples/qt3d/planets-qml/PlanetEffectDSB.qml | 135 | ||||
-rw-r--r-- | examples/qt3d/planets-qml/PlanetMaterial.qml | 23 | ||||
-rw-r--r-- | examples/qt3d/planets-qml/PlanetShadowEffectD.qml | 149 | ||||
-rw-r--r-- | examples/qt3d/planets-qml/ShadowEffect.qml (renamed from examples/qt3d/planets-qml/PlanetEffectDB.qml) | 93 | ||||
-rw-r--r-- | examples/qt3d/planets-qml/SolarSystem.qml | 238 | ||||
-rw-r--r-- | examples/qt3d/planets-qml/SunEffect.qml (renamed from examples/qt3d/planets-qml/CloudEffectDS.qml) | 77 | ||||
-rw-r--r-- | examples/qt3d/planets-qml/android/AndroidManifest.xml | 2 | ||||
-rw-r--r-- | examples/qt3d/planets-qml/planets-qml.qrc | 14 | ||||
-rw-r--r-- | examples/qt3d/planets-qml/shaders/es2/sun.frag | 59 | ||||
-rw-r--r-- | examples/qt3d/planets-qml/shaders/es2/sun.vert | 54 | ||||
-rw-r--r-- | examples/qt3d/planets-qml/shaders/gl3/sun.frag | 63 | ||||
-rw-r--r-- | examples/qt3d/planets-qml/shaders/gl3/sun.vert | 56 |
13 files changed, 512 insertions, 526 deletions
diff --git a/examples/qt3d/planets-qml/PlanetEffectD.qml b/examples/qt3d/planets-qml/PlanetEffect.qml index d8660650f..7c8bf4948 100644 --- a/examples/qt3d/planets-qml/PlanetEffectD.qml +++ b/examples/qt3d/planets-qml/PlanetEffect.qml @@ -57,6 +57,10 @@ Effect { property Texture2D shadowTexture property PlanetsLight light + property string vertexES: "qrc:/shaders/es2/planetD.vert" + property string fragmentES: "qrc:/shaders/es2/planetD.frag" + property string vertexGL: "qrc:/shaders/gl3/planetD.vert" + property string fragmentGL: "qrc:/shaders/gl3/planetD.frag" parameters: [ Parameter { name: "lightViewProjection"; value: root.light.lightViewProjection }, @@ -64,6 +68,32 @@ Effect { Parameter { name: "lightIntensity"; value: root.light.lightIntensity } ] + FilterKey { id: eskey; name: "name"; value: "ES2" } + FilterKey { id: glkey; name: "name"; value: "Desktop" } + FilterKey { id: forwardkey; name : "pass"; value : "forward" } + + RenderPass { + id: glpass + filterKeys: [ forwardkey ] + + shaderProgram: ShaderProgram { + vertexShaderCode: loadSource(vertexGL) + fragmentShaderCode: loadSource(fragmentGL) + } + // no special render state set => use the default set of states + } + + RenderPass { + id: espass + filterKeys: [ forwardkey ] + + shaderProgram: ShaderProgram { + vertexShaderCode: loadSource(vertexES) + fragmentShaderCode: loadSource(fragmentES) + } + // no special render state set => use the default set of states + } + techniques: [ Technique { graphicsApiFilter { @@ -73,20 +103,9 @@ Effect { minorVersion: 2 } - filterKeys: [ FilterKey { name: "name"; value: "Desktop" } ] + filterKeys: [ glkey ] - renderPasses: [ - RenderPass { - filterKeys: [ FilterKey { name : "pass"; value : "forward" } ] - - shaderProgram: ShaderProgram { - 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 - } - ] + renderPasses: [ glpass ] }, Technique { graphicsApiFilter { @@ -94,20 +113,9 @@ Effect { majorVersion: 2 } - filterKeys: [ FilterKey { name: "name"; value: "ES2" } ] - - renderPasses: [ - RenderPass { - filterKeys: [ FilterKey { name : "pass"; value : "forward" } ] + filterKeys: [ eskey ] - 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 - } - ] + renderPasses: [ espass ] }, Technique { graphicsApiFilter { @@ -116,20 +124,9 @@ Effect { minorVersion: 0 } - filterKeys: [ FilterKey { name: "name"; value: "ES2" } ] - - renderPasses: [ - RenderPass { - filterKeys: [ FilterKey { name : "pass"; value : "forward" } ] - - shaderProgram: ShaderProgram { - vertexShaderCode: loadSource("qrc:/shaders/es2/planetD.vert") - fragmentShaderCode: loadSource("qrc:/shaders/es2/planetD.frag") - } + filterKeys: [ eskey ] - // no special render state set => use the default set of states - } - ] + renderPasses: [ espass ] } ] } diff --git a/examples/qt3d/planets-qml/PlanetEffectDSB.qml b/examples/qt3d/planets-qml/PlanetEffectDSB.qml deleted file mode 100644 index b9cda657a..000000000 --- a/examples/qt3d/planets-qml/PlanetEffectDSB.qml +++ /dev/null @@ -1,135 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt3D.Core 2.0 -import Qt3D.Render 2.0 - -Effect { - id: root - - property Texture2D shadowTexture - property PlanetsLight light - - parameters: [ - Parameter { name: "lightViewProjection"; value: root.light.lightViewProjection }, - Parameter { name: "lightPosition"; value: root.light.lightPosition }, - Parameter { name: "lightIntensity"; value: root.light.lightIntensity } - ] - - techniques: [ - Technique { - graphicsApiFilter { - api: GraphicsApiFilter.OpenGL - profile: GraphicsApiFilter.CoreProfile - majorVersion: 3 - minorVersion: 2 - } - - filterKeys: [ FilterKey { name: "name"; value: "Desktop" } ] - - renderPasses: [ - RenderPass { - filterKeys: [ FilterKey { name : "pass"; value : "forward" } ] - - shaderProgram: ShaderProgram { - 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 { - graphicsApiFilter { - api: GraphicsApiFilter.OpenGL - majorVersion: 2 - } - - filterKeys: [ FilterKey { name: "name"; value: "ES2" } ] - - renderPasses: [ - RenderPass { - filterKeys: [ FilterKey { name : "pass"; value : "forward" } ] - - 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 { - graphicsApiFilter { - api: GraphicsApiFilter.OpenGLES - majorVersion: 2 - minorVersion: 0 - } - - filterKeys: [ FilterKey { name: "name"; value: "ES2" } ] - - renderPasses: [ - RenderPass { - filterKeys: [ FilterKey { name : "pass"; value : "forward" } ] - - 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/PlanetMaterial.qml b/examples/qt3d/planets-qml/PlanetMaterial.qml index ca0fa5405..4d50aee8d 100644 --- a/examples/qt3d/planets-qml/PlanetMaterial.qml +++ b/examples/qt3d/planets-qml/PlanetMaterial.qml @@ -59,9 +59,9 @@ Material { property color diffuseColor: Qt.rgba(0.7, 0.7, 0.7, 1.0) property color specularColor: Qt.rgba(0.5, 0.5, 0.5, 1.0) property real shininess: 150.0 - property alias diffuseMap: diffuseTextureImage.source - property alias specularMap: specularTextureImage.source - property alias normalMap: normalTextureImage.source + property string diffuseMap + property string specularMap + property string normalMap property real textureScale: 1.0 property real opacity: 1.0 @@ -94,7 +94,10 @@ Material { } generateMipMaps: true maximumAnisotropy: 16.0 - TextureImage { id: diffuseTextureImage } + TextureImage { + id: diffuseTextureImage + source: diffuseMap + } } }, Parameter { @@ -109,7 +112,11 @@ Material { } generateMipMaps: true maximumAnisotropy: 16.0 - TextureImage { id: specularTextureImage } + TextureImage { + id: specularTextureImage + // Get rid of runtime warnings. It's safe, as the texture just isn't used + source: specularMap !== "" ? specularMap : "qrc:/images/uranusmap.jpg" + } } }, Parameter { @@ -123,7 +130,11 @@ Material { y: WrapMode.Repeat } maximumAnisotropy: 16.0 - TextureImage { id: normalTextureImage } + TextureImage { + id: normalTextureImage + // Get rid of runtime warnings. It's safe, as the texture just isn't used + source: normalMap !== "" ? normalMap : "qrc:/images/uranusmap.jpg" + } } }, Parameter { diff --git a/examples/qt3d/planets-qml/PlanetShadowEffectD.qml b/examples/qt3d/planets-qml/PlanetShadowEffectD.qml deleted file mode 100644 index 05022586a..000000000 --- a/examples/qt3d/planets-qml/PlanetShadowEffectD.qml +++ /dev/null @@ -1,149 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt3D module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import Qt3D.Core 2.0 -import Qt3D.Render 2.0 - -Effect { - id: root - - property Texture2D shadowTexture - property PlanetsLight light - - parameters: [ - Parameter { name: "lightViewProjection"; value: root.light.lightViewProjection }, - Parameter { name: "lightPosition"; value: root.light.lightPosition }, - Parameter { name: "lightIntensity"; value: root.light.lightIntensity }, - Parameter { name: "shadowMapTexture"; value: root.shadowTexture } - ] - - techniques: [ - Technique { - graphicsApiFilter { - api: GraphicsApiFilter.OpenGL - profile: GraphicsApiFilter.CoreProfile - majorVersion: 3 - minorVersion: 2 - } - - filterKeys: [ FilterKey { name: "name"; value: "Desktop" } ] - - renderPasses: [ - RenderPass { - filterKeys: [ FilterKey { name: "pass"; value: "shadowmap" } ] - - shaderProgram: ShaderProgram { - vertexShaderCode: loadSource("qrc:/shaders/gl3/shadowmap.vert") - fragmentShaderCode: loadSource("qrc:/shaders/gl3/shadowmap.frag") - } - - renderStates: [ - PolygonOffset { scaleFactor: 4; depthSteps: 4 }, - DepthTest { depthFunction: DepthTest.Less } - ] - }, - RenderPass { - filterKeys: [ FilterKey { name : "pass"; value : "forward" } ] - - shaderProgram: ShaderProgram { - 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 { - graphicsApiFilter { - api: GraphicsApiFilter.OpenGL - majorVersion: 2 - } - - filterKeys: [ FilterKey { name: "name"; value: "ES2" } ] - - renderPasses: [ - RenderPass { - filterKeys: [ FilterKey { name : "pass"; value : "forward" } ] - - 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 { - graphicsApiFilter { - api: GraphicsApiFilter.OpenGLES - majorVersion: 2 - minorVersion: 0 - } - - filterKeys: [ FilterKey { name: "name"; value: "ES2" } ] - - renderPasses: [ - RenderPass { - filterKeys: [ FilterKey { name : "pass"; value : "forward" } ] - - 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/ShadowEffect.qml index 40af57fce..c09ebebc5 100644 --- a/examples/qt3d/planets-qml/PlanetEffectDB.qml +++ b/examples/qt3d/planets-qml/ShadowEffect.qml @@ -61,9 +61,55 @@ Effect { parameters: [ Parameter { name: "lightViewProjection"; value: root.light.lightViewProjection }, Parameter { name: "lightPosition"; value: root.light.lightPosition }, - Parameter { name: "lightIntensity"; value: root.light.lightIntensity } + Parameter { name: "lightIntensity"; value: root.light.lightIntensity }, + Parameter { name: "shadowMapTexture"; value: root.shadowTexture } ] + FilterKey { id: desktopkey; name: "name"; value: "Desktop" } + FilterKey { id: shadowkey; name: "pass"; value: "shadowmap" } + FilterKey { id: forwardkey; name : "pass"; value : "forward" } + FilterKey { id: eskey; name: "name"; value: "ES2" } + + RenderPass { + id: shadowpass + filterKeys: [ shadowkey ] + + shaderProgram: ShaderProgram { + vertexShaderCode: loadSource("qrc:/shaders/gl3/shadowmap.vert") + fragmentShaderCode: loadSource("qrc:/shaders/gl3/shadowmap.frag") + } + + renderStates: [ + PolygonOffset { scaleFactor: 4; depthSteps: 4 }, + DepthTest { depthFunction: DepthTest.Less } + ] + } + + RenderPass { + id: glpass + filterKeys: [ forwardkey ] + + shaderProgram: ShaderProgram { + 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 + } + + RenderPass { + id: espass + filterKeys: [ forwardkey ] + + 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 + } + + techniques: [ Technique { graphicsApiFilter { @@ -73,20 +119,9 @@ Effect { minorVersion: 2 } - filterKeys: [ FilterKey { name: "name"; value: "Desktop" } ] - - renderPasses: [ - RenderPass { - filterKeys: [ FilterKey { name : "pass"; value : "forward" } ] + filterKeys: [ desktopkey ] - shaderProgram: ShaderProgram { - 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 - } - ] + renderPasses: [ shadowpass, glpass ] }, Technique { graphicsApiFilter { @@ -94,20 +129,9 @@ Effect { majorVersion: 2 } - filterKeys: [ FilterKey { name: "name"; value: "ES2" } ] - - renderPasses: [ - RenderPass { - filterKeys: [ FilterKey { name : "pass"; value : "forward" } ] - - shaderProgram: ShaderProgram { - vertexShaderCode: loadSource("qrc:/shaders/es2/planetDB.vert") - fragmentShaderCode: loadSource("qrc:/shaders/es2/planetDB.frag") - } + filterKeys: [ eskey ] - // no special render state set => use the default set of states - } - ] + renderPasses: [ espass ] }, Technique { graphicsApiFilter { @@ -116,20 +140,9 @@ Effect { minorVersion: 0 } - filterKeys: [ FilterKey { name: "name"; value: "ES2" } ] - - renderPasses: [ - RenderPass { - filterKeys: [ FilterKey { name : "pass"; value : "forward" } ] - - shaderProgram: ShaderProgram { - vertexShaderCode: loadSource("qrc:/shaders/es2/planetDB.vert") - fragmentShaderCode: loadSource("qrc:/shaders/es2/planetDB.frag") - } + filterKeys: [ eskey ] - // no special render state set => use the default set of states - } - ] + renderPasses: [ espass ] } ] } diff --git a/examples/qt3d/planets-qml/SolarSystem.qml b/examples/qt3d/planets-qml/SolarSystem.qml index 6cc8814c9..0cd2a4db5 100644 --- a/examples/qt3d/planets-qml/SolarSystem.qml +++ b/examples/qt3d/planets-qml/SolarSystem.qml @@ -151,29 +151,45 @@ Entity { InputSettings {} ] - CloudEffectDS { - id: effectDS + PlanetEffect { + id: effectD light: light } - PlanetEffectD { - id: effectD + PlanetEffect { + id: effectDB light: light + vertexES: "qrc:/shaders/es2/planetDB.vert" + fragmentES: "qrc:/shaders/es2/planetDB.frag" + vertexGL: "qrc:/shaders/gl3/planetDB.vert" + fragmentGL: "qrc:/shaders/gl3/planetDB.frag" } - PlanetShadowEffectD { - id: shadowMapEffectD - shadowTexture: framegraph.shadowTexture + PlanetEffect { + id: effectDSB light: light + vertexES: "qrc:/shaders/es2/planetDB.vert" + fragmentES: "qrc:/shaders/es2/planetDSB.frag" + vertexGL: "qrc:/shaders/gl3/planetDB.vert" + fragmentGL: "qrc:/shaders/gl3/planetDSB.frag" } - PlanetEffectDB { - id: effectDB + PlanetEffect { + id: cloudEffect light: light + vertexES: "qrc:/shaders/es2/planetD.vert" + fragmentES: "qrc:/shaders/es2/planetDS.frag" + vertexGL: "qrc:/shaders/gl3/planetD.vert" + fragmentGL: "qrc:/shaders/gl3/planetDS.frag" } - PlanetEffectDSB { - id: effectDSB + SunEffect { + id: sunEffect + } + + ShadowEffect { + id: shadowMapEffect + shadowTexture: framegraph.shadowTexture light: light } @@ -474,15 +490,16 @@ Entity { // STARFIELD // - Mesh { - id: starfield - source: "qrc:/meshes/starfield.obj" - } - Entity { id: starfieldEntity - property Material materialStarfield: PlanetMaterial { + Mesh { + id: starfield + source: "qrc:/meshes/starfield.obj" + } + + PlanetMaterial { + id: materialStarfield effect: effectD ambientLight: ambientStrengthStarfield specularColor: Qt.rgba(0.0, 0.0, 0.0, 1.0) @@ -502,20 +519,19 @@ Entity { // SUN // - Planet { - id: sun - tilt: planetData[Planets.SUN].tilt - } - Entity { id: sunEntity - property Material materialSun: PlanetMaterial { - effect: effectD + Planet { + id: sun + tilt: planetData[Planets.SUN].tilt + } + + PlanetMaterial { + id: materialSun + effect: sunEffect ambientLight: ambientStrengthSun - specularColor: Qt.rgba(0.0, 0.0, 0.0, 1.0) diffuseMap: "qrc:/images/sunmap.jpg" - shininess: 1000000.0 } property Transform transformSun: Transform { @@ -538,15 +554,16 @@ Entity { // MERCURY - Planet { - id: mercury - tilt: planetData[Planets.MERCURY].tilt - } - Entity { id: mercuryEntity - property Material materialMercury: PlanetMaterial { + Planet { + id: mercury + tilt: planetData[Planets.MERCURY].tilt + } + + PlanetMaterial { + id: materialMercury effect: effectDB ambientLight: ambientStrengthPlanet specularColor: Qt.rgba(0.2, 0.2, 0.2, 1.0) @@ -571,15 +588,16 @@ Entity { // VENUS - Planet { - id: venus - tilt: planetData[Planets.VENUS].tilt - } - Entity { id: venusEntity - property Material materialVenus: PlanetMaterial { + Planet { + id: venus + tilt: planetData[Planets.VENUS].tilt + } + + PlanetMaterial { + id: materialVenus effect: effectDB ambientLight: ambientStrengthPlanet specularColor: Qt.rgba(0.2, 0.2, 0.2, 1.0) @@ -605,15 +623,16 @@ Entity { // EARTH //! [1] - Planet { - id: earth - tilt: planetData[Planets.EARTH].tilt - } - Entity { id: earthEntity - property Material materialEarth: PlanetMaterial { + Planet { + id: earth + tilt: planetData[Planets.EARTH].tilt + } + + PlanetMaterial { + id: materialEarth effect: effectDSB ambientLight: ambientStrengthPlanet diffuseMap: "qrc:/images/earthmap1k.jpg" @@ -639,16 +658,17 @@ Entity { // EARTH CLOUDS - Planet { - id: earthClouds - tilt: planetData[Planets.EARTH].tilt - } - Entity { id: earthCloudsEntity - property Material materialEarthClouds: PlanetMaterial { - effect: effectDS + Planet { + id: earthClouds + tilt: planetData[Planets.EARTH].tilt + } + + PlanetMaterial { + id: materialEarthClouds + effect: cloudEffect ambientLight: ambientStrengthClouds diffuseMap: "qrc:/images/earthcloudmapcolortrans.png" specularMap: "qrc:/images/earthcloudmapspec.jpg" @@ -672,15 +692,16 @@ Entity { // MOON - Planet { - id: moon - tilt: planetData[Planets.MOON].tilt - } - Entity { id: moonEntity - property Material materialMoon: PlanetMaterial { + Planet { + id: moon + tilt: planetData[Planets.MOON].tilt + } + + PlanetMaterial { + id: materialMoon effect: effectDB ambientLight: ambientStrengthPlanet specularColor: Qt.rgba(0.2, 0.2, 0.2, 1.0) @@ -705,15 +726,16 @@ Entity { // MARS - Planet { - id: mars - tilt: planetData[Planets.MARS].tilt - } - Entity { id: marsEntity - property Material materialMars: PlanetMaterial { + Planet { + id: mars + tilt: planetData[Planets.MARS].tilt + } + + PlanetMaterial { + id: materialMars effect: effectDB ambientLight: ambientStrengthPlanet specularColor: Qt.rgba(0.2, 0.2, 0.2, 1.0) @@ -738,15 +760,16 @@ Entity { // JUPITER - Planet { - id: jupiter - tilt: planetData[Planets.JUPITER].tilt - } - Entity { id: jupiterEntity - property Material materialJupiter: PlanetMaterial { + Planet { + id: jupiter + tilt: planetData[Planets.JUPITER].tilt + } + + PlanetMaterial { + id: materialJupiter effect: effectD ambientLight: ambientStrengthPlanet specularColor: Qt.rgba(0.2, 0.2, 0.2, 1.0) @@ -770,16 +793,17 @@ Entity { // SATURN - Planet { - id: saturn - tilt: planetData[Planets.SATURN].tilt - } - Entity { id: saturnEntity - property Material materialSaturn: PlanetMaterial { - effect: shadowMapEffectD + Planet { + id: saturn + tilt: planetData[Planets.SATURN].tilt + } + + PlanetMaterial { + id: materialSaturn + effect: shadowMapEffect ambientLight: ambientStrengthPlanet specularColor: Qt.rgba(0.2, 0.2, 0.2, 1.0) diffuseMap: "qrc:/images/saturnmap.jpg" @@ -802,17 +826,18 @@ Entity { // SATURN RING - Ring { - id: saturnRing - innerRadius: saturnRingInnerRadius - outerRadius: saturnRingOuterRadius - } - Entity { id: saturnRingEntity - property Material materialSaturnRing: PlanetMaterial { - effect: shadowMapEffectD + Ring { + id: saturnRing + innerRadius: saturnRingInnerRadius + outerRadius: saturnRingOuterRadius + } + + PlanetMaterial { + id: materialSaturnRing + effect: shadowMapEffect ambientLight: ambientStrengthRing specularColor: Qt.rgba(0.01, 0.01, 0.01, 1.0) diffuseMap: "qrc:/images/saturnringcolortrans.png" @@ -836,16 +861,17 @@ Entity { // URANUS - Planet { - id: uranus - tilt: planetData[Planets.URANUS].tilt - } - Entity { id: uranusEntity - property Material materialUranus: PlanetMaterial { - effect: shadowMapEffectD + Planet { + id: uranus + tilt: planetData[Planets.URANUS].tilt + } + + PlanetMaterial { + id: materialUranus + effect: shadowMapEffect ambientLight: ambientStrengthPlanet specularColor: Qt.rgba(0.2, 0.2, 0.2, 1.0) diffuseMap: "qrc:/images/uranusmap.jpg" @@ -868,17 +894,18 @@ Entity { // URANUS RING - Ring { - id: uranusRing - innerRadius: uranusRingInnerRadius - outerRadius: uranusRingOuterRadius - } - Entity { id: uranusRingEntity - property Material materialUranusRing: PlanetMaterial { - effect: shadowMapEffectD + Ring { + id: uranusRing + innerRadius: uranusRingInnerRadius + outerRadius: uranusRingOuterRadius + } + + PlanetMaterial { + id: materialUranusRing + effect: shadowMapEffect ambientLight: ambientStrengthRing specularColor: Qt.rgba(0.01, 0.01, 0.01, 1.0) diffuseMap: "qrc:/images/uranusringcolortrans.png" @@ -902,15 +929,16 @@ Entity { // NEPTUNE - Planet { - id: neptune - tilt: planetData[Planets.NEPTUNE].tilt - } - Entity { id: neptuneEntity - property Material materialNeptune: PlanetMaterial { + Planet { + id: neptune + tilt: planetData[Planets.NEPTUNE].tilt + } + + PlanetMaterial { + id: materialNeptune effect: effectD ambientLight: ambientStrengthPlanet specularColor: Qt.rgba(0.2, 0.2, 0.2, 1.0) diff --git a/examples/qt3d/planets-qml/CloudEffectDS.qml b/examples/qt3d/planets-qml/SunEffect.qml index 4f07559e3..4cda00081 100644 --- a/examples/qt3d/planets-qml/CloudEffectDS.qml +++ b/examples/qt3d/planets-qml/SunEffect.qml @@ -55,13 +55,33 @@ import Qt3D.Render 2.0 Effect { id: root - property Texture2D shadowTexture - property PlanetsLight light + FilterKey { id: desktopkey; name: "name"; value: "Desktop" } + FilterKey { id: forwardkey; name : "pass"; value : "forward" } + FilterKey { id: eskey; name: "name"; value: "ES2" } - parameters: [ - Parameter { name: "lightPosition"; value: root.light.lightPosition }, - Parameter { name: "lightIntensity"; value: root.light.lightIntensity } - ] + RenderPass { + id: glpass + filterKeys: [ forwardkey ] + + shaderProgram: ShaderProgram { + vertexShaderCode: loadSource("qrc:/shaders/gl3/sun.vert") + fragmentShaderCode: loadSource("qrc:/shaders/gl3/sun.frag") + } + + // no special render state set => use the default set of states + } + + RenderPass { + id: espass + filterKeys: [ forwardkey ] + + shaderProgram: ShaderProgram { + vertexShaderCode: loadSource("qrc:/shaders/es2/sun.vert") + fragmentShaderCode: loadSource("qrc:/shaders/es2/sun.frag") + } + + // no special render state set => use the default set of states + } techniques: [ Technique { @@ -72,20 +92,9 @@ Effect { minorVersion: 2 } - filterKeys: [ FilterKey { name: "name"; value: "Desktop" } ] - - renderPasses: [ - RenderPass { - filterKeys: [ FilterKey { name : "pass"; value : "forward" } ] + filterKeys: [ desktopkey ] - 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 - } - ] + renderPasses: [ glpass ] }, Technique { graphicsApiFilter { @@ -93,20 +102,9 @@ Effect { majorVersion: 2 } - filterKeys: [ FilterKey { name: "name"; value: "ES2" } ] - - renderPasses: [ - RenderPass { - filterKeys: [ FilterKey { name : "pass"; value : "forward" } ] + filterKeys: [ eskey ] - 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 - } - ] + renderPasses: [ espass ] }, Technique { graphicsApiFilter { @@ -115,20 +113,9 @@ Effect { minorVersion: 0 } - filterKeys: [ FilterKey { name: "name"; value: "ES2" } ] - - renderPasses: [ - RenderPass { - filterKeys: [ FilterKey { name : "pass"; value : "forward" } ] - - shaderProgram: ShaderProgram { - vertexShaderCode: loadSource("qrc:/shaders/es2/planetD.vert") - fragmentShaderCode: loadSource("qrc:/shaders/es2/planetDS.frag") - } + filterKeys: [ eskey ] - // no special render state set => use the default set of states - } - ] + renderPasses: [ espass ] } ] } diff --git a/examples/qt3d/planets-qml/android/AndroidManifest.xml b/examples/qt3d/planets-qml/android/AndroidManifest.xml index f4e10846c..0252a83b8 100644 --- a/examples/qt3d/planets-qml/android/AndroidManifest.xml +++ b/examples/qt3d/planets-qml/android/AndroidManifest.xml @@ -42,7 +42,7 @@ <!-- Background running --> </activity> </application> - <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="14"/> + <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="16"/> <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. diff --git a/examples/qt3d/planets-qml/planets-qml.qrc b/examples/qt3d/planets-qml/planets-qml.qrc index dceaffeeb..4b6bd433d 100644 --- a/examples/qt3d/planets-qml/planets-qml.qrc +++ b/examples/qt3d/planets-qml/planets-qml.qrc @@ -9,16 +9,16 @@ <file>Planet.qml</file> <file>Ring.qml</file> <file>PlanetsLight.qml</file> - <file>CloudEffectDS.qml</file> - <file>PlanetEffectD.qml</file> - <file>PlanetEffectDB.qml</file> - <file>PlanetEffectDSB.qml</file> - <file>PlanetMaterial.qml</file> - <file>PlanetShadowEffectD.qml</file> + <file>SunEffect.qml</file> + <file>PlanetEffect.qml</file> + <file>ShadowEffect.qml</file> <file>PlanetFrameGraph.qml</file> + <file>PlanetMaterial.qml</file> <file>planets.js</file> <file>meshes/starfield.obj</file> <file>meshes/ring.obj</file> + <file>shaders/gl3/sun.frag</file> + <file>shaders/gl3/sun.vert</file> <file>shaders/gl3/shadowmap.frag</file> <file>shaders/gl3/shadowmap.vert</file> <file>shaders/gl3/planetD.frag</file> @@ -27,6 +27,8 @@ <file>shaders/gl3/planetDB.vert</file> <file>shaders/gl3/planetDS.frag</file> <file>shaders/gl3/planetDSB.frag</file> + <file>shaders/es2/sun.frag</file> + <file>shaders/es2/sun.vert</file> <file>shaders/es2/planetD.frag</file> <file>shaders/es2/planetD.vert</file> <file>shaders/es2/planetDB.frag</file> diff --git a/examples/qt3d/planets-qml/shaders/es2/sun.frag b/examples/qt3d/planets-qml/shaders/es2/sun.frag new file mode 100644 index 000000000..263112d24 --- /dev/null +++ b/examples/qt3d/planets-qml/shaders/es2/sun.frag @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** 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 sampler2D diffuseTexture; + +varying highp vec3 position; +varying highp vec2 texCoord; + +highp vec4 dModel(const highp vec2 flipYTexCoord) +{ + // Lookup diffuse + highp vec3 diffuseColor = texture2D(diffuseTexture, flipYTexCoord).rgb; + + return vec4(diffuseColor, 1.0); +} + +void main() +{ + highp vec2 flipYTexCoord = texCoord; + flipYTexCoord.y = 1.0 - texCoord.y; + + highp vec4 result = dModel(flipYTexCoord); + + gl_FragColor = result; +} diff --git a/examples/qt3d/planets-qml/shaders/es2/sun.vert b/examples/qt3d/planets-qml/shaders/es2/sun.vert new file mode 100644 index 000000000..8ba96452c --- /dev/null +++ b/examples/qt3d/planets-qml/shaders/es2/sun.vert @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** 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 vec2 vertexTexCoord; + +varying vec3 position; +varying vec2 texCoord; + +uniform mat4 modelView; +uniform mat4 mvp; + +uniform float texCoordScale; + +void main() +{ + texCoord = vertexTexCoord * texCoordScale; + position = vec3(modelView * vec4(vertexPosition, 1.0)); + gl_Position = mvp * vec4(vertexPosition, 1.0); +} diff --git a/examples/qt3d/planets-qml/shaders/gl3/sun.frag b/examples/qt3d/planets-qml/shaders/gl3/sun.frag new file mode 100644 index 000000000..bbc47118a --- /dev/null +++ b/examples/qt3d/planets-qml/shaders/gl3/sun.frag @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#version 150 core + +uniform sampler2D diffuseTexture; + +in vec3 position; +in vec2 texCoord; + +out vec4 fragColor; + +vec4 dModel(const in vec2 flipYTexCoord) +{ + // Lookup diffuse + vec3 diffuseColor = texture(diffuseTexture, flipYTexCoord).rgb; + + return vec4(diffuseColor, 1.0); +} + +void main() +{ + vec2 flipYTexCoord = texCoord; + flipYTexCoord.y = 1.0 - texCoord.y; + + vec4 result = dModel(flipYTexCoord); + + fragColor = result; +} diff --git a/examples/qt3d/planets-qml/shaders/gl3/sun.vert b/examples/qt3d/planets-qml/shaders/gl3/sun.vert new file mode 100644 index 000000000..70cd54429 --- /dev/null +++ b/examples/qt3d/planets-qml/shaders/gl3/sun.vert @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#version 150 core + +in vec3 vertexPosition; +in vec2 vertexTexCoord; + +out vec3 position; +out vec2 texCoord; + +uniform mat4 modelView; +uniform mat4 mvp; + +uniform float texCoordScale; + +void main() +{ + texCoord = vertexTexCoord * texCoordScale; + position = vec3(modelView * vec4(vertexPosition, 1.0)); + gl_Position = mvp * vec4(vertexPosition, 1.0); +} |