mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-03 00:03:50 +00:00
Align lens flare with sky-locked sun rendering
- anchor flare sun position to camera + sun direction to match celestial billboard projection - remove world-space parallax drift that caused flare/sun misalignment while moving
This commit is contained in:
parent
8156942b66
commit
7a4a21c8bf
1 changed files with 11 additions and 2 deletions
|
|
@ -215,14 +215,23 @@ void LensFlare::render(const Camera& camera, const glm::vec3& sunPosition, float
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sun billboard rendering is sky-locked (view translation removed), so anchor
|
||||||
|
// flare projection to camera position along sun direction to avoid parallax drift.
|
||||||
|
glm::vec3 sunDir = sunPosition;
|
||||||
|
if (glm::length(sunDir) < 0.0001f) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sunDir = glm::normalize(sunDir);
|
||||||
|
glm::vec3 anchoredSunPos = camera.getPosition() + sunDir * 800.0f;
|
||||||
|
|
||||||
// Calculate sun visibility
|
// Calculate sun visibility
|
||||||
float visibility = calculateSunVisibility(camera, sunPosition);
|
float visibility = calculateSunVisibility(camera, anchoredSunPos);
|
||||||
if (visibility < 0.01f) {
|
if (visibility < 0.01f) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get sun screen position
|
// Get sun screen position
|
||||||
glm::vec2 sunScreen = worldToScreen(camera, sunPosition);
|
glm::vec2 sunScreen = worldToScreen(camera, anchoredSunPos);
|
||||||
glm::vec2 screenCenter(0.0f, 0.0f);
|
glm::vec2 screenCenter(0.0f, 0.0f);
|
||||||
|
|
||||||
// Vector from sun to screen center
|
// Vector from sun to screen center
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue