From 54f789f2264e7756d85af749b1fea68541ec88b4 Mon Sep 17 00:00:00 2001 From: Turanszki Janos Date: Thu, 24 Jun 2021 23:55:30 +0200 Subject: [PATCH] lens flare fix --- WickedEngine/wiRenderer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/WickedEngine/wiRenderer.cpp b/WickedEngine/wiRenderer.cpp index 4954d4dc3..cc016edba 100644 --- a/WickedEngine/wiRenderer.cpp +++ b/WickedEngine/wiRenderer.cpp @@ -4613,10 +4613,10 @@ void DrawLensFlares( if (light.GetType() == LightComponent::DIRECTIONAL) { // directional light flare will be placed at infinite position along direction vector: - XMVECTOR D = XMVector3Normalize(-XMVector3Transform(XMVectorSet(0, -vis.camera->zFarP, 0, 0), XMMatrixRotationQuaternion(XMLoadFloat4(&light.rotation)))); - if (XMVectorGetX(XMVector3Dot(D, XMVectorSet(0, 1, 0, 0))) < 0) + XMVECTOR D = XMVector3Normalize(-XMVector3Transform(XMVectorSet(0, 1, 0, 1), XMMatrixRotationQuaternion(XMLoadFloat4(&light.rotation)))); + if (XMVectorGetX(XMVector3Dot(D, XMVectorSet(0, -1, 0, 0))) < 0) continue; // sun below horizon, skip lensflare - POS = vis.camera->GetEye() + D; + POS = vis.camera->GetEye() + D * -vis.camera->zFarP; } else {