mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-30 07:49:31 -05:00
Atmosphere is now a separated node in OS. Removed ATM code from renderableglobe and renderableplanet.
This commit is contained in:
@@ -31,6 +31,8 @@
|
||||
#include <openspace/util/time.h>
|
||||
#include <openspace/util/spicemanager.h>
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/misc/assert.h>
|
||||
@@ -40,14 +42,6 @@
|
||||
#include <ghoul/opengl/textureunit.h>
|
||||
#include <ghoul/misc/invariants.h>
|
||||
|
||||
#ifdef OPENSPACE_MODULE_ATMOSPHERE_ENABLED
|
||||
#include <openspace/rendering/deferredcastermanager.h>
|
||||
#include <modules/atmosphere/rendering/atmospheredeferredcaster.h>
|
||||
#include <openspace/engine/configurationmanager.h>
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#endif
|
||||
|
||||
#include <memory>
|
||||
#include <fstream>
|
||||
|
||||
@@ -71,27 +65,6 @@ namespace {
|
||||
const char* keyShadowCaster = "Caster";
|
||||
const char* keyBody = "Body";
|
||||
|
||||
#ifdef OPENSPACE_MODULE_ATMOSPHERE_ENABLED
|
||||
const std::string keyAtmosphere = "Atmosphere";
|
||||
const std::string keyAtmosphereRadius = "AtmoshereRadius";
|
||||
const std::string keyPlanetRadius = "PlanetRadius";
|
||||
const std::string keyAverageGroundReflectance = "PlanetAverageGroundReflectance";
|
||||
const std::string keyRayleigh = "Rayleigh";
|
||||
const std::string keyRayleighHeightScale = "H_R";
|
||||
const std::string keyOzone = "Ozone";
|
||||
const std::string keyOzoneHeightScale = "H_O";
|
||||
const std::string keyMie = "Mie";
|
||||
const std::string keyMieHeightScale = "H_M";
|
||||
const std::string keyMiePhaseConstant = "G";
|
||||
const std::string keyImage = "Image";
|
||||
const std::string keyToneMappingOp = "ToneMapping";
|
||||
const std::string keyExposure = "Exposure";
|
||||
const std::string keyBackground = "Background";
|
||||
const std::string keyGamma = "Gamma";
|
||||
const std::string keyATMDebug = "Debug";
|
||||
const std::string keyTextureScale = "PreCalculatedTextureScale";
|
||||
const std::string keySaveTextures = "SaveCalculatedTextures";
|
||||
#endif
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
@@ -158,47 +131,6 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary)
|
||||
, _nightTexture(nullptr)
|
||||
, _heightMapTexture(nullptr)
|
||||
, _geometry(nullptr)
|
||||
#ifdef OPENSPACE_MODULE_ATMOSPHERE_ENABLED
|
||||
, _atmosphereHeightP("atmmosphereHeight", "Atmosphere Height (KM)", 60.0f, 0.1f, 99.0f)
|
||||
, _groundAverageReflectanceP("averageGroundReflectance", "Average Ground Reflectance (%)", 0.1f, 0.0f, 1.0f)
|
||||
, _rayleighHeightScaleP("rayleighHeightScale", "Rayleigh Height Scale (KM)", 8.0f, 0.1f, 20.0f)
|
||||
, _rayleighScatteringCoeffXP("rayleighScatteringCoeffX", "Rayleigh Scattering Coeff X (x10e-3)", 1.0f, 0.01f, 100.0f)
|
||||
, _rayleighScatteringCoeffYP("rayleighScatteringCoeffY", "Rayleigh Scattering Coeff Y (x10e-3)", 1.0f, 0.01f, 100.0f)
|
||||
, _rayleighScatteringCoeffZP("rayleighScatteringCoeffZ", "Rayleigh Scattering Coeff Z (x10e-3)", 1.0f, 0.01f, 100.0f)
|
||||
, _ozoneEnabledP("ozone", "Ozone Layer Enabled", true)
|
||||
, _ozoneHeightScaleP("ozoneLayerHeightScale", "Ozone Height Scale (KM)", 8.0f, 0.1f, 20.0f)
|
||||
, _ozoneCoeffXP("ozoneLayerCoeffX", "Ozone Layer Extinction Coeff X (x10e-5)", 3.426f, 0.01f, 100.0f)
|
||||
, _ozoneCoeffYP("ozoneLayerCoeffY", "Ozone Layer Extinction Coeff Y (x10e-5)", 8.298f, 0.01f, 100.0f)
|
||||
, _ozoneCoeffZP("ozoneLayerCoeffZ", "Ozone Layer Extinction Coeff Z (x10e-5)", 0.356f, 0.01f, 100.0f)
|
||||
, _mieHeightScaleP("mieHeightScale", "Mie Height Scale (KM)", 1.2f, 0.1f, 20.0f)
|
||||
, _mieScatteringCoefficientP("mieScatteringCoefficient", "Mie Scattering Coefficient (x10e-3)", 4.0f, 0.01f, 1000.0f)
|
||||
, _mieScatteringExtinctionPropCoefficientP("mieScatteringExtinctionPropCoefficient",
|
||||
"Mie Scattering/Extinction Proportion Coefficient (%)", 0.9f, 0.01f, 1.0f)
|
||||
, _mieAsymmetricFactorGP("mieAsymmetricFactorG", "Mie Asymmetric Factor G", 0.85f, -1.0f, 1.0f)
|
||||
, _sunIntensityP("sunIntensity", "Sun Intensity", 50.0f, 0.1f, 1000.0f)
|
||||
, _hdrExpositionP("hdrExposition", "HDR", 0.4f, 0.01f, 5.0f)
|
||||
, _backgroundExposureP("backgroundExposition", "Background Exposition", 1.8f, 0.01f, 10.0f)
|
||||
, _gammaConstantP("gamma", "Gamma Correction", 1.8f, 0.1f, 3.0f)
|
||||
, _atmosphereEnabled(false)
|
||||
, _ozoneLayerEnabled(false)
|
||||
, _atmosphereRadius(0.f)
|
||||
, _atmospherePlanetRadius(0.f)
|
||||
, _planetAverageGroundReflectance(0.f)
|
||||
, _rayleighHeightScale(0.f)
|
||||
, _ozoneHeightScale(0.f)
|
||||
, _mieHeightScale(0.f)
|
||||
, _miePhaseConstant(0.f)
|
||||
, _sunRadianceIntensity(50.f)
|
||||
, _hdrConstant(0.f)
|
||||
, _exposureBackgroundConstant(1.8f)
|
||||
, _gammaConstant(1.8f)
|
||||
, _mieExtinctionCoeff(glm::vec3(0.f))
|
||||
, _rayleighScatteringCoeff(glm::vec3(0.f))
|
||||
, _ozoneExtinctionCoeff(glm::vec3(0.f))
|
||||
, _mieScatteringCoeff(glm::vec3(0.f))
|
||||
, _saveCalculationsToTexture(false)
|
||||
, _preCalculatedTexturesScale(1.0)
|
||||
#endif
|
||||
, _alpha(1.f)
|
||||
, _planetRadius(0.f)
|
||||
, _hasNightTexture(false)
|
||||
@@ -350,222 +282,6 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef OPENSPACE_MODULE_ATMOSPHERE_ENABLED
|
||||
//================================================================
|
||||
//========== Reads Atmosphere Entries from mod file ==============
|
||||
//================================================================
|
||||
bool errorReadingAtmosphereData = false;
|
||||
ghoul::Dictionary atmosphereDictionary;
|
||||
success = dictionary.getValue(keyAtmosphere, atmosphereDictionary);
|
||||
if (success) {
|
||||
if (!atmosphereDictionary.getValue(keyAtmosphereRadius, _atmosphereRadius)) {
|
||||
errorReadingAtmosphereData = true;
|
||||
LWARNING("No Atmosphere Radius value expecified for Atmosphere Effects of "
|
||||
<< name << " planet.\nDisabling atmosphere effects for this planet.");
|
||||
}
|
||||
|
||||
if (!atmosphereDictionary.getValue(keyPlanetRadius, _atmospherePlanetRadius)) {
|
||||
errorReadingAtmosphereData = true;
|
||||
LWARNING("No Planet Radius value expecified for Atmosphere Effects of "
|
||||
<< name << " planet.\nDisabling atmosphere effects for this planet.");
|
||||
}
|
||||
|
||||
if (!atmosphereDictionary.getValue(keyAverageGroundReflectance, _planetAverageGroundReflectance)) {
|
||||
errorReadingAtmosphereData = true;
|
||||
LWARNING("No Average Atmosphere Ground Reflectance value expecified for Atmosphere Effects of "
|
||||
<< name << " planet.\nDisabling atmosphere effects for this planet.");
|
||||
}
|
||||
|
||||
ghoul::Dictionary rayleighDictionary;
|
||||
success = atmosphereDictionary.getValue(keyRayleigh, rayleighDictionary);
|
||||
|
||||
if (success) {
|
||||
// Not using right now.
|
||||
glm::vec3 rayleighWavelengths;
|
||||
success = rayleighDictionary.getValue("Coefficients.Wavelengths", rayleighWavelengths);
|
||||
|
||||
if (!rayleighDictionary.getValue("Coefficients.Scattering", _rayleighScatteringCoeff)) {
|
||||
errorReadingAtmosphereData = true;
|
||||
LWARNING("No Rayleigh Scattering parameters expecified for Atmosphere Effects of "
|
||||
<< name << " planet.\nDisabling atmosphere effects for this planet.");
|
||||
}
|
||||
|
||||
if (!rayleighDictionary.getValue(keyRayleighHeightScale, _rayleighHeightScale)) {
|
||||
errorReadingAtmosphereData = true;
|
||||
LWARNING("No Rayleigh Height Scale value expecified for Atmosphere Effects of "
|
||||
<< name << " planet.\nDisabling atmosphere effects for this planet.");
|
||||
}
|
||||
}
|
||||
else {
|
||||
errorReadingAtmosphereData = true;
|
||||
LWARNING("No Rayleigh parameters expecified for Atmosphere Effects of "
|
||||
<< name << " planet.\nDisabling atmosphere effects for this planet.");
|
||||
}
|
||||
|
||||
ghoul::Dictionary ozoneDictionary;
|
||||
success = atmosphereDictionary.getValue(keyOzone, ozoneDictionary);
|
||||
if (success) {
|
||||
_ozoneLayerEnabled = true;
|
||||
if (!ozoneDictionary.getValue(keyOzoneHeightScale, _ozoneHeightScale)) {
|
||||
_ozoneLayerEnabled = false;
|
||||
}
|
||||
|
||||
if (!ozoneDictionary.getValue("Coefficients.Extinction", _ozoneExtinctionCoeff)) {
|
||||
_ozoneLayerEnabled = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
_ozoneLayerEnabled = false;
|
||||
}
|
||||
|
||||
ghoul::Dictionary mieDictionary;
|
||||
success = atmosphereDictionary.getValue(keyMie, mieDictionary);
|
||||
if (success) {
|
||||
if (!mieDictionary.getValue(keyMieHeightScale, _mieHeightScale)) {
|
||||
errorReadingAtmosphereData = true;
|
||||
LWARNING("No Mie Height Scale value expecified for Atmosphere Effects of "
|
||||
<< name << " planet.\nDisabling atmosphere effects for this planet.");
|
||||
}
|
||||
|
||||
if (!mieDictionary.getValue("Coefficients.Scattering", _mieScatteringCoeff)) {
|
||||
errorReadingAtmosphereData = true;
|
||||
LWARNING("No Mie Scattering parameters expecified for Atmosphere Effects of "
|
||||
<< name << " planet.\nDisabling atmosphere effects for this planet.");
|
||||
}
|
||||
|
||||
if (!mieDictionary.getValue("Coefficients.Extinction", _mieExtinctionCoeff)) {
|
||||
errorReadingAtmosphereData = true;
|
||||
LWARNING("No Mie Extinction parameters expecified for Atmosphere Effects of "
|
||||
<< name << " planet.\nDisabling atmosphere effects for this planet.");
|
||||
}
|
||||
|
||||
if (!mieDictionary.getValue(keyMiePhaseConstant, _miePhaseConstant)) {
|
||||
errorReadingAtmosphereData = true;
|
||||
LWARNING("No Mie Phase Constant value expecified for Atmosphere Effects of "
|
||||
<< name << " planet.\nDisabling atmosphere effects for this planet.");
|
||||
}
|
||||
}
|
||||
else {
|
||||
errorReadingAtmosphereData = true;
|
||||
LWARNING("No Mie parameters expecified for Atmosphere Effects of "
|
||||
<< name << " planet.\nDisabling atmosphere effects for this planet.");
|
||||
}
|
||||
|
||||
ghoul::Dictionary ImageDictionary;
|
||||
success = atmosphereDictionary.getValue(keyImage, ImageDictionary);
|
||||
if (success) {
|
||||
if (ImageDictionary.getValue(keyToneMappingOp, _preCalculatedTexturesScale)) {
|
||||
LDEBUG("Atmosphere Texture Scaled to " << _preCalculatedTexturesScale);
|
||||
}
|
||||
|
||||
if (ImageDictionary.getValue(keyExposure, _hdrConstant)) {
|
||||
LDEBUG("Saving Precalculated Atmosphere Textures.");
|
||||
}
|
||||
|
||||
if (ImageDictionary.getValue(keyGamma, _gammaConstant)) {
|
||||
LDEBUG("Saving Precalculated Atmosphere Textures.");
|
||||
}
|
||||
}
|
||||
|
||||
ghoul::Dictionary debugDictionary;
|
||||
success = atmosphereDictionary.getValue(keyATMDebug, debugDictionary);
|
||||
if (success) {
|
||||
if (debugDictionary.getValue(keyTextureScale, _preCalculatedTexturesScale)) {
|
||||
LDEBUG("Atmosphere Texture Scaled to " << _preCalculatedTexturesScale);
|
||||
}
|
||||
|
||||
if (debugDictionary.getValue(keySaveTextures, _saveCalculationsToTexture)) {
|
||||
LDEBUG("Saving Precalculated Atmosphere Textures.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!errorReadingAtmosphereData) {
|
||||
_atmosphereEnabled = true;
|
||||
|
||||
//========================================================
|
||||
//============== Atmosphere Properties ===================
|
||||
//========================================================
|
||||
|
||||
_atmosphereHeightP.set(_atmosphereRadius - _atmospherePlanetRadius);
|
||||
_atmosphereHeightP.onChange(std::bind(&RenderablePlanet::updateAtmosphereParameters, this));
|
||||
addProperty(_atmosphereHeightP);
|
||||
|
||||
_groundAverageReflectanceP.set(_planetAverageGroundReflectance);
|
||||
_groundAverageReflectanceP.onChange(std::bind(&RenderablePlanet::updateAtmosphereParameters, this));
|
||||
addProperty(_groundAverageReflectanceP);
|
||||
|
||||
_rayleighHeightScaleP.set(_rayleighHeightScale);
|
||||
_rayleighHeightScaleP.onChange(std::bind(&RenderablePlanet::updateAtmosphereParameters, this));
|
||||
addProperty(_rayleighHeightScaleP);
|
||||
|
||||
_rayleighScatteringCoeffXP.set(_rayleighScatteringCoeff.x * 1000.0f);
|
||||
_rayleighScatteringCoeffXP.onChange(std::bind(&RenderablePlanet::updateAtmosphereParameters, this));
|
||||
addProperty(_rayleighScatteringCoeffXP);
|
||||
|
||||
_rayleighScatteringCoeffYP.set(_rayleighScatteringCoeff.y * 1000.0f);
|
||||
_rayleighScatteringCoeffYP.onChange(std::bind(&RenderablePlanet::updateAtmosphereParameters, this));
|
||||
addProperty(_rayleighScatteringCoeffYP);
|
||||
|
||||
_rayleighScatteringCoeffZP.set(_rayleighScatteringCoeff.z * 1000.0f);
|
||||
_rayleighScatteringCoeffZP.onChange(std::bind(&RenderablePlanet::updateAtmosphereParameters, this));
|
||||
addProperty(_rayleighScatteringCoeffZP);
|
||||
|
||||
_ozoneEnabledP.set(_ozoneLayerEnabled);
|
||||
_ozoneEnabledP.onChange(std::bind(&RenderablePlanet::updateAtmosphereParameters, this));
|
||||
addProperty(_ozoneEnabledP);
|
||||
|
||||
_ozoneHeightScaleP.set(_ozoneHeightScale);
|
||||
_ozoneHeightScaleP.onChange(std::bind(&RenderablePlanet::updateAtmosphereParameters, this));
|
||||
addProperty(_ozoneHeightScaleP);
|
||||
|
||||
_ozoneCoeffXP.set(_ozoneExtinctionCoeff.x * 100000.0f);
|
||||
_ozoneCoeffXP.onChange(std::bind(&RenderablePlanet::updateAtmosphereParameters, this));
|
||||
addProperty(_ozoneCoeffXP);
|
||||
|
||||
_ozoneCoeffYP.set(_ozoneExtinctionCoeff.y * 100000.0f);
|
||||
_ozoneCoeffYP.onChange(std::bind(&RenderablePlanet::updateAtmosphereParameters, this));
|
||||
addProperty(_ozoneCoeffYP);
|
||||
|
||||
_ozoneCoeffZP.set(_ozoneExtinctionCoeff.z * 100000.0f);
|
||||
_ozoneCoeffZP.onChange(std::bind(&RenderablePlanet::updateAtmosphereParameters, this));
|
||||
addProperty(_ozoneCoeffZP);
|
||||
|
||||
_mieHeightScaleP.set(_mieHeightScale);
|
||||
_mieHeightScaleP.onChange(std::bind(&RenderablePlanet::updateAtmosphereParameters, this));
|
||||
addProperty(_mieHeightScaleP);
|
||||
|
||||
_mieScatteringCoefficientP.set(_mieScatteringCoeff.r * 1000.0f);
|
||||
_mieScatteringCoefficientP.onChange(std::bind(&RenderablePlanet::updateAtmosphereParameters, this));
|
||||
addProperty(_mieScatteringCoefficientP);
|
||||
|
||||
_mieScatteringExtinctionPropCoefficientP.set(_mieScatteringCoeff.r / _mieExtinctionCoeff.r);
|
||||
_mieScatteringExtinctionPropCoefficientP.onChange(std::bind(&RenderablePlanet::updateAtmosphereParameters, this));
|
||||
addProperty(_mieScatteringExtinctionPropCoefficientP);
|
||||
|
||||
_mieAsymmetricFactorGP.set(_miePhaseConstant);
|
||||
_mieAsymmetricFactorGP.onChange(std::bind(&RenderablePlanet::updateAtmosphereParameters, this));
|
||||
addProperty(_mieAsymmetricFactorGP);
|
||||
|
||||
_sunIntensityP.set(_sunRadianceIntensity);
|
||||
_sunIntensityP.onChange(std::bind(&RenderablePlanet::updateAtmosphereParameters, this));
|
||||
addProperty(_sunIntensityP);
|
||||
|
||||
_hdrExpositionP.set(_hdrConstant);
|
||||
_hdrExpositionP.onChange(std::bind(&RenderablePlanet::updateAtmosphereParameters, this));
|
||||
addProperty(_hdrExpositionP);
|
||||
|
||||
_backgroundExposureP.set(_exposureBackgroundConstant);
|
||||
_backgroundExposureP.onChange(std::bind(&RenderablePlanet::updateAtmosphereParameters, this));
|
||||
addProperty(_backgroundExposureP);
|
||||
|
||||
_gammaConstantP.set(_gammaConstant);
|
||||
_gammaConstantP.onChange(std::bind(&RenderablePlanet::updateAtmosphereParameters, this));
|
||||
addProperty(_gammaConstantP);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool RenderablePlanet::initialize() {
|
||||
@@ -615,52 +331,6 @@ bool RenderablePlanet::initialize() {
|
||||
|
||||
loadTexture();
|
||||
|
||||
#ifdef OPENSPACE_MODULE_ATMOSPHERE_ENABLED
|
||||
if (_atmosphereEnabled) {
|
||||
_deferredcaster = std::make_unique<AtmosphereDeferredcaster>();
|
||||
if (_deferredcaster) {
|
||||
_deferredcaster->setAtmosphereRadius(_atmosphereRadius);
|
||||
_deferredcaster->setPlanetRadius(_atmospherePlanetRadius);
|
||||
_deferredcaster->setPlanetAverageGroundReflectance(_planetAverageGroundReflectance);
|
||||
_deferredcaster->setRayleighHeightScale(_rayleighHeightScale);
|
||||
_deferredcaster->enableOzone(_ozoneLayerEnabled);
|
||||
_deferredcaster->setOzoneHeightScale(_ozoneHeightScale);
|
||||
_deferredcaster->setMieHeightScale(_mieHeightScale);
|
||||
_deferredcaster->setMiePhaseConstant(_miePhaseConstant);
|
||||
_deferredcaster->setSunRadianceIntensity(_sunRadianceIntensity);
|
||||
_deferredcaster->setHDRConstant(_hdrConstant);
|
||||
_deferredcaster->setBackgroundConstant(_exposureBackgroundConstant);
|
||||
_deferredcaster->setGammaConstant(_gammaConstant);
|
||||
_deferredcaster->setRayleighScatteringCoefficients(_rayleighScatteringCoeff);
|
||||
_deferredcaster->setOzoneExtinctionCoefficients(_ozoneExtinctionCoeff);
|
||||
_deferredcaster->setMieScatteringCoefficients(_mieScatteringCoeff);
|
||||
_deferredcaster->setMieExtinctionCoefficients(_mieExtinctionCoeff);
|
||||
// TODO: Fix the ellipsoid nature of the renderable globe (JCC)
|
||||
//_deferredcaster->setEllipsoidRadii(_ellipsoid.radii());
|
||||
_deferredcaster->setRenderableClass(AtmosphereDeferredcaster::RenderablePlanet);
|
||||
|
||||
_deferredcaster->setPrecalculationTextureScale(_preCalculatedTexturesScale);
|
||||
if (_saveCalculationsToTexture)
|
||||
_deferredcaster->enablePrecalculationTexturesSaving();
|
||||
|
||||
_deferredcaster->initialize();
|
||||
}
|
||||
|
||||
OsEng.renderEngine().deferredcasterManager().attachDeferredcaster(*_deferredcaster.get());
|
||||
|
||||
std::function<void(bool)> onChange = [&](bool enabled) {
|
||||
if (enabled) {
|
||||
OsEng.renderEngine().deferredcasterManager().attachDeferredcaster(*_deferredcaster.get());
|
||||
}
|
||||
else {
|
||||
OsEng.renderEngine().deferredcasterManager().detachDeferredcaster(*_deferredcaster.get());
|
||||
}
|
||||
};
|
||||
|
||||
onEnabledChange(onChange);
|
||||
}
|
||||
#endif
|
||||
|
||||
return isReady();
|
||||
}
|
||||
|
||||
@@ -680,13 +350,6 @@ bool RenderablePlanet::deinitialize() {
|
||||
_texture = nullptr;
|
||||
_nightTexture = nullptr;
|
||||
|
||||
#ifdef OPENSPACE_MODULE_ATMOSPHERE_ENABLED
|
||||
if (_deferredcaster) {
|
||||
OsEng.renderEngine().deferredcasterManager().detachDeferredcaster(*_deferredcaster.get());
|
||||
_deferredcaster = nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -728,15 +391,6 @@ void RenderablePlanet::render(const RenderData& data, RendererTasks& renderTask)
|
||||
);
|
||||
_programObject->setUniform("ModelTransform", glm::mat4(modelTransform));
|
||||
|
||||
// Normal Transformation
|
||||
/*glm::mat4 translateObjTrans = glm::translate(glm::mat4(1.0), data.position.vec3());
|
||||
glm::mat4 translateCamTrans = glm::translate(glm::mat4(1.0), -data.camera.positionVec3());
|
||||
float scaleFactor = data.camera.scaling().x * powf(10.0, data.camera.scaling().y);
|
||||
glm::mat4 scaleCamTrans = glm::scale(glm::mat4(1.0), glm::vec3(scaleFactor));*/
|
||||
|
||||
// glm::mat4 ModelViewTrans = data.camera.viewMatrix() * scaleCamTrans *
|
||||
// translateCamTrans * translateObjTrans * glm::mat4(modelTransform);
|
||||
|
||||
setPscUniforms(*_programObject.get(), data.camera, data.position);
|
||||
|
||||
_programObject->setUniform("_performShading", _performShading);
|
||||
@@ -851,32 +505,15 @@ void RenderablePlanet::render(const RenderData& data, RendererTasks& renderTask)
|
||||
// disable shader
|
||||
_programObject->deactivate();
|
||||
|
||||
#ifdef OPENSPACE_MODULE_ATMOSPHERE_ENABLED
|
||||
if (_atmosphereEnabled) {
|
||||
DeferredcasterTask task{ _deferredcaster.get(), data };
|
||||
renderTask.deferredcasterTasks.push_back(task);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void RenderablePlanet::update(const UpdateData& data) {
|
||||
// set spice-orientation in accordance to timestamp
|
||||
_stateMatrix = data.modelTransform.rotation;
|
||||
//_stateMatrix = SpiceManager::ref().positionTransformMatrix(_frame, "GALACTIC", data.time);
|
||||
_time = data.time.j2000Seconds();
|
||||
|
||||
if (_programObject && _programObject->isDirty())
|
||||
_programObject->rebuildFromFile();
|
||||
|
||||
#ifdef OPENSPACE_MODULE_ATMOSPHERE_ENABLED
|
||||
if (_deferredcaster) {
|
||||
_deferredcaster->setTime(data.time.j2000Seconds());
|
||||
glm::dmat4 modelTransform;
|
||||
computeModelTransformMatrix(data.modelTransform, &modelTransform);
|
||||
_deferredcaster->setModelTransform(modelTransform);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void RenderablePlanet::loadTexture() {
|
||||
@@ -924,59 +561,4 @@ void RenderablePlanet::loadTexture() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef OPENSPACE_MODULE_ATMOSPHERE_ENABLED
|
||||
|
||||
void RenderablePlanet::updateAtmosphereParameters() {
|
||||
bool executeComputation = true;
|
||||
|
||||
if (_sunRadianceIntensity != _sunIntensityP ||
|
||||
_hdrConstant != _hdrExpositionP ||
|
||||
_exposureBackgroundConstant != _backgroundExposureP ||
|
||||
_gammaConstant != _gammaConstantP)
|
||||
executeComputation = false;
|
||||
|
||||
_atmosphereRadius = _atmospherePlanetRadius + _atmosphereHeightP;
|
||||
_planetAverageGroundReflectance = _groundAverageReflectanceP;
|
||||
_rayleighHeightScale = _rayleighHeightScaleP;
|
||||
_rayleighScatteringCoeff = glm::vec3(_rayleighScatteringCoeffXP * 0.001f, _rayleighScatteringCoeffYP * 0.001f,
|
||||
_rayleighScatteringCoeffZP * 0.001f);
|
||||
_ozoneLayerEnabled = _ozoneEnabledP.value();
|
||||
_ozoneHeightScale = _ozoneHeightScaleP.value();
|
||||
_ozoneExtinctionCoeff = glm::vec3(_ozoneCoeffXP.value() * 0.00001f,
|
||||
_ozoneCoeffYP.value() * 0.00001f,
|
||||
_ozoneCoeffZP.value() * 0.00001f);
|
||||
_mieHeightScale = _mieHeightScaleP;
|
||||
_mieScatteringCoeff = glm::vec3(_mieScatteringCoefficientP * 0.001f);
|
||||
_mieExtinctionCoeff = _mieScatteringCoeff * (1.0f / static_cast<float>(_mieScatteringExtinctionPropCoefficientP));
|
||||
_miePhaseConstant = _mieAsymmetricFactorGP;
|
||||
_sunRadianceIntensity = _sunIntensityP;
|
||||
_hdrConstant = _hdrExpositionP;
|
||||
_exposureBackgroundConstant = _backgroundExposureP;
|
||||
_gammaConstant = _gammaConstantP.value();
|
||||
|
||||
if (_deferredcaster) {
|
||||
_deferredcaster->setAtmosphereRadius(_atmosphereRadius);
|
||||
_deferredcaster->setPlanetRadius(_atmospherePlanetRadius);
|
||||
_deferredcaster->setPlanetAverageGroundReflectance(_planetAverageGroundReflectance);
|
||||
_deferredcaster->setRayleighHeightScale(_rayleighHeightScale);
|
||||
_deferredcaster->enableOzone(_ozoneLayerEnabled);
|
||||
_deferredcaster->setOzoneHeightScale(_ozoneHeightScale);
|
||||
_deferredcaster->setMieHeightScale(_mieHeightScale);
|
||||
_deferredcaster->setMiePhaseConstant(_miePhaseConstant);
|
||||
_deferredcaster->setSunRadianceIntensity(_sunRadianceIntensity);
|
||||
_deferredcaster->setHDRConstant(_hdrConstant);
|
||||
_deferredcaster->setBackgroundConstant(_exposureBackgroundConstant);
|
||||
_deferredcaster->setGammaConstant(_gammaConstant);
|
||||
_deferredcaster->setRayleighScatteringCoefficients(_rayleighScatteringCoeff);
|
||||
_deferredcaster->setOzoneExtinctionCoefficients(_ozoneExtinctionCoeff);
|
||||
_deferredcaster->setMieScatteringCoefficients(_mieScatteringCoeff);
|
||||
_deferredcaster->setMieExtinctionCoefficients(_mieExtinctionCoeff);
|
||||
_deferredcaster->setRenderableClass(AtmosphereDeferredcaster::RenderablePlanet);
|
||||
|
||||
if (executeComputation)
|
||||
_deferredcaster->preCalculateAtmosphereParam();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} // namespace openspace
|
||||
Reference in New Issue
Block a user