summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2015-01-09 10:18:23 +0100
committerSean Harmer <sean.harmer@kdab.com>2015-01-18 15:30:52 +0100
commit191838d88a3e171514d7f28ce9c56d9facb4ef5a (patch)
tree66ddddb3bb32926399f1879c99bd8e9713bc5a16 /examples
parent1cbb5868e80a09bed4ad486eba638c9bd66ce4b2 (diff)
deferred-renderer-qml shows something again
Render the lights from a UBO defined in a ShaderData Note: Applies to GL 3 only, need to implement struct support for QShaderData for older platforms to work Change-Id: I6119bf85535075655e522544612dcc7c43daec35 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/deferred-renderer-qml/FinalEffect.qml8
-rw-r--r--examples/deferred-renderer-qml/main.qml29
2 files changed, 26 insertions, 11 deletions
diff --git a/examples/deferred-renderer-qml/FinalEffect.qml b/examples/deferred-renderer-qml/FinalEffect.qml
index 90c9edc32..db780e177 100644
--- a/examples/deferred-renderer-qml/FinalEffect.qml
+++ b/examples/deferred-renderer-qml/FinalEffect.qml
@@ -81,7 +81,9 @@ Effect {
};
const int lightCount = 3;
- uniform PointLight pointLights[lightCount];
+ uniform PointLightBlock {
+ PointLight lights[lightCount];
+ } pointLights;
void main()
{
@@ -92,8 +94,8 @@ Effect {
vec4 lightColor;
for (int i = 0; i < 3; i++) {
- vec3 s = normalize(pointLights[i].position - pos);
- lightColor += pointLights[i].color * (pointLights[i].intensity * max(dot(s, norm), 0.0));
+ vec3 s = normalize(pointLights.lights[i].position - pos);
+ lightColor += pointLights.lights[i].color * (pointLights.lights[i].intensity * max(dot(s, norm), 0.0));
}
lightColor /= float(lightCount);
fragColor = col * lightColor;
diff --git a/examples/deferred-renderer-qml/main.qml b/examples/deferred-renderer-qml/main.qml
index 4cb8c9fb1..5ad94dba3 100644
--- a/examples/deferred-renderer-qml/main.qml
+++ b/examples/deferred-renderer-qml/main.qml
@@ -41,6 +41,7 @@
import Qt3D 2.0
import Qt3D.Render 2.0
+import QtQuick 2.0 as QQ2
Entity {
id : root
@@ -80,10 +81,18 @@ Entity {
},
Material {
parameters : [
- Parameter { name : "color"; value : gBuffer.color },
- Parameter { name : "position"; value : gBuffer.position },
- Parameter { name : "normal"; value : gBuffer.normal },
- Parameter { name : "winSize"; value : Qt.size(1024, 1024) }
+ Parameter { name: "color"; value : gBuffer.color },
+ Parameter { name: "position"; value : gBuffer.position },
+ Parameter { name: "normal"; value : gBuffer.normal },
+ Parameter { name: "winSize"; value : Qt.size(1024, 1024) },
+ Parameter { name: "PointLightBlock"; value: ShaderData {
+ property ShaderDataArray lights: ShaderDataArray {
+ // hard coded lights until we have a way to filter
+ // ShaderData in a scene
+ values: [sceneEntity.light, sphere1.light, sphere2.light]
+ }
+ }
+ }
]
effect : FinalEffect {}
}
@@ -94,11 +103,15 @@ Entity {
Entity {
id : sceneEntity
- components : PointLight {
- color : "red"
- intensity : 3.0
+ property PointLight light: PointLight {
+ color : "white"
+ intensity : 1.0
+ QQ2.ColorAnimation on color { from: "white"; to: "blue"; duration: 4000; loops: 2 }
+ QQ2.NumberAnimation on intensity { from: 0; to: 15.0; duration: 1000; loops: QQ2.Animation.Infinite }
}
+ components: light
+
Camera {
id: camera
projectionType: CameraLens.PerspectiveProjection
@@ -140,7 +153,7 @@ Entity {
property PointLight light : PointLight {
color : "yellow"
- intensity : 1.0
+ intensity : 2.0
}
components : [