Commit baebca68 authored by Dario Seyb's avatar Dario Seyb

added more settings

parent f5a10db1
......@@ -8,5 +8,6 @@
"mars",
"jupiter"
],
"scene": "AtmosphereTest"
"scene": "AtmosphereTest",
"default_planet_type": "earth"
}
\ No newline at end of file
#version 410 core
#pragma import "../../setup/geometry.glsl"
#pragma import "../../noise/noise3d.glsl"
#pragma import "../../noise/noise4d.glsl"
#pragma import "../../Utils.glsl"
#pragma import "../../CommonDeferredFrag.glsl"
#pragma import "mars_texture.glsl"
#pragma import "../../terrain/generic_water_texture.glsl"
#pragma import "../../terrain/dispMappingWithWater_fsh.glsl"
float getContinentHeightNoise(vec3 normalizedPosInModelspace) {
return 2*(fbm_3d(normalizedPosInModelspace , 2, 1.25));
return smoothstep(sin(4*(fbm_3d(normalizedPosInModelspace , 1, 1.25))), -1, 0);
}
float getRidgedHeightNoise(vec3 normalizedPosInModelspace) {
return (.75 - abs(fbm_3d( normalizedPosInModelspace , 2, 40.)))/2.;
}
float getDetailHeightNoise(vec3 normalizedPosInModelspace) {
return fbm_3d( normalizedPosInModelspace , 2, 160.)/8.;
return pow(fbm_3d( normalizedPosInModelspace , 3, 50.)/1.4, 2) * 3;
}
float getRidgedDetailsHeightNoise(vec3 normalizedPosInModelspace) {
return (.75 - abs(fbm_3d( normalizedPosInModelspace , 4, 8*640.)))/256.;
return (.75 - abs(fbm_3d( normalizedPosInModelspace , 4, 8*640.)));
}
float getHeightNoise(vec3 normalizedPosInModelspace) {
return (getContinentHeightNoise(normalizedPosInModelspace)
+ getRidgedHeightNoise(normalizedPosInModelspace)
+ getDetailHeightNoise(normalizedPosInModelspace)
+ getRidgedDetailsHeightNoise(normalizedPosInModelspace))
return (0.2 + getRidgedHeightNoise(normalizedPosInModelspace) * 0.1 + getContinentHeightNoise(normalizedPosInModelspace)
+ getDetailHeightNoise(normalizedPosInModelspace))
* 2.;
}
......@@ -52,13 +50,13 @@ vec4 texture_getColor(vec3 texCoord3d, vec3 upVectorNormalized, vec3 normalNorma
if (height> SNOW_LEVEL && phiPert <= ROCK_SLOPE) {
color = vec4(1., 1., 1., 1.);
color = vec4(1., 0., 0., 1.);
} else if (height> ROCK_LEVEL || phiPert > ROCK_SLOPE) {
color = vec4(.1, .1, .1, 1.);
} else if (height> PLANT_LEVEL) {
color = vec4(.2, .5,.15, 1.);
color = vec4(.9, .3,.15, 1.);
}else { //"sand""
color = vec4(1., .8, .55, 1.);
}
......
......@@ -35,6 +35,7 @@ private:
bool m_fullscreen;
uint64_t m_targetFps;
std::string m_defaultScene;
std::string m_defaultPlanetType;
public:
CONSTRUCT_SYSTEM(SettingsSystem, std::string resourcePath,
......@@ -57,7 +58,17 @@ public:
inline uint64_t getTargetFps() const { return m_targetFps; }
inline QualitySetting getQualitySetting() const { return m_qualitySetting; }
inline std::string getDefaultScene() const { return m_defaultScene; }
inline std::string getDefaultPlanetType() const { return m_defaultPlanetType; }
inline std::vector<PlanetMetaData> getAvailablePlanets() const { return m_availablePlanets; }
inline PlanetMetaData getPlanet(std::string name) const {
for (auto& planet : m_availablePlanets) {
if (planet.name == name) {
return planet;
}
}
return{};
}
bool startup() override;
void shutdown() override;
......
......@@ -49,7 +49,7 @@ public:
Geometry playerIconGeometry;
std::map<Entity::Id, Entity> minimapItems;
Entity addPlanet(Transform::Handle sun, std::string n, double m, double r, double e, double a, double i, double N, double P, double T, bool isEarthlike, bool hasWater, bool hasMoon, bool hasAtmosphere = false);
Entity addPlanet(Transform::Handle sun, std::string n, double m, double r, double e, double a, double i, double N, double P, double T, std::string planetType = "earth");
bool startup() override;
void shutdown() override;
......
#pragma once
#include <engine/core/Context.hpp>
#include <engine/core/System.hpp>
#include <engine/core/SettingsSystem.hpp>
#include <engine/events/EventSystem.hpp>
#include <engine/audio/AudioSystem.hpp>
#include <engine/graphics/RendererSystem.hpp>
......@@ -15,6 +16,7 @@ private:
std::string m_name;
protected:
SettingsSystem* m_settings;
EventSystem* m_events;
RendererSystem* m_renderer;
SceneGraphSystem* m_sceneGraph;
......@@ -29,6 +31,7 @@ public:
std::string getName() { return m_name; }
bool startup() override {
RESOLVE_DEPENDENCY(m_settings);
RESOLVE_DEPENDENCY(m_events);
RESOLVE_DEPENDENCY(m_renderer);
RESOLVE_DEPENDENCY(m_sceneGraph);
......
......@@ -46,6 +46,7 @@ bool SettingsSystem::startup() {
m_fullscreen = false;
m_targetFps = 60;
m_defaultScene = "AtmosphereTest";
m_defaultPlanetType = "earth";
#define VALIDATE_TYPE(p, type) if(!p.second.is<type>()) { std::cout << "Warning: Setting \"" << i.first << "\": " << i.second << " is not of expected type " #type "." << std::endl; continue; }
......@@ -82,7 +83,7 @@ bool SettingsSystem::startup() {
if (prop.first == "shaders") {
VALIDATE_TYPE(prop, std::string);
planet.shaders = prop.second.get<std::string>();
} else if (prop.first == "atmopshere") {
} else if (prop.first == "atmosphere") {
VALIDATE_TYPE(prop, bool);
planet.hasAtmosphere = prop.second.get<bool>();
} else if (prop.first == "water") {
......@@ -118,6 +119,9 @@ bool SettingsSystem::startup() {
} else if (i.first == "scene") {
VALIDATE_TYPE(i, std::string);
m_defaultScene = i.second.get<std::string>();
} else if (i.first == "default_planet_type") {
VALIDATE_TYPE(i, std::string);
m_defaultPlanetType = i.second.get<std::string>();
} else {
std::cout << "Warning: Unknown setting \"" << i.first << "\"." << std::endl;
}
......
......@@ -570,7 +570,7 @@ void precomputeAtmosphereLookupTextures(double molecularNumberDensity,
}
// Mass is in solar masses!
Entity OrbitalSimulationSystem::addPlanet(Transform::Handle sun, std::string n, double m, double r, double e, double a, double i, double N, double P, double T, bool isEarthlike, bool hasWater, bool hasMoon, bool hasAtmosphere) {
Entity OrbitalSimulationSystem::addPlanet(Transform::Handle sun, std::string n, double m, double r, double e, double a, double i, double N, double P, double T, std::string planetType) {
// Mass, Radius, Eccentricity, Semimajor axis, Inclination, Ascending Node, Arg. of Periapsis, time at perihelion
auto planetEntity = m_scene->create();
......@@ -590,12 +590,9 @@ Entity OrbitalSimulationSystem::addPlanet(Transform::Handle sun, std::string n,
planetTransform->scale = glm::dvec3(solarToWorld(r), solarToWorld(r), solarToWorld(r));
planetTransform->position = pos;
if (isEarthlike) {
planetEntity.assign<Drawable>(defaultGeom, planetMaterials["earth"], 2, m_renderer->getRenderPassId("Main"_sh));
} else {
planetEntity.assign<Drawable>(defaultGeom, planetMaterials["jupiter"], 2, m_renderer->getRenderPassId("Main"_sh));
}
auto& planet = m_settings->getPlanet(planetType);
planetEntity.assign<Drawable>(defaultGeom, planetMaterials[planetType], 2, m_renderer->getRenderPassId("Main"_sh));
// Add an atmosphere to the planet
......@@ -610,7 +607,7 @@ Entity OrbitalSimulationSystem::addPlanet(Transform::Handle sun, std::string n,
6360000, 6420000, 8000, 0.76, transmittance, inscattering);
}
if (hasAtmosphere) {
if (planet.hasAtmosphere) {
atmosphereMat.mainTexture = transmittance;
atmosphereMat.specularSmoothnessTexture = inscattering;
atmosphereMat.emissiveColor = { Rg, Rt, 0, 0 };
......@@ -624,7 +621,7 @@ Entity OrbitalSimulationSystem::addPlanet(Transform::Handle sun, std::string n,
}
if (isEarthlike && hasWater) {
if (planet.hasWater) {
// Add simple water as well
auto water = m_scene->create();
auto waterTransform = water.assign<Transform>();
......@@ -633,7 +630,7 @@ Entity OrbitalSimulationSystem::addPlanet(Transform::Handle sun, std::string n,
waterTransform->scale = planetTransform->scale * 1.0;
}
if (hasMoon) {
if (planet.moonCount != 0) {
// Let's add a moon!
auto moon = m_scene->create();
auto moonTransform = moon.assign<Transform>();
......
......@@ -267,14 +267,14 @@ void AtmosphereTestScene::switchToMainScene() {
//e
// a i N w
mercury = m_orbitals->addPlanet(sunTransform, "Mercury", 0.000000165956, 0.003505316091954, 0.205633, 0.387098, 0.1222500, 0.84153, 0.50768, 0, true, false, true, true);
venus = m_orbitals->addPlanet(sunTransform, "Venus", 0.00000243522, 0.008695402298851, 0.006778, 0.723330, 0.0592500, 1.33679, 0.95717, 0, true, false, true, true);
earth = m_orbitals->addPlanet(sunTransform, "Earth", 0.000002988, 0.009153735632184, 0.016713, 1.000000, 0.0000000, 0.00000, 4.93533, 0, true, true, true, true);
mars = m_orbitals->addPlanet(sunTransform, "Mars", 0.000000319716, 0.004870689655172, 0.093396, 1.523688, 0.0322851, 0.02333, 4.99858, 0, true, true, true, true);
jupiter = m_orbitals->addPlanet(sunTransform, "Jupiter", 0.000954265748, 0.1004468390805, 0.048482, 5.202560, 0.0227500, 1.75150, 4.77905, 0, false, false, true, false);
saturn = m_orbitals->addPlanet(sunTransform, "Saturn", 0.00028386, 0.08366666666667, 0.055580, 9.554750, 0.0434412, 1.98230, 5.92169, 0, false, false, true, false);
uranus = m_orbitals->addPlanet(sunTransform, "Uranus", 0.00004344552, 0.03643965517241, 0.047292, 19.18176, 0.0134948, 1.29060, 1.68516, 0, false, false, true, false);
neptune = m_orbitals->addPlanet(sunTransform, "Neptune", 0.0000512442, 0.03537643678161, 0.008598, 30.05814, 0.0002355, 2.29810, 4.76243, 0, false, false, true, false);
mercury = m_orbitals->addPlanet(sunTransform, "Mercury", 0.000000165956, 0.003505316091954, 0.205633, 0.387098, 0.1222500, 0.84153, 0.50768, 0, "earth");
venus = m_orbitals->addPlanet(sunTransform, "Venus", 0.00000243522, 0.008695402298851, 0.006778, 0.723330, 0.0592500, 1.33679, 0.95717, 0, "mars");
earth = m_orbitals->addPlanet(sunTransform, "Earth", 0.000002988, 0.009153735632184, 0.016713, 1.000000, 0.0000000, 0.00000, 4.93533, 0, m_settings->getDefaultPlanetType());
mars = m_orbitals->addPlanet(sunTransform, "Mars", 0.000000319716, 0.004870689655172, 0.093396, 1.523688, 0.0322851, 0.02333, 4.99858, 0, "mars");
jupiter = m_orbitals->addPlanet(sunTransform, "Jupiter", 0.000954265748, 0.1004468390805, 0.048482, 5.202560, 0.0227500, 1.75150, 4.77905, 0, "jupiter");
saturn = m_orbitals->addPlanet(sunTransform, "Saturn", 0.00028386, 0.08366666666667, 0.055580, 9.554750, 0.0434412, 1.98230, 5.92169, 0, "jupiter");
uranus = m_orbitals->addPlanet(sunTransform, "Uranus", 0.00004344552, 0.03643965517241, 0.047292, 19.18176, 0.0134948, 1.29060, 1.68516, 0, "jupiter");
neptune = m_orbitals->addPlanet(sunTransform, "Neptune", 0.0000512442, 0.03537643678161, 0.008598, 30.05814, 0.0002355, 2.29810, 4.76243, 0, "jupiter");
m_player->attachToParent(earth);
......
......@@ -91,14 +91,14 @@ bool OrbitsScene::startup() {
// Mass in solar masses, Radius in solar radii, Eccentricity, Semimajor axis, Inclination, Ascending Node, Arg. of Periapsis, time at perihelion
// mass radius e a i N w
mercury = m_orbitals->addPlanet(sunTransform, "Mercury", 0.000000165956, 0.003505316091954, 0.205633, 0.387098, 0.1222500, 0.84153, 0.50768, 0, true, true, true);
venus = m_orbitals->addPlanet(sunTransform, "Venus", 0.00000243522, 0.008695402298851, 0.006778, 0.723330, 0.0592500, 1.33679, 0.95717, 0, true, true, true);
earth = m_orbitals->addPlanet(sunTransform, "Earth", 0.000002988, 0.009153735632184, 0.016713, 1.000000, 0.0000000, 0.00000, 4.93533, 0, true, true, true);
mars = m_orbitals->addPlanet(sunTransform, "Mars", 0.000000319716, 0.004870689655172, 0.093396, 1.523688, 0.0322851, 0.02333, 4.99858, 0, true, true, true);
jupiter = m_orbitals->addPlanet(sunTransform, "Jupiter", 0.000954265748, 0.1004468390805, 0.048482, 5.202560, 0.0227500, 1.75150, 4.77905, 0, true, true, true);
saturn = m_orbitals->addPlanet(sunTransform, "Saturn", 0.00028386, 0.08366666666667, 0.055580, 9.554750, 0.0434412, 1.98230, 5.92169, 0, true, true, true);
uranus = m_orbitals->addPlanet(sunTransform, "Uranus", 0.00004344552, 0.03643965517241, 0.047292, 19.18176, 0.0134948, 1.29060, 1.68516, 0, true, true, true);
neptune = m_orbitals->addPlanet(sunTransform, "Neptune", 0.0000512442, 0.03537643678161, 0.008598, 30.05814, 0.0002355, 2.29810, 4.76243, 0, true, true, true);
mercury = m_orbitals->addPlanet(sunTransform, "Mercury", 0.000000165956, 0.003505316091954, 0.205633, 0.387098, 0.1222500, 0.84153, 0.50768, 0);
venus = m_orbitals->addPlanet(sunTransform, "Venus", 0.00000243522, 0.008695402298851, 0.006778, 0.723330, 0.0592500, 1.33679, 0.95717, 0);
earth = m_orbitals->addPlanet(sunTransform, "Earth", 0.000002988, 0.009153735632184, 0.016713, 1.000000, 0.0000000, 0.00000, 4.93533, 0);
mars = m_orbitals->addPlanet(sunTransform, "Mars", 0.000000319716, 0.004870689655172, 0.093396, 1.523688, 0.0322851, 0.02333, 4.99858, 0);
jupiter = m_orbitals->addPlanet(sunTransform, "Jupiter", 0.000954265748, 0.1004468390805, 0.048482, 5.202560, 0.0227500, 1.75150, 4.77905, 0);
saturn = m_orbitals->addPlanet(sunTransform, "Saturn", 0.00028386, 0.08366666666667, 0.055580, 9.554750, 0.0434412, 1.98230, 5.92169, 0);
uranus = m_orbitals->addPlanet(sunTransform, "Uranus", 0.00004344552, 0.03643965517241, 0.047292, 19.18176, 0.0134948, 1.29060, 1.68516, 0);
neptune = m_orbitals->addPlanet(sunTransform, "Neptune", 0.0000512442, 0.03537643678161, 0.008598, 30.05814, 0.0002355, 2.29810, 4.76243, 0);
// Load a sound and enable 3D positioning for it
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment