mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 03:17:02 +02:00
make stars fade in as sun drops below horizon
This commit is contained in:
parent
73428ec12d
commit
a2a1bf4e8c
1 changed files with 23 additions and 1 deletions
|
@ -3220,18 +3220,40 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs
|
||||||
// compute starfield alpha based on distance from atmosphere
|
// compute starfield alpha based on distance from atmosphere
|
||||||
float alpha = 1.0f;
|
float alpha = 1.0f;
|
||||||
bool hasStars = true;
|
bool hasStars = true;
|
||||||
|
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) {
|
if (Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) {
|
||||||
// TODO: handle this correctly for zones
|
// TODO: handle this correctly for zones
|
||||||
const EnvironmentData& closestData = _environment.getClosestData(theCamera.getPosition());
|
const EnvironmentData& closestData = _environment.getClosestData(theCamera.getPosition());
|
||||||
|
|
||||||
if (closestData.getHasStars()) {
|
if (closestData.getHasStars()) {
|
||||||
|
const float APPROXIMATE_DISTANCE_FROM_HORIZON = 0.1f;
|
||||||
|
const float DOUBLE_APPROXIMATE_DISTANCE_FROM_HORIZON = 0.2f;
|
||||||
|
|
||||||
|
glm::vec3 sunDirection = (getAvatarPosition() - closestData.getSunLocation())
|
||||||
|
/ closestData.getAtmosphereOuterRadius();
|
||||||
float height = glm::distance(theCamera.getPosition(), closestData.getAtmosphereCenter());
|
float height = glm::distance(theCamera.getPosition(), closestData.getAtmosphereCenter());
|
||||||
if (height < closestData.getAtmosphereInnerRadius()) {
|
if (height < closestData.getAtmosphereInnerRadius()) {
|
||||||
|
// If we're inside the atmosphere, then determine if our keyLight is below the horizon
|
||||||
alpha = 0.0f;
|
alpha = 0.0f;
|
||||||
|
|
||||||
|
if (sunDirection.y > -APPROXIMATE_DISTANCE_FROM_HORIZON) {
|
||||||
|
float directionY = glm::clamp(sunDirection.y,
|
||||||
|
-APPROXIMATE_DISTANCE_FROM_HORIZON, APPROXIMATE_DISTANCE_FROM_HORIZON)
|
||||||
|
+ APPROXIMATE_DISTANCE_FROM_HORIZON;
|
||||||
|
alpha = (directionY / DOUBLE_APPROXIMATE_DISTANCE_FROM_HORIZON);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} else if (height < closestData.getAtmosphereOuterRadius()) {
|
} else if (height < closestData.getAtmosphereOuterRadius()) {
|
||||||
alpha = (height - closestData.getAtmosphereInnerRadius()) /
|
alpha = (height - closestData.getAtmosphereInnerRadius()) /
|
||||||
(closestData.getAtmosphereOuterRadius() - closestData.getAtmosphereInnerRadius());
|
(closestData.getAtmosphereOuterRadius() - closestData.getAtmosphereInnerRadius());
|
||||||
|
|
||||||
|
if (sunDirection.y > -APPROXIMATE_DISTANCE_FROM_HORIZON) {
|
||||||
|
float directionY = glm::clamp(sunDirection.y,
|
||||||
|
-APPROXIMATE_DISTANCE_FROM_HORIZON, APPROXIMATE_DISTANCE_FROM_HORIZON)
|
||||||
|
+ APPROXIMATE_DISTANCE_FROM_HORIZON;
|
||||||
|
alpha = (directionY / DOUBLE_APPROXIMATE_DISTANCE_FROM_HORIZON);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
hasStars = false;
|
hasStars = false;
|
||||||
|
|
Loading…
Reference in a new issue