diff options
author | Tomi Korpipää <tomi.korpipaa@theqtcompany.com> | 2015-06-29 07:30:09 +0300 |
---|---|---|
committer | Tomi Korpipää <tomi.korpipaa@theqtcompany.com> | 2015-06-29 06:29:27 +0000 |
commit | 1148887340389dad57bab066b06d2d0e9eacceae (patch) | |
tree | 5a933830ff5f915e92ea0c8092fd23f0402a0aaa /examples/qt3d/planets-qml | |
parent | 56aaa976625a2cd337ccf24b29ae563dc8292778 (diff) |
Fixed planets-qml after 5.5.0 -> 5.5 merge
Change-Id: Ib4bf6b5b90b633903037084daeb70799da23f30b
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'examples/qt3d/planets-qml')
21 files changed, 54 insertions, 864 deletions
diff --git a/examples/qt3d/planets-qml/Light.qml b/examples/qt3d/planets-qml/Light.qml index 199d3f30a..a90d11ff3 100644 --- a/examples/qt3d/planets-qml/Light.qml +++ b/examples/qt3d/planets-qml/Light.qml @@ -41,6 +41,9 @@ import Qt3D.Renderer 2.0 Entity { id: root + property alias near: lightCamera.nearPlane + property alias ratio: lightCamera.aspectRatio + property vector3d lightPosition: Qt.vector3d(0.0, 0.0, 0.0) property vector3d lightIntensity: Qt.vector3d(1.0, 1.0, 1.0) @@ -52,10 +55,9 @@ Entity { id: lightCamera objectName: "lightCameraLens" projectionType: CameraLens.PerspectiveProjection - fieldOfView: 45 - aspectRatio: 1 - nearPlane : 0.1 - farPlane : 20000000.0 + fieldOfView: 30 + nearPlane: 2500000.0 + farPlane: 10000000.0 position: root.lightPosition viewCenter: Qt.vector3d(0.0, 0.0, 0.0) upVector: Qt.vector3d(0.0, 1.0, 0.0) diff --git a/examples/qt3d/planets-qml/PlanetEffectD.qml b/examples/qt3d/planets-qml/PlanetEffectD.qml index e5fcc8ae0..59c901717 100644 --- a/examples/qt3d/planets-qml/PlanetEffectD.qml +++ b/examples/qt3d/planets-qml/PlanetEffectD.qml @@ -47,8 +47,7 @@ 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: "shadowMapTexture"; value: root.shadowTexture } + Parameter { name: "lightIntensity"; value: root.light.lightIntensity } ] techniques: [ @@ -64,19 +63,6 @@ Effect { renderPasses: [ RenderPass { - annotations: [ Annotation { name: "pass"; value: "shadowmap" } ] - - shaderProgram: ShaderProgram { - vertexShaderCode: loadSource("qrc:/shaders/gl3/shadowmap.vert") - fragmentShaderCode: loadSource("qrc:/shaders/gl3/shadowmap.frag") - } - - renderStates: [ - PolygonOffset { factor: 4; units: 4 }, - DepthTest { func: DepthTest.Less } - ] - }, - RenderPass { annotations: [ Annotation { name : "pass"; value : "forward" } ] bindings: [ diff --git a/examples/qt3d/planets-qml/PlanetEffectDB.qml b/examples/qt3d/planets-qml/PlanetEffectDB.qml index ad9d2035e..c825d4868 100644 --- a/examples/qt3d/planets-qml/PlanetEffectDB.qml +++ b/examples/qt3d/planets-qml/PlanetEffectDB.qml @@ -47,8 +47,7 @@ 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: "shadowMapTexture"; value: root.shadowTexture } + Parameter { name: "lightIntensity"; value: root.light.lightIntensity } ] techniques: [ @@ -64,19 +63,6 @@ Effect { renderPasses: [ RenderPass { - annotations: [ Annotation { name: "pass"; value: "shadowmap" } ] - - shaderProgram: ShaderProgram { - vertexShaderCode: loadSource("qrc:/shaders/gl3/shadowmap.vert") - fragmentShaderCode: loadSource("qrc:/shaders/gl3/shadowmap.frag") - } - - renderStates: [ - PolygonOffset { factor: 4; units: 4 }, - DepthTest { func: DepthTest.Less } - ] - }, - RenderPass { annotations: [ Annotation { name : "pass"; value : "forward" } ] bindings: [ diff --git a/examples/qt3d/planets-qml/PlanetEffectDSB.qml b/examples/qt3d/planets-qml/PlanetEffectDSB.qml index 78b00bd32..51de33ec4 100644 --- a/examples/qt3d/planets-qml/PlanetEffectDSB.qml +++ b/examples/qt3d/planets-qml/PlanetEffectDSB.qml @@ -47,8 +47,7 @@ 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: "shadowMapTexture"; value: root.shadowTexture } + Parameter { name: "lightIntensity"; value: root.light.lightIntensity } ] techniques: [ @@ -64,19 +63,6 @@ Effect { renderPasses: [ RenderPass { - annotations: [ Annotation { name: "pass"; value: "shadowmap" } ] - - shaderProgram: ShaderProgram { - vertexShaderCode: loadSource("qrc:/shaders/gl3/shadowmap.vert") - fragmentShaderCode: loadSource("qrc:/shaders/gl3/shadowmap.frag") - } - - renderStates: [ - PolygonOffset { factor: 4; units: 4 }, - DepthTest { func: DepthTest.Less } - ] - }, - RenderPass { annotations: [ Annotation { name : "pass"; value : "forward" } ] bindings: [ diff --git a/examples/qt3d/planets-qml/PlanetFrameGraph.qml b/examples/qt3d/planets-qml/PlanetFrameGraph.qml index 6034505d2..a7abcf45f 100644 --- a/examples/qt3d/planets-qml/PlanetFrameGraph.qml +++ b/examples/qt3d/planets-qml/PlanetFrameGraph.qml @@ -52,6 +52,7 @@ FrameGraph { TechniqueFilter { requires: [ Annotation { name: "name"; value: "Desktop" } ] + RenderPassFilter { includes: [ Annotation { name: "pass"; value: "shadowmap" } ] @@ -67,8 +68,8 @@ FrameGraph { height: mainview.height format: Texture.D24 generateMipMaps: false - magnificationFilter: Texture.Nearest - minificationFilter: Texture.Nearest + magnificationFilter: Texture.Linear + minificationFilter: Texture.Linear wrapMode { x: WrapMode.ClampToEdge y: WrapMode.ClampToEdge diff --git a/examples/qt3d/planets-qml/PlanetEffectDS.qml b/examples/qt3d/planets-qml/PlanetShadowEffectD.qml index 1d3512d86..e5fcc8ae0 100644 --- a/examples/qt3d/planets-qml/PlanetEffectDS.qml +++ b/examples/qt3d/planets-qml/PlanetShadowEffectD.qml @@ -85,12 +85,17 @@ Effect { parameterName: "ambient"; shaderVariableName: "ka"; bindingType: ParameterMapping.Uniform + }, + ParameterMapping { + parameterName: "specular"; + shaderVariableName: "ks"; + bindingType: ParameterMapping.Uniform } ] shaderProgram: ShaderProgram { vertexShaderCode: loadSource("qrc:/shaders/gl3/planetD.vert") - fragmentShaderCode: loadSource("qrc:/shaders/gl3/planetDS.frag") + fragmentShaderCode: loadSource("qrc:/shaders/gl3/planetD.frag") } // no special render state set => use the default set of states @@ -115,12 +120,17 @@ Effect { 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/planetDS.frag") + fragmentShaderCode: loadSource("qrc:/shaders/es2/planetD.frag") } // no special render state set => use the default set of states @@ -146,12 +156,17 @@ Effect { 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/planetDS.frag") + 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/ShadowMapFrameGraph.qml b/examples/qt3d/planets-qml/ShadowMapFrameGraph.qml deleted file mode 100644 index 5020d13c0..000000000 --- a/examples/qt3d/planets-qml/ShadowMapFrameGraph.qml +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -import Qt3D 2.0 -import Qt3D.Renderer 2.0 -import QtQuick 2.2 as QQ2 - -FrameGraph { - id: root - - property alias viewCamera: viewCameraSelector.camera - property alias lightCamera: lightCameraSelector.camera - readonly property Texture2D shadowTexture: depthTexture - - activeFrameGraph: Viewport { - 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" } ] - - 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 - } - comparisonFunction: Texture.CompareLessEqual - comparisonMode: Texture.CompareRefToTexture - } - } - ] - } - - ClearBuffer { - buffers: ClearBuffer.DepthBuffer - - CameraSelector { - id: lightCameraSelector - } - } - } - } - - RenderPassFilter { - includes: [ Annotation { name: "pass"; value: "forward" } ] - - ClearBuffer { - buffers: ClearBuffer.ColorDepthBuffer - - CameraSelector { - id: viewCameraSelector - } - } - } - } -} diff --git a/examples/qt3d/planets-qml/SolarSystem.qml b/examples/qt3d/planets-qml/SolarSystem.qml index 515e2d8d7..1e719bc6d 100644 --- a/examples/qt3d/planets-qml/SolarSystem.qml +++ b/examples/qt3d/planets-qml/SolarSystem.qml @@ -100,6 +100,7 @@ Entity { Light { id: light + ratio: width / height } Camera { @@ -107,8 +108,8 @@ Entity { projectionType: CameraLens.PerspectiveProjection fieldOfView: 45 aspectRatio: width / height - nearPlane : 2500000.0 - farPlane : 20000000.0 + nearPlane: 2500000.0 + farPlane: 20000000.0 position: defaultCameraPosition upVector: defaultUp viewCenter: Qt.vector3d( xLookAtOffset, yLookAtOffset, zLookAtOffset ) @@ -132,26 +133,23 @@ Entity { } PlanetEffectD { - id: shadowMapEffectD - shadowTexture: framegraph.shadowTexture + id: effectD light: light } - PlanetEffectDS { - id: shadowMapEffectDS + PlanetShadowEffectD { + id: shadowMapEffectD shadowTexture: framegraph.shadowTexture light: light } PlanetEffectDB { - id: shadowMapEffectDB - shadowTexture: framegraph.shadowTexture + id: effectDB light: light } PlanetEffectDSB { - id: shadowMapEffectDSB - shadowTexture: framegraph.shadowTexture + id: effectDSB light: light } @@ -425,6 +423,7 @@ Entity { var outerRadius = Planets.getOuterRadius(focusedPlanet) cameraNear = outerRadius camera.nearPlane = cameraNear + light.near = cameraNear // Calculate position var cameraPosition = getNewCameraPosition(focusedPlanet, outerRadius) @@ -460,7 +459,7 @@ Entity { id: starfieldEntity property Material materialStarfield: PlanetMaterial { - effect: shadowMapEffectD + effect: effectD ambientLight: ambientStrengthStarfield specularColor: Qt.rgba(0.0, 0.0, 0.0, 1.0) diffuseMap: "qrc:/images/galaxy_starfield.png" @@ -492,7 +491,7 @@ Entity { id: sunEntity property Material materialSun: PlanetMaterial { - effect: shadowMapEffectD + effect: effectD ambientLight: ambientStrengthSun specularColor: Qt.rgba(0.0, 0.0, 0.0, 1.0) diffuseMap: "qrc:/images/sunmap.jpg" @@ -534,7 +533,7 @@ Entity { id: mercuryEntity property Material materialMercury: PlanetMaterial { - effect: shadowMapEffectDB + effect: effectDB ambientLight: ambientStrengthPlanet specularColor: Qt.rgba(0.2, 0.2, 0.2, 1.0) diffuseMap: "qrc:/images/mercurymap.jpg" @@ -573,7 +572,7 @@ Entity { id: venusEntity property Material materialVenus: PlanetMaterial { - effect: shadowMapEffectDB + effect: effectDB ambientLight: ambientStrengthPlanet specularColor: Qt.rgba(0.2, 0.2, 0.2, 1.0) diffuseMap: "qrc:/images/venusmap.jpg" @@ -613,7 +612,7 @@ Entity { id: earthEntity property Material materialEarth: PlanetMaterial { - effect: shadowMapEffectDSB + effect: effectDSB ambientLight: ambientStrengthPlanet diffuseMap: "qrc:/images/earthmap1k.jpg" specularMap: "qrc:/images/earthspec1k.jpg" @@ -693,7 +692,7 @@ Entity { id: moonEntity property Material materialMoon: PlanetMaterial { - effect: shadowMapEffectDB + effect: effectDB ambientLight: ambientStrengthPlanet specularColor: Qt.rgba(0.2, 0.2, 0.2, 1.0) diffuseMap: "qrc:/images/moonmap1k.jpg" @@ -732,7 +731,7 @@ Entity { id: marsEntity property Material materialMars: PlanetMaterial { - effect: shadowMapEffectDB + effect: effectDB ambientLight: ambientStrengthPlanet specularColor: Qt.rgba(0.2, 0.2, 0.2, 1.0) diffuseMap: "qrc:/images/marsmap1k.jpg" @@ -771,7 +770,7 @@ Entity { id: jupiterEntity property Material materialJupiter: PlanetMaterial { - effect: shadowMapEffectD + effect: effectD ambientLight: ambientStrengthPlanet specularColor: Qt.rgba(0.2, 0.2, 0.2, 1.0) diffuseMap: "qrc:/images/jupitermap.jpg" @@ -967,7 +966,7 @@ Entity { id: neptuneEntity property Material materialNeptune: PlanetMaterial { - effect: shadowMapEffectD + effect: effectD ambientLight: ambientStrengthPlanet specularColor: Qt.rgba(0.2, 0.2, 0.2, 1.0) diffuseMap: "qrc:/images/neptunemap.jpg" diff --git a/examples/qt3d/planets-qml/android/AndroidManifest.xml b/examples/qt3d/planets-qml/android/AndroidManifest.xml index 0c768c546..f4e10846c 100644 --- a/examples/qt3d/planets-qml/android/AndroidManifest.xml +++ b/examples/qt3d/planets-qml/android/AndroidManifest.xml @@ -1,6 +1,6 @@ <?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"> + <application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="-- %%INSERT_APP_NAME%% --" android:icon="@drawable/icon" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"> <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"/> diff --git a/examples/qt3d/planets-qml/main.cpp b/examples/qt3d/planets-qml/main.cpp index 02c43181f..9643e0054 100644 --- a/examples/qt3d/planets-qml/main.cpp +++ b/examples/qt3d/planets-qml/main.cpp @@ -44,7 +44,9 @@ int main(int argc, char **argv) QSurfaceFormat format; if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) { +#ifdef Q_OS_OSX format.setVersion(3, 2); +#endif format.setProfile(QSurfaceFormat::CoreProfile); } format.setDepthBufferSize(24); diff --git a/examples/qt3d/planets-qml/planets-qml.qrc b/examples/qt3d/planets-qml/planets-qml.qrc index 04a67b7d7..cf9aafc29 100644 --- a/examples/qt3d/planets-qml/planets-qml.qrc +++ b/examples/qt3d/planets-qml/planets-qml.qrc @@ -12,9 +12,9 @@ <file>CloudEffectDS.qml</file> <file>PlanetEffectD.qml</file> <file>PlanetEffectDB.qml</file> - <file>PlanetEffectDS.qml</file> <file>PlanetEffectDSB.qml</file> <file>PlanetMaterial.qml</file> + <file>PlanetShadowEffectD.qml</file> <file>PlanetFrameGraph.qml</file> <file>planets.js</file> <file>meshes/starfield.obj</file> diff --git a/examples/qt3d/planets-qml/shaders/gl3/planetD.frag b/examples/qt3d/planets-qml/shaders/gl3/planetD.frag index 62d941d25..74da1f37a 100644 --- a/examples/qt3d/planets-qml/shaders/gl3/planetD.frag +++ b/examples/qt3d/planets-qml/shaders/gl3/planetD.frag @@ -93,9 +93,7 @@ void main() float shadowMapSample = textureProj(shadowMapTexture, positionInLightSpace); - vec3 ambient = lightIntensity * ka * texture(diffuseTexture, flipYTexCoord).rgb; - - vec3 result = ambient; + vec3 result = lightIntensity * ka * texture(diffuseTexture, flipYTexCoord).rgb; if (shadowMapSample > 0) result = dModel(flipYTexCoord); diff --git a/examples/qt3d/planets-qml/shaders/gl3/planetDS.frag b/examples/qt3d/planets-qml/shaders/gl3/planetDS.frag index 2a1b78bfa..03922362f 100644 --- a/examples/qt3d/planets-qml/shaders/gl3/planetDS.frag +++ b/examples/qt3d/planets-qml/shaders/gl3/planetDS.frag @@ -94,9 +94,7 @@ void main() float shadowMapSample = textureProj(shadowMapTexture, positionInLightSpace); - vec3 ambient = lightIntensity * ka * texture(diffuseTexture, flipYTexCoord).rgb; - - vec3 result = ambient; + vec3 result = lightIntensity * ka * texture(diffuseTexture, flipYTexCoord).rgb; if (shadowMapSample > 0) result = dsModel(flipYTexCoord); diff --git a/examples/qt3d/planets-qml/shaders/planetD.frag b/examples/qt3d/planets-qml/shaders/planetD.frag deleted file mode 100644 index 62d941d25..000000000 --- a/examples/qt3d/planets-qml/shaders/planetD.frag +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** 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 mat4 viewMatrix; - -uniform vec3 lightPosition; -uniform vec3 lightIntensity; - -uniform vec3 ka; // Ambient reflectivity -uniform vec3 ks; // Specular reflectivity -uniform float shininess; // Specular shininess factor -uniform float opacity; // Alpha channel - -uniform sampler2D diffuseTexture; - -uniform sampler2DShadow shadowMapTexture; - -in vec4 positionInLightSpace; - -in vec3 position; -in vec3 normal; -in vec2 texCoord; - -out vec4 fragColor; - -vec3 dModel(const in vec2 flipYTexCoord) -{ - // Calculate the vector from the light to the fragment - 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) - vec3 v = normalize(-position); - - // Reflect the light beam using the normal at this fragment - vec3 r = reflect(-s, normal); - - // Calculate the diffuse component - float diffuse = max(dot(s, normal), 0.0); - - // Calculate the specular component - 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 - vec3 diffuseColor = texture(diffuseTexture, flipYTexCoord).rgb; - - // Combine the ambient, diffuse and specular contributions - return lightIntensity * ((ka + diffuse) * diffuseColor + specular * ks); -} - -void main() -{ - vec2 flipYTexCoord = texCoord; - flipYTexCoord.y = 1.0 - texCoord.y; - - float shadowMapSample = textureProj(shadowMapTexture, positionInLightSpace); - - vec3 ambient = lightIntensity * ka * texture(diffuseTexture, flipYTexCoord).rgb; - - vec3 result = ambient; - if (shadowMapSample > 0) - result = dModel(flipYTexCoord); - - float alpha = opacity * texture(diffuseTexture, flipYTexCoord).a; - - fragColor = vec4(result, alpha); -} diff --git a/examples/qt3d/planets-qml/shaders/planetD.vert b/examples/qt3d/planets-qml/shaders/planetD.vert deleted file mode 100644 index 41a1db6e4..000000000 --- a/examples/qt3d/planets-qml/shaders/planetD.vert +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** 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 vec3 vertexNormal; -in vec2 vertexTexCoord; - -out vec4 positionInLightSpace; -out vec3 position; -out vec3 normal; -out 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/planetDB.frag b/examples/qt3d/planets-qml/shaders/planetDB.frag deleted file mode 100644 index bf53a127b..000000000 --- a/examples/qt3d/planets-qml/shaders/planetDB.frag +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** 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 mat4 viewMatrix; - -uniform vec3 lightPosition; -uniform vec3 lightIntensity; - -uniform vec3 ka; // Ambient reflectivity -uniform vec3 ks; // Specular reflectivity -uniform float shininess; // Specular shininess factor -uniform float opacity; // Alpha channel - -uniform sampler2D diffuseTexture; -uniform sampler2D normalTexture; - -uniform sampler2DShadow shadowMapTexture; - -in vec4 positionInLightSpace; - -in vec3 lightDir; -in vec3 viewDir; -in vec2 texCoord; - -out vec4 fragColor; - -void dbModel(const in vec3 norm, const in vec2 flipYTexCoord, out vec3 ambientAndDiff, out vec3 spec) -{ - // Reflection of light direction about normal - vec3 r = reflect(-lightDir, norm); - - vec3 diffuseColor = texture(diffuseTexture, flipYTexCoord).rgb; - - // Calculate the ambient contribution - vec3 ambient = lightIntensity * ka * diffuseColor; - - // Calculate the diffuse contribution - float sDotN = max(dot(lightDir, norm), 0.0); - vec3 diffuse = lightIntensity * diffuseColor * sDotN; - - // Sum the ambient and diffuse contributions - ambientAndDiff = ambient + diffuse; - - // Calculate the specular highlight contribution - spec = vec3(0.0); - if (sDotN > 0.0) - spec = (lightIntensity * ks) * pow(max(dot(r, viewDir), 0.0), shininess); -} - -void main() -{ - vec2 flipYTexCoord = texCoord; - flipYTexCoord.y = 1.0 - texCoord.y; - - float shadowMapSample = textureProj(shadowMapTexture, positionInLightSpace); - - // Sample the textures at the interpolated texCoords - vec4 normal = 2.0 * texture(normalTexture, flipYTexCoord) - vec4(1.0); - - vec3 result = lightIntensity * ka * texture(diffuseTexture, flipYTexCoord).rgb; - - // Calculate the lighting model, keeping the specular component separate - vec3 ambientAndDiff, spec; - if (shadowMapSample > 0) { - dbModel(normalize(normal.xyz), flipYTexCoord, ambientAndDiff, spec); - result = ambientAndDiff + spec; - } - - // Combine spec with ambient+diffuse for final fragment color - fragColor = vec4(result, opacity); -} diff --git a/examples/qt3d/planets-qml/shaders/planetDB.vert b/examples/qt3d/planets-qml/shaders/planetDB.vert deleted file mode 100644 index e30394aa3..000000000 --- a/examples/qt3d/planets-qml/shaders/planetDB.vert +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** 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 vec3 vertexNormal; -in vec2 vertexTexCoord; -in vec4 vertexTangent; - -out vec4 positionInLightSpace; -out vec3 lightDir; -out vec3 viewDir; -out 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/planetDS.frag b/examples/qt3d/planets-qml/shaders/planetDS.frag deleted file mode 100644 index 2a1b78bfa..000000000 --- a/examples/qt3d/planets-qml/shaders/planetDS.frag +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** -** -** 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 mat4 viewMatrix; - -uniform vec3 lightPosition; -uniform vec3 lightIntensity; - -uniform vec3 ka; // Ambient reflectivity -uniform float shininess; // Specular shininess factor -uniform float opacity; // Alpha channel - -uniform sampler2D diffuseTexture; -uniform sampler2D specularTexture; - -uniform sampler2DShadow shadowMapTexture; - -in vec4 positionInLightSpace; - -in vec3 position; -in vec3 normal; -in vec2 texCoord; - -out vec4 fragColor; - -vec3 dsModel(const in vec2 flipYTexCoord) -{ - // Calculate the vector from the light to the fragment - 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) - vec3 v = normalize(-position); - - // Reflect the light beam using the normal at this fragment - vec3 r = reflect(-s, normal); - - // Calculate the diffuse component - float diffuse = max(dot(s, normal), 0.0); - - // Calculate the specular component - 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 - vec3 diffuseColor = texture(diffuseTexture, flipYTexCoord).rgb; - vec3 specularColor = texture(specularTexture, flipYTexCoord).rgb; - - // Combine the ambient, diffuse and specular contributions - return lightIntensity * ((ka + diffuse) * diffuseColor + specular * specularColor); -} - -void main() -{ - vec2 flipYTexCoord = texCoord; - flipYTexCoord.y = 1.0 - texCoord.y; - - float shadowMapSample = textureProj(shadowMapTexture, positionInLightSpace); - - vec3 ambient = lightIntensity * ka * texture(diffuseTexture, flipYTexCoord).rgb; - - vec3 result = ambient; - if (shadowMapSample > 0) - result = dsModel(flipYTexCoord); - - fragColor = vec4(result, opacity * texture(diffuseTexture, flipYTexCoord).a); -} diff --git a/examples/qt3d/planets-qml/shaders/planetDSB.frag b/examples/qt3d/planets-qml/shaders/planetDSB.frag deleted file mode 100644 index deb9565d4..000000000 --- a/examples/qt3d/planets-qml/shaders/planetDSB.frag +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************** -** -** 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 mat4 viewMatrix; - -uniform vec3 lightPosition; -uniform vec3 lightIntensity; - -uniform vec3 ka; // Ambient reflectivity -uniform float shininess; // Specular shininess factor -uniform float opacity; // Alpha channel - -uniform sampler2D diffuseTexture; -uniform sampler2D specularTexture; -uniform sampler2D normalTexture; - -uniform sampler2DShadow shadowMapTexture; - -in vec4 positionInLightSpace; - -in vec3 lightDir; -in vec3 viewDir; -in vec2 texCoord; - -out vec4 fragColor; - -void dsbModel(const in vec3 norm, const in vec2 flipYTexCoord, out vec3 ambientAndDiff, out vec3 spec) -{ - // Reflection of light direction about normal - vec3 r = reflect(-lightDir, norm); - - vec3 diffuseColor = texture(diffuseTexture, flipYTexCoord).rgb; - vec3 specularColor = texture(specularTexture, flipYTexCoord).rgb; - - // Calculate the ambient contribution - vec3 ambient = lightIntensity * ka * diffuseColor; - - // Calculate the diffuse contribution - float sDotN = max(dot(lightDir, norm), 0.0); - vec3 diffuse = lightIntensity * diffuseColor * sDotN; - - // Sum the ambient and diffuse contributions - ambientAndDiff = ambient + diffuse; - - // Calculate the specular highlight contribution - spec = vec3(0.0); - if (sDotN > 0.0) - spec = (lightIntensity * (shininess / (8.0 * 3.14))) * pow(max(dot(r, viewDir), 0.0), shininess); - - spec *= specularColor; -} - -void main() -{ - vec2 flipYTexCoord = texCoord; - flipYTexCoord.y = 1.0 - texCoord.y; - - float shadowMapSample = textureProj(shadowMapTexture, positionInLightSpace); - - // Sample the textures at the interpolated texCoords - vec4 normal = 2.0 * texture(normalTexture, flipYTexCoord) - vec4(1.0); - - vec3 result = lightIntensity * ka * texture(diffuseTexture, flipYTexCoord).rgb; - - // Calculate the lighting model, keeping the specular component separate - vec3 ambientAndDiff, spec; - if (shadowMapSample > 0) { - dsbModel(normalize(normal.xyz), flipYTexCoord, ambientAndDiff, spec); - result = ambientAndDiff + spec; - } - - // Combine spec with ambient+diffuse for final fragment color - fragColor = vec4(result, opacity); -} diff --git a/examples/qt3d/planets-qml/shaders/shadowmap.frag b/examples/qt3d/planets-qml/shaders/shadowmap.frag deleted file mode 100644 index 63f203da6..000000000 --- a/examples/qt3d/planets-qml/shaders/shadowmap.frag +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** 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 - -void main() -{ -} diff --git a/examples/qt3d/planets-qml/shaders/shadowmap.vert b/examples/qt3d/planets-qml/shaders/shadowmap.vert deleted file mode 100644 index ca93360c6..000000000 --- a/examples/qt3d/planets-qml/shaders/shadowmap.vert +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). -** 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; - -uniform mat4 mvp; - -void main() -{ - gl_Position = mvp * vec4(vertexPosition, 1.0); -} |