diff --git a/src/render/software/AtmosphereRenderer.cpp b/src/render/software/AtmosphereRenderer.cpp index 7ce14ad..49e8d5f 100644 --- a/src/render/software/AtmosphereRenderer.cpp +++ b/src/render/software/AtmosphereRenderer.cpp @@ -171,7 +171,8 @@ SoftwareBrunetonAtmosphereRenderer::~SoftwareBrunetonAtmosphereRenderer() void SoftwareBrunetonAtmosphereRenderer::getLightingStatus(LightStatus* status, Vector3 normal, int opaque) { - return model->fillLightingStatus(status, normal, opaque); + model->fillLightingStatus(status, normal, opaque); + parent->getNightSky()->fillLightingStatus(status, normal, opaque); } AtmosphereResult SoftwareBrunetonAtmosphereRenderer::applyAerialPerspective(Vector3 location, Color base) diff --git a/src/render/software/NightSky.cpp b/src/render/software/NightSky.cpp index 1ba1a7b..4a8e2b2 100644 --- a/src/render/software/NightSky.cpp +++ b/src/render/software/NightSky.cpp @@ -7,6 +7,8 @@ #include "Scenery.h" #include "AtmosphereDefinition.h" #include "SurfaceMaterial.h" +#include "LightComponent.h" +#include "LightStatus.h" #define WORLD_SCALING 0.05 #define MOON_DISTANCE 384403.0 @@ -86,3 +88,18 @@ const Color NightSky::getColor(double altitude, const Vector3 &direction) return result; } + +void NightSky::fillLightingStatus(LightStatus *status, const Vector3 &, int) +{ + LightComponent moon; + + AtmosphereDefinition* atmosphere = renderer->getScenery()->getAtmosphere(); + VectorSpherical moon_location_s = {MOON_DISTANCE_SCALED, atmosphere->moon_theta, -atmosphere->moon_phi}; + + moon.color = Color(0.03, 0.03, 0.03); // TODO take moon phase into account + moon.direction = Vector3(moon_location_s).normalize().scale(-1.0); + moon.reflection = 0.2; + moon.altered = 1; + + status->pushComponent(moon); +} diff --git a/src/render/software/NightSky.h b/src/render/software/NightSky.h index 428f033..c1bc3c5 100644 --- a/src/render/software/NightSky.h +++ b/src/render/software/NightSky.h @@ -26,6 +26,8 @@ public: */ virtual const Color getColor(double altitude, const Vector3 &direction); + virtual void fillLightingStatus(LightStatus *status, const Vector3 &normal, int opaque); + private: SoftwareRenderer* renderer; };