From 68e0e8837a7437b483d8639167a6ebad57b1dd35 Mon Sep 17 00:00:00 2001 From: Sean Harmer Date: Sun, 10 Jul 2016 15:27:01 +0100 Subject: 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 --- src/render/lights/qspotlight.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/render/lights') 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); } } -- cgit v1.2.3