diff options
-rw-r--r-- | examples/deferred-renderer-qml/FinalEffect.qml | 8 | ||||
-rw-r--r-- | examples/deferred-renderer-qml/main.qml | 29 |
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 : [ |