summaryrefslogtreecommitdiffstats
path: root/tests/manual/planets-qml/shaders/es2
diff options
context:
space:
mode:
Diffstat (limited to 'tests/manual/planets-qml/shaders/es2')
-rw-r--r--tests/manual/planets-qml/shaders/es2/planetD.frag60
-rw-r--r--tests/manual/planets-qml/shaders/es2/planetD.vert36
-rw-r--r--tests/manual/planets-qml/shaders/es2/planetDB.frag56
-rw-r--r--tests/manual/planets-qml/shaders/es2/planetDB.vert61
-rw-r--r--tests/manual/planets-qml/shaders/es2/planetDS.frag61
-rw-r--r--tests/manual/planets-qml/shaders/es2/planetDSB.frag61
-rw-r--r--tests/manual/planets-qml/shaders/es2/sun.frag26
-rw-r--r--tests/manual/planets-qml/shaders/es2/sun.vert21
8 files changed, 382 insertions, 0 deletions
diff --git a/tests/manual/planets-qml/shaders/es2/planetD.frag b/tests/manual/planets-qml/shaders/es2/planetD.frag
new file mode 100644
index 000000000..f34a2a23e
--- /dev/null
+++ b/tests/manual/planets-qml/shaders/es2/planetD.frag
@@ -0,0 +1,60 @@
+// Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+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/tests/manual/planets-qml/shaders/es2/planetD.vert b/tests/manual/planets-qml/shaders/es2/planetD.vert
new file mode 100644
index 000000000..a5da1441e
--- /dev/null
+++ b/tests/manual/planets-qml/shaders/es2/planetD.vert
@@ -0,0 +1,36 @@
+// Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+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/tests/manual/planets-qml/shaders/es2/planetDB.frag b/tests/manual/planets-qml/shaders/es2/planetDB.frag
new file mode 100644
index 000000000..376e38939
--- /dev/null
+++ b/tests/manual/planets-qml/shaders/es2/planetDB.frag
@@ -0,0 +1,56 @@
+// Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+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/tests/manual/planets-qml/shaders/es2/planetDB.vert b/tests/manual/planets-qml/shaders/es2/planetDB.vert
new file mode 100644
index 000000000..0a7c08604
--- /dev/null
+++ b/tests/manual/planets-qml/shaders/es2/planetDB.vert
@@ -0,0 +1,61 @@
+// Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+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/tests/manual/planets-qml/shaders/es2/planetDS.frag b/tests/manual/planets-qml/shaders/es2/planetDS.frag
new file mode 100644
index 000000000..d4ee704bf
--- /dev/null
+++ b/tests/manual/planets-qml/shaders/es2/planetDS.frag
@@ -0,0 +1,61 @@
+// Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+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/tests/manual/planets-qml/shaders/es2/planetDSB.frag b/tests/manual/planets-qml/shaders/es2/planetDSB.frag
new file mode 100644
index 000000000..95e60e9ee
--- /dev/null
+++ b/tests/manual/planets-qml/shaders/es2/planetDSB.frag
@@ -0,0 +1,61 @@
+// Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+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/tests/manual/planets-qml/shaders/es2/sun.frag b/tests/manual/planets-qml/shaders/es2/sun.frag
new file mode 100644
index 000000000..f9697c8e5
--- /dev/null
+++ b/tests/manual/planets-qml/shaders/es2/sun.frag
@@ -0,0 +1,26 @@
+// Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+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/tests/manual/planets-qml/shaders/es2/sun.vert b/tests/manual/planets-qml/shaders/es2/sun.vert
new file mode 100644
index 000000000..f15074d1f
--- /dev/null
+++ b/tests/manual/planets-qml/shaders/es2/sun.vert
@@ -0,0 +1,21 @@
+// Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+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);
+}