summaryrefslogtreecommitdiffstats
path: root/src/render/lights
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2016-07-10 15:27:01 +0100
committerSean Harmer <sean.harmer@kdab.com>2016-07-12 19:15:46 +0000
commit68e0e8837a7437b483d8639167a6ebad57b1dd35 (patch)
treed89fd9faee629f1db2ac2069eeec8372f6e50394 /src/render/lights
parent2390fbeac2cb38d68b08a8fda1141cf713b32e4b (diff)
Save per-fragment normalization by doing it CPU side once when set
The spot light local direction was being normalized in the fragment shader which is a lot of work. Much better to normalize it once on the CPU side when it is updated. Change-Id: I87045462b6b09fad4262f5755493b87595d29f11 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/render/lights')
-rw-r--r--src/render/lights/qspotlight.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/render/lights/qspotlight.cpp b/src/render/lights/qspotlight.cpp
index 54ed8da63..81c18387b 100644
--- a/src/render/lights/qspotlight.cpp
+++ b/src/render/lights/qspotlight.cpp
@@ -221,8 +221,9 @@ void QSpotLight::setLocalDirection(const QVector3D &direction)
{
Q_D(QSpotLight);
if (localDirection() != direction) {
- d->m_shaderData->setProperty("direction", direction);
- emit localDirectionChanged(direction);
+ const QVector3D dir = direction.normalized();
+ d->m_shaderData->setProperty("direction", dir);
+ emit localDirectionChanged(dir);
}
}