diff --git a/data/config/planets/earth.json b/data/config/planets/earth.json new file mode 100644 index 0000000000000000000000000000000000000000..7e6408359dd76554cdd6541f4b1baa5a0c3f3220 --- /dev/null +++ b/data/config/planets/earth.json @@ -0,0 +1,6 @@ +{ + "shaders": "planets/earth", + "atmosphere": true, + "water": true, + "moons": 1 +} \ No newline at end of file diff --git a/data/config/planets/jupiter.json b/data/config/planets/jupiter.json new file mode 100644 index 0000000000000000000000000000000000000000..d1e0e480ae0a5d3f73311b87e35b494b657281c3 --- /dev/null +++ b/data/config/planets/jupiter.json @@ -0,0 +1,6 @@ +{ + "shaders": "planets/jupiter", + "atmosphere": false, + "water": false, + "moons": 3 +} \ No newline at end of file diff --git a/data/config/planets/mars.json b/data/config/planets/mars.json new file mode 100644 index 0000000000000000000000000000000000000000..474e1d0673a8775593c9d07cd4c8d85c8a7ab027 --- /dev/null +++ b/data/config/planets/mars.json @@ -0,0 +1,6 @@ +{ + "shaders": "planets/mars", + "atmosphere": false, + "water": false, + "moons": 0 +} \ No newline at end of file diff --git a/data/config/settings.json b/data/config/settings.json new file mode 100644 index 0000000000000000000000000000000000000000..6680d808ec5ce6554d94530407c311625bd2459c --- /dev/null +++ b/data/config/settings.json @@ -0,0 +1,12 @@ +{ + "resolution": [1280, 720], + "target_fps": 60, + "fullscreen": false, + "quality": "high", + "available_planet_prefabs": [ + "earth", + "mars", + "jupiter" + ], + "scene": "AtmosphereTest" +} \ No newline at end of file diff --git a/data/shader/TXAA.fsh b/data/shader/TXAA.fsh index 78329e7462eea26f0a4fa9062dd46199b559919f..252e9a77c12d8cea81f9b06b269952858220abc7 100644 --- a/data/shader/TXAA.fsh +++ b/data/shader/TXAA.fsh @@ -33,13 +33,11 @@ void main() depth = depthSample; } } - - vec4 history = texture(uSamplerHistory, vTexCoord - motion.xy); - float factor = 0.85; - + vec4 history = texture(uSamplerHistory, vTexCoord - motion); vec4 current = texture(uSamplerColor, vTexCoord); + vec4 minNeighbour = current; vec4 maxNeighbour = current; diff --git a/data/shader/WaterSurface.fsh b/data/shader/WaterSurface.fsh index a2eaafe8631b9e7a23fbe3edcdd5013b21e050f3..558ab2bf3b8f8ea740cb4c47e1bff818e38b3ac5 100644 --- a/data/shader/WaterSurface.fsh +++ b/data/shader/WaterSurface.fsh @@ -9,7 +9,7 @@ #pragma import "CommonDeferredFrag.glsl" -#pragma import "planets/earth_texture.glsl" +#pragma import "planets/earth/earth_texture.glsl" #pragma import "terrain/generic_water_texture.glsl" #pragma import "terrain/dispMappingWithWater_fsh.glsl" diff --git a/data/shader/planets/earth.fsh b/data/shader/planets/earth.fsh deleted file mode 100644 index efe16caca412b6965d27c69d246090f9958736de..0000000000000000000000000000000000000000 --- a/data/shader/planets/earth.fsh +++ /dev/null @@ -1,15 +0,0 @@ -#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 "earth_texture.glsl" -#pragma import "../terrain/generic_water_texture.glsl" - -#pragma import "../terrain/dispMappingWithWater_fsh.glsl" diff --git a/data/shader/planets/earth.gsh b/data/shader/planets/earth.gsh deleted file mode 100644 index d579c590a28504ab365759919533453c4ac66ea2..0000000000000000000000000000000000000000 --- a/data/shader/planets/earth.gsh +++ /dev/null @@ -1 +0,0 @@ -#pragma import "../terrain/dispMapping_gsh.glsl" diff --git a/data/shader/planets/earth.tcsh b/data/shader/planets/earth.tcsh deleted file mode 100644 index 23241f2db002e9748f01725656af64fd86ba49da..0000000000000000000000000000000000000000 --- a/data/shader/planets/earth.tcsh +++ /dev/null @@ -1 +0,0 @@ -#pragma import "../terrain/dispMapping_tcsh.glsl" diff --git a/data/shader/planets/earth.tesh b/data/shader/planets/earth.tesh deleted file mode 100644 index cf9fd1b1ac1d2ef273b7aad38b3f42ce8f4f716f..0000000000000000000000000000000000000000 --- a/data/shader/planets/earth.tesh +++ /dev/null @@ -1,6 +0,0 @@ - -#pragma import "../noise/noise3d.glsl" -#pragma import "../Utils.glsl" - -#pragma import "earth_texture.glsl" -#pragma import "../terrain/dispMapping_tesh.glsl" diff --git a/data/shader/planets/earth.vsh b/data/shader/planets/earth.vsh deleted file mode 100644 index 3ac58a6128d2a9032182ea82a79660a15787cb8d..0000000000000000000000000000000000000000 --- a/data/shader/planets/earth.vsh +++ /dev/null @@ -1 +0,0 @@ -#pragma import "../terrain/dispMapping_vsh.glsl" diff --git a/data/shader/planets/earth/earth.fsh b/data/shader/planets/earth/earth.fsh new file mode 100644 index 0000000000000000000000000000000000000000..252be10c317a691db57b10a3a3715b1d8c1c8faf --- /dev/null +++ b/data/shader/planets/earth/earth.fsh @@ -0,0 +1,15 @@ +#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 "earth_texture.glsl" +#pragma import "../../terrain/generic_water_texture.glsl" + +#pragma import "../../terrain/dispMappingWithWater_fsh.glsl" diff --git a/data/shader/planets/earth/earth.gsh b/data/shader/planets/earth/earth.gsh new file mode 100644 index 0000000000000000000000000000000000000000..8b439a9355e3cd5a0ea418658923c58c55052c0c --- /dev/null +++ b/data/shader/planets/earth/earth.gsh @@ -0,0 +1 @@ +#pragma import "../../terrain/dispMapping_gsh.glsl" diff --git a/data/shader/planets/earth/earth.tcsh b/data/shader/planets/earth/earth.tcsh new file mode 100644 index 0000000000000000000000000000000000000000..1340d2f5ec505acb8b4366b41c87992d521dbeae --- /dev/null +++ b/data/shader/planets/earth/earth.tcsh @@ -0,0 +1 @@ +#pragma import "../../terrain/dispMapping_tcsh.glsl" diff --git a/data/shader/planets/earth/earth.tesh b/data/shader/planets/earth/earth.tesh new file mode 100644 index 0000000000000000000000000000000000000000..ce91606fa23e7582ff053b48cd35fcace60d8123 --- /dev/null +++ b/data/shader/planets/earth/earth.tesh @@ -0,0 +1,6 @@ + +#pragma import "../../noise/noise3d.glsl" +#pragma import "../../Utils.glsl" + +#pragma import "earth_texture.glsl" +#pragma import "../../terrain/dispMapping_tesh.glsl" diff --git a/data/shader/planets/earth/earth.vsh b/data/shader/planets/earth/earth.vsh new file mode 100644 index 0000000000000000000000000000000000000000..16af3ce566b9692a7c5c8a9ddff1119baf5f81a6 --- /dev/null +++ b/data/shader/planets/earth/earth.vsh @@ -0,0 +1 @@ +#pragma import "../../terrain/dispMapping_vsh.glsl" diff --git a/data/shader/planets/earth_texture.glsl b/data/shader/planets/earth/earth_texture.glsl similarity index 100% rename from data/shader/planets/earth_texture.glsl rename to data/shader/planets/earth/earth_texture.glsl diff --git a/data/shader/planets/jupiter.fsh b/data/shader/planets/jupiter.fsh deleted file mode 100644 index 6684d276759d5f98e623fb567e2e487b67b4c833..0000000000000000000000000000000000000000 --- a/data/shader/planets/jupiter.fsh +++ /dev/null @@ -1,9 +0,0 @@ -#version 410 core - -#pragma import "../setup/geometry.glsl" - -#pragma import "../CommonDeferredFrag.glsl" - -#pragma import "gas_texture.glsl" - -#pragma import "../terrain/plainSphere_fsh.glsl" diff --git a/data/shader/planets/jupiter.gsh b/data/shader/planets/jupiter.gsh deleted file mode 100644 index 18bc441b77884d881418f399a4b42df09ca67965..0000000000000000000000000000000000000000 --- a/data/shader/planets/jupiter.gsh +++ /dev/null @@ -1 +0,0 @@ -#pragma import "../terrain/plainSphere_gsh.glsl" diff --git a/data/shader/planets/jupiter.tcsh b/data/shader/planets/jupiter.tcsh deleted file mode 100644 index 2b7bf4685ac45c9a42b09ecbeb6747500fc34e9c..0000000000000000000000000000000000000000 --- a/data/shader/planets/jupiter.tcsh +++ /dev/null @@ -1 +0,0 @@ -#pragma import "../terrain/plainSphere_tcsh.glsl" diff --git a/data/shader/planets/jupiter.tesh b/data/shader/planets/jupiter.tesh deleted file mode 100644 index ac8c98f1e9fddf9d6f0ec8fcd9a00a347ca75c17..0000000000000000000000000000000000000000 --- a/data/shader/planets/jupiter.tesh +++ /dev/null @@ -1,2 +0,0 @@ - -#pragma import "../terrain/plainSphere_tesh.glsl" diff --git a/data/shader/planets/jupiter.vsh b/data/shader/planets/jupiter.vsh deleted file mode 100644 index f79697336007bec41a41950b2143dd882cb26529..0000000000000000000000000000000000000000 --- a/data/shader/planets/jupiter.vsh +++ /dev/null @@ -1 +0,0 @@ -#pragma import "../terrain/plainSphere_vsh.glsl" diff --git a/data/shader/planets/jupiter/jupiter.fsh b/data/shader/planets/jupiter/jupiter.fsh new file mode 100644 index 0000000000000000000000000000000000000000..2a4c7e7e89381f15c2487a712ac2b55809c83a92 --- /dev/null +++ b/data/shader/planets/jupiter/jupiter.fsh @@ -0,0 +1,9 @@ +#version 410 core + +#pragma import "../../setup/geometry.glsl" + +#pragma import "../../CommonDeferredFrag.glsl" + +#pragma import "jupiter_texture.glsl" + +#pragma import "../../terrain/plainSphere_fsh.glsl" diff --git a/data/shader/planets/jupiter/jupiter.gsh b/data/shader/planets/jupiter/jupiter.gsh new file mode 100644 index 0000000000000000000000000000000000000000..a6e115eec8715ec2a50af823466a63685f0d26ee --- /dev/null +++ b/data/shader/planets/jupiter/jupiter.gsh @@ -0,0 +1 @@ +#pragma import "../../terrain/plainSphere_gsh.glsl" diff --git a/data/shader/planets/jupiter/jupiter.tcsh b/data/shader/planets/jupiter/jupiter.tcsh new file mode 100644 index 0000000000000000000000000000000000000000..d1029216ed88698aa43dce62138f9e1dc3926a5b --- /dev/null +++ b/data/shader/planets/jupiter/jupiter.tcsh @@ -0,0 +1 @@ +#pragma import "../../terrain/plainSphere_tcsh.glsl" diff --git a/data/shader/planets/jupiter/jupiter.tesh b/data/shader/planets/jupiter/jupiter.tesh new file mode 100644 index 0000000000000000000000000000000000000000..b82bd91d21b425b1b1624b207ad210855e169f23 --- /dev/null +++ b/data/shader/planets/jupiter/jupiter.tesh @@ -0,0 +1 @@ +#pragma import "../../terrain/plainSphere_tesh.glsl" diff --git a/data/shader/planets/jupiter/jupiter.vsh b/data/shader/planets/jupiter/jupiter.vsh new file mode 100644 index 0000000000000000000000000000000000000000..c44148ce9c65f1c079073153d39d52fe65e302b5 --- /dev/null +++ b/data/shader/planets/jupiter/jupiter.vsh @@ -0,0 +1 @@ +#pragma import "../../terrain/plainSphere_vsh.glsl" diff --git a/data/shader/planets/gas_texture.glsl b/data/shader/planets/jupiter/jupiter_texture.glsl similarity index 97% rename from data/shader/planets/gas_texture.glsl rename to data/shader/planets/jupiter/jupiter_texture.glsl index 69e9823281e669b22d6ccc92eaccba6a54f424ab..0ec79f25ab2c9b3f9f7a44e3790031bad18f8795 100644 --- a/data/shader/planets/gas_texture.glsl +++ b/data/shader/planets/jupiter/jupiter_texture.glsl @@ -1,5 +1,5 @@ -#pragma import "../noise/noise3d.glsl" -#pragma import "../noise/noise2d.glsl" +#pragma import "../../noise/noise3d.glsl" +#pragma import "../../noise/noise2d.glsl" //float getHeightNoise(vec3 normalizedPosInModelspace) { diff --git a/data/shader/planets/mars/mars.gsh b/data/shader/planets/mars/mars.gsh new file mode 100644 index 0000000000000000000000000000000000000000..8b439a9355e3cd5a0ea418658923c58c55052c0c --- /dev/null +++ b/data/shader/planets/mars/mars.gsh @@ -0,0 +1 @@ +#pragma import "../../terrain/dispMapping_gsh.glsl" diff --git a/data/shader/planets/mars/mars.tcsh b/data/shader/planets/mars/mars.tcsh new file mode 100644 index 0000000000000000000000000000000000000000..1340d2f5ec505acb8b4366b41c87992d521dbeae --- /dev/null +++ b/data/shader/planets/mars/mars.tcsh @@ -0,0 +1 @@ +#pragma import "../../terrain/dispMapping_tcsh.glsl" diff --git a/data/shader/planets/mars/mars.tesh b/data/shader/planets/mars/mars.tesh new file mode 100644 index 0000000000000000000000000000000000000000..0f7e9ad07f21559460018e484d12017c3d461806 --- /dev/null +++ b/data/shader/planets/mars/mars.tesh @@ -0,0 +1,5 @@ +#pragma import "../../noise/noise3d.glsl" +#pragma import "../../Utils.glsl" + +#pragma import "mars_texture.glsl" +#pragma import "../../terrain/dispMapping_tesh.glsl" diff --git a/data/shader/planets/mars/mars.vsh b/data/shader/planets/mars/mars.vsh new file mode 100644 index 0000000000000000000000000000000000000000..16af3ce566b9692a7c5c8a9ddff1119baf5f81a6 --- /dev/null +++ b/data/shader/planets/mars/mars.vsh @@ -0,0 +1 @@ +#pragma import "../../terrain/dispMapping_vsh.glsl" diff --git a/data/shader/planets/mars/mars_texture.glsl b/data/shader/planets/mars/mars_texture.glsl new file mode 100644 index 0000000000000000000000000000000000000000..bceeff0ce642949845bae279e97f0ac918c5f452 --- /dev/null +++ b/data/shader/planets/mars/mars_texture.glsl @@ -0,0 +1,81 @@ +float getContinentHeightNoise(vec3 normalizedPosInModelspace) { + return 2*(fbm_3d(normalizedPosInModelspace , 2, 1.25)); +} +float getRidgedHeightNoise(vec3 normalizedPosInModelspace) { + return (.75 - abs(fbm_3d( normalizedPosInModelspace , 2, 40.)))/2.; +} +float getDetailHeightNoise(vec3 normalizedPosInModelspace) { + return fbm_3d( normalizedPosInModelspace , 2, 160.)/8.; +} +float getRidgedDetailsHeightNoise(vec3 normalizedPosInModelspace) { + return (.75 - abs(fbm_3d( normalizedPosInModelspace , 4, 8*640.)))/256.; +} + +float getHeightNoise(vec3 normalizedPosInModelspace) { + return (getContinentHeightNoise(normalizedPosInModelspace) + + getRidgedHeightNoise(normalizedPosInModelspace) + + getDetailHeightNoise(normalizedPosInModelspace) + + getRidgedDetailsHeightNoise(normalizedPosInModelspace)) + * 2.; +} + +#define SNOW_LEVEL .5 +#define ROCK_LEVEL .3 +#define PLANT_LEVEL .03 + +#define ROCK_SLOPE .6 + +vec4 texture_getColor(vec3 texCoord3d, vec3 upVectorNormalized, vec3 normalNormalized, float depth){ + //float noiseVal1 = fbm_3d( texCoord3d,4, 128.*128.);// * 0.05; + float noiseOct1 = 0.; + float noiseOct2 = 0.; + float noiseOct3 = 0.; + float noiseOct4 = 0.; + float noiseOct5 = 0.; + + noiseOct1 = snoise_3d(32.*128. * texCoord3d); + noiseOct2 = snoise_3d(64.*128. * texCoord3d); + noiseOct3 = snoise_3d(128.*128. * texCoord3d); + + float heightPertubation = 1./2.*noiseOct1 + 1./4.*noiseOct2 + 1./8.*noiseOct3; + vec4 color = vec4(1., 1., 1., 1.); + + float height =getHeightNoise(texCoord3d)/2.*.9 + heightPertubation * .1; + + float dt = dot(normalNormalized, upVectorNormalized); + float cs = dt / (length(normalNormalized) * length(upVectorNormalized)); + float phi = acos(dt); + float phiNormalized = 2*phi / M_PI; //scale results from [0, M_PI/2] to [0, 1] + + float phiPertubation = 1./2.*noiseOct4 + 1./4.*noiseOct5; + float phiPert = .9*phiNormalized + .1 * phiPertubation; + + + if (height> SNOW_LEVEL && phiPert <= ROCK_SLOPE) { + color = vec4(1., 1., 1., 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.); + }else { //"sand"" + color = vec4(1., .8, .55, 1.); + } + return color; +} + +vec4 texture_getColor(vec3 texCoord3d, vec3 upVectorNormalized, vec3 normalNormalized){ + return texture_getColor(texCoord3d, upVectorNormalized, normalNormalized, 1.); +} + +float texture_getFinalHeight(vec3 normalizedPosInModelspace){ + return 0.008 * getHeightNoise(normalizedPosInModelspace); +} + +vec3 texture_getDisplacedPosition_modelspace(vec3 normalizedPosInModelspace, vec3 normalizedNormal) { + vec3 newPosition = normalizedPosInModelspace + normalizedNormal * texture_getFinalHeight(normalizedPosInModelspace); + return newPosition; +} + + diff --git a/data/shader/planets/moon.fsh b/data/shader/planets/moon.fsh deleted file mode 100644 index dc4e1aebd8781310300c97b53224643bb1dd92b8..0000000000000000000000000000000000000000 --- a/data/shader/planets/moon.fsh +++ /dev/null @@ -1,12 +0,0 @@ -#version 410 core - -#pragma import "../setup/geometry.glsl" - -#pragma import "../noise/noise3d.glsl" -#pragma import "../Utils.glsl" - -#pragma import "../CommonDeferredFrag.glsl" - -#pragma import "moon_texture.glsl" - -#pragma import "../terrain/dispMapping_fsh.glsl" diff --git a/data/shader/planets/moon.gsh b/data/shader/planets/moon.gsh deleted file mode 100644 index d579c590a28504ab365759919533453c4ac66ea2..0000000000000000000000000000000000000000 --- a/data/shader/planets/moon.gsh +++ /dev/null @@ -1 +0,0 @@ -#pragma import "../terrain/dispMapping_gsh.glsl" diff --git a/data/shader/planets/moon.tcsh b/data/shader/planets/moon.tcsh deleted file mode 100644 index 23241f2db002e9748f01725656af64fd86ba49da..0000000000000000000000000000000000000000 --- a/data/shader/planets/moon.tcsh +++ /dev/null @@ -1 +0,0 @@ -#pragma import "../terrain/dispMapping_tcsh.glsl" diff --git a/data/shader/planets/moon.tesh b/data/shader/planets/moon.tesh deleted file mode 100644 index 995f2613922a3e5b3a1051fa5d376de7994c2c9d..0000000000000000000000000000000000000000 --- a/data/shader/planets/moon.tesh +++ /dev/null @@ -1,6 +0,0 @@ -#pragma import "../noise/noise3d.glsl" - -#pragma import "../Utils.glsl" - -#pragma import "earth_texture.glsl" -#pragma import "../terrain/dispMapping_tesh.glsl" diff --git a/data/shader/planets/moon.vsh b/data/shader/planets/moon.vsh deleted file mode 100644 index 3ac58a6128d2a9032182ea82a79660a15787cb8d..0000000000000000000000000000000000000000 --- a/data/shader/planets/moon.vsh +++ /dev/null @@ -1 +0,0 @@ -#pragma import "../terrain/dispMapping_vsh.glsl" diff --git a/data/shader/planets/moon/moon.fsh b/data/shader/planets/moon/moon.fsh new file mode 100644 index 0000000000000000000000000000000000000000..1dc425465b98a77dbe0659e3e199d978120bb843 --- /dev/null +++ b/data/shader/planets/moon/moon.fsh @@ -0,0 +1,12 @@ +#version 410 core + +#pragma import "../../setup/geometry.glsl" + +#pragma import "../../noise/noise3d.glsl" +#pragma import "../../Utils.glsl" + +#pragma import "../../CommonDeferredFrag.glsl" + +#pragma import "moon_texture.glsl" + +#pragma import "../../terrain/dispMapping_fsh.glsl" diff --git a/data/shader/planets/moon/moon.gsh b/data/shader/planets/moon/moon.gsh new file mode 100644 index 0000000000000000000000000000000000000000..8b439a9355e3cd5a0ea418658923c58c55052c0c --- /dev/null +++ b/data/shader/planets/moon/moon.gsh @@ -0,0 +1 @@ +#pragma import "../../terrain/dispMapping_gsh.glsl" diff --git a/data/shader/planets/moon/moon.tcsh b/data/shader/planets/moon/moon.tcsh new file mode 100644 index 0000000000000000000000000000000000000000..1340d2f5ec505acb8b4366b41c87992d521dbeae --- /dev/null +++ b/data/shader/planets/moon/moon.tcsh @@ -0,0 +1 @@ +#pragma import "../../terrain/dispMapping_tcsh.glsl" diff --git a/data/shader/planets/moon/moon.tesh b/data/shader/planets/moon/moon.tesh new file mode 100644 index 0000000000000000000000000000000000000000..a363e13cb0d9519ab39b1f4de4a44819aae49124 --- /dev/null +++ b/data/shader/planets/moon/moon.tesh @@ -0,0 +1,6 @@ +#pragma import "../../noise/noise3d.glsl" + +#pragma import "../../Utils.glsl" + +#pragma import "../earth/earth_texture.glsl" +#pragma import "../../terrain/dispMapping_tesh.glsl" diff --git a/data/shader/planets/moon/moon.vsh b/data/shader/planets/moon/moon.vsh new file mode 100644 index 0000000000000000000000000000000000000000..16af3ce566b9692a7c5c8a9ddff1119baf5f81a6 --- /dev/null +++ b/data/shader/planets/moon/moon.vsh @@ -0,0 +1 @@ +#pragma import "../../terrain/dispMapping_vsh.glsl" diff --git a/data/shader/planets/moon_texture.glsl b/data/shader/planets/moon/moon_texture.glsl similarity index 100% rename from data/shader/planets/moon_texture.glsl rename to data/shader/planets/moon/moon_texture.glsl diff --git a/presentation/atmosphere (1).png b/presentation/atmosphere (1).png new file mode 100644 index 0000000000000000000000000000000000000000..2ec245f49507537994deda6b64283384f079a83b Binary files /dev/null and b/presentation/atmosphere (1).png differ diff --git a/presentation/atmosphere (2).png b/presentation/atmosphere (2).png new file mode 100644 index 0000000000000000000000000000000000000000..ef87f0456058fe09ae885d485c0e144ad131772f Binary files /dev/null and b/presentation/atmosphere (2).png differ diff --git a/presentation/atmosphere_artifacts.png b/presentation/atmosphere_artifacts.png new file mode 100644 index 0000000000000000000000000000000000000000..2f3e8ab9f20b94cb2f612e58d7324d70c224126e Binary files /dev/null and b/presentation/atmosphere_artifacts.png differ diff --git a/presentation/clouds_01.png b/presentation/clouds_01.png new file mode 100644 index 0000000000000000000000000000000000000000..ca9f497de8211d6903b38bef2185afeb43fece9f Binary files /dev/null and b/presentation/clouds_01.png differ diff --git a/presentation/clouds_02.png b/presentation/clouds_02.png new file mode 100644 index 0000000000000000000000000000000000000000..b3aff1aceb4de73e135871f9f1d1e226bd03a13a Binary files /dev/null and b/presentation/clouds_02.png differ diff --git a/presentation/comparison_aa_no_aa.png b/presentation/comparison_aa_no_aa.png new file mode 100644 index 0000000000000000000000000000000000000000..38ca6dbeaa66fda8958abb498dc6bf766f2a148c Binary files /dev/null and b/presentation/comparison_aa_no_aa.png differ diff --git a/presentation/no_aa.png b/presentation/no_aa.png new file mode 100644 index 0000000000000000000000000000000000000000..e951f984ddaf6820ffc4196ff54a927506829f10 Binary files /dev/null and b/presentation/no_aa.png differ diff --git a/presentation/no_rejection.png b/presentation/no_rejection.png new file mode 100644 index 0000000000000000000000000000000000000000..37bb189d84555292f9dc92b712774934a64ab4f2 Binary files /dev/null and b/presentation/no_rejection.png differ diff --git a/presentation/no_reprojection.png b/presentation/no_reprojection.png new file mode 100644 index 0000000000000000000000000000000000000000..d9c7948f6df6b0f4abbf66f10b5fb98d33f84595 Binary files /dev/null and b/presentation/no_reprojection.png differ diff --git a/presentation/with_aa.png b/presentation/with_aa.png new file mode 100644 index 0000000000000000000000000000000000000000..b240f0330b6ad2bff58bd5f1058adc687ae82473 Binary files /dev/null and b/presentation/with_aa.png differ diff --git a/run.bat b/run.bat index d1b8328d84d4e57f8c2cfa49575e3a0e405d59f4..83ad0d83164a06dd6982efa086ad47d9eabf5eb7 100644 --- a/run.bat +++ b/run.bat @@ -1 +1 @@ -"build\src\game\RelWithDebInfo\game.exe" AtmosphereTest "" +"build\src\game\RelWithDebInfo\game.exe" "config/settings.json" diff --git a/run.sh b/run.sh index 515872af32746edeaab19a024b9719cdc2b49dfc..1eb933320a6f353702a018a635191189c0059bf3 100755 --- a/run.sh +++ b/run.sh @@ -1 +1 @@ -./build/src/game/game AtmosphereTest "" +./build/src/game/game "config/settings.json" diff --git a/src/game/include/engine/core/GameLoopSystem.hpp b/src/game/include/engine/core/GameLoopSystem.hpp index 92cd365a7086f7297e35e7a8ddffdfe115c24b93..b3071ad367028ee120c0580fb0d7fd528078ab25 100644 --- a/src/game/include/engine/core/GameLoopSystem.hpp +++ b/src/game/include/engine/core/GameLoopSystem.hpp @@ -5,12 +5,14 @@ #include #include #include +#include #include #include class GameLoopSystem : public System { private: + SettingsSystem* m_settings; EventSystem* m_events; WindowSystem* m_window; RendererSystem* m_renderer; diff --git a/src/game/include/engine/core/SettingsSystem.hpp b/src/game/include/engine/core/SettingsSystem.hpp index 4d01de9edbde9d02251f3bea4cc8e8701ab32f30..7cbb954ccfe451114bc37659b0556daf368b1c9a 100644 --- a/src/game/include/engine/core/SettingsSystem.hpp +++ b/src/game/include/engine/core/SettingsSystem.hpp @@ -1,6 +1,22 @@ #pragma once #include #include +#include + +enum class QualitySetting { + Low, + Medium, + High +}; + +struct PlanetMetaData { + std::string name; + std::string shaders; + bool hasAtmosphere; + bool hasWater; + uint64_t moonCount; +}; + class SettingsSystem : public System { private: @@ -10,19 +26,38 @@ private: std::string m_shaderPath; std::string m_soundPath; + std::string m_configFilePath; + + std::vector m_availablePlanets; + + glm::ivec2 m_resolution; + QualitySetting m_qualitySetting; + bool m_fullscreen; + uint64_t m_targetFps; + std::string m_defaultScene; + public: CONSTRUCT_SYSTEM(SettingsSystem, std::string resourcePath, std::string texturePath, std::string geometryPath, - std::string shaderPath, std::string soundPath) + std::string shaderPath, std::string soundPath, std::string configFilePath) , m_resourcePath(resourcePath), m_texturePath(texturePath), m_geometryPath(geometryPath), m_shaderPath(shaderPath), - m_soundPath(soundPath) {} + m_soundPath(soundPath) { + + m_configFilePath = configFilePath; + } inline std::string getResourcePath() const { return m_resourcePath; } inline std::string getFullTexturePath() const { return m_resourcePath + m_texturePath; } inline std::string getFullGeometryPath() const { return m_resourcePath + m_geometryPath; } inline std::string getFullShaderPath() const { return m_resourcePath + m_shaderPath; } inline std::string getFullSoundPath() const { return m_resourcePath + m_soundPath; } + inline glm::ivec2 getResolution() const { return m_resolution; } + inline bool getFullscreen() const { return m_fullscreen; } + 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::vector getAvailablePlanets() const { return m_availablePlanets; } bool startup() override; void shutdown() override; diff --git a/src/game/include/engine/core/WindowSystem.hpp b/src/game/include/engine/core/WindowSystem.hpp index 9bf858f3d7c1be1156fecfe1ddb24b210757f944..df4c8eb301cb94a60b4feaea5f3a5d0e94fee88e 100644 --- a/src/game/include/engine/core/WindowSystem.hpp +++ b/src/game/include/engine/core/WindowSystem.hpp @@ -1,22 +1,27 @@ #pragma once #include #include +#include #include #include class WindowSystem : public System { private: + SettingsSystem* m_settings; + void setSDLHintsForOpenGLVersion(unsigned int _version); bool createWindow(); glm::uvec2 m_windowSize; SDL_Window *m_sdlWindow; SDL_GLContext m_glContext; + bool m_fullscreen; public: - CONSTRUCT_SYSTEM(WindowSystem, int windowWidth, int windowHeight) { + CONSTRUCT_SYSTEM(WindowSystem, int windowWidth, int windowHeight, bool fullscreen) { m_windowSize.x = windowWidth; m_windowSize.y = windowHeight; + m_fullscreen = fullscreen; } void setWindowTitle(const char* title); diff --git a/src/game/include/engine/scene/OrbitalSimulationSystem.hpp b/src/game/include/engine/scene/OrbitalSimulationSystem.hpp index f4c42fdef59ed2710a982b3decf2cb7e598f8903..62704abec7b5f86793ac63c675a1891aec04fa8e 100644 --- a/src/game/include/engine/scene/OrbitalSimulationSystem.hpp +++ b/src/game/include/engine/scene/OrbitalSimulationSystem.hpp @@ -9,10 +9,13 @@ #include #include #include +#include + class OrbitalSimulationSystem : public System { private: + SettingsSystem* m_settings; EventSystem* m_events; SceneGraphSystem *m_scene; RendererSystem *m_renderer; @@ -22,9 +25,6 @@ private: Geometry orbitTorus; Geometry minimapItem; - Material planetMat; - Material jupiterMat; - Material earthMat; Material moonMat; Material trajectoryMat; Material atmosphereMat; @@ -32,6 +32,7 @@ private: Material waterMat; Material minimapItemMaterial; + std::unordered_map planetMaterials; std::vector trajectories; diff --git a/src/game/include/engine/utils/picojson.h b/src/game/include/engine/utils/picojson.h new file mode 100644 index 0000000000000000000000000000000000000000..045dc537babd749fdb8042966146fc915f73571f --- /dev/null +++ b/src/game/include/engine/utils/picojson.h @@ -0,0 +1,1039 @@ +/* + * Copyright 2009-2010 Cybozu Labs, Inc. + * Copyright 2011-2014 Kazuho Oku + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef picojson_h +#define picojson_h + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// for isnan/isinf +#if __cplusplus>=201103L +# include +#else +extern "C" { +# ifdef _MSC_VER +# include +# elif defined(__INTEL_COMPILER) +# include +# else +# include +# endif +} +#endif + +#ifndef PICOJSON_USE_RVALUE_REFERENCE +# if (defined(__cpp_rvalue_references) && __cpp_rvalue_references >= 200610) || (defined(_MSC_VER) && _MSC_VER >= 1600) +# define PICOJSON_USE_RVALUE_REFERENCE 1 +# else +# define PICOJSON_USE_RVALUE_REFERENCE 0 +# endif +#endif//PICOJSON_USE_RVALUE_REFERENCE + + +// experimental support for int64_t (see README.mkdn for detail) +#ifdef PICOJSON_USE_INT64 +# define __STDC_FORMAT_MACROS +# include +# include +#endif + +// to disable the use of localeconv(3), set PICOJSON_USE_LOCALE to 0 +#ifndef PICOJSON_USE_LOCALE +# define PICOJSON_USE_LOCALE 1 +#endif +#if PICOJSON_USE_LOCALE +extern "C" { +# include +} +#endif + +#ifndef PICOJSON_ASSERT +# define PICOJSON_ASSERT(e) do { if (! (e)) throw std::runtime_error(#e); } while (0) +#endif + +#ifdef _MSC_VER + #define SNPRINTF _snprintf_s + #pragma warning(push) + #pragma warning(disable : 4244) // conversion from int to char + #pragma warning(disable : 4127) // conditional expression is constant + #pragma warning(disable : 4702) // unreachable code +#else + #define SNPRINTF snprintf +#endif + +namespace picojson { + + enum { + null_type, + boolean_type, + number_type, + string_type, + array_type, + object_type +#ifdef PICOJSON_USE_INT64 + , int64_type +#endif + }; + + enum { + INDENT_WIDTH = 2 + }; + + struct null {}; + + class value { + public: + typedef std::vector array; + typedef std::map object; + union _storage { + bool boolean_; + double number_; +#ifdef PICOJSON_USE_INT64 + int64_t int64_; +#endif + std::string* string_; + array* array_; + object* object_; + }; + protected: + int type_; + _storage u_; + public: + value(); + value(int type, bool); + explicit value(bool b); +#ifdef PICOJSON_USE_INT64 + explicit value(int64_t i); +#endif + explicit value(double n); + explicit value(const std::string& s); + explicit value(const array& a); + explicit value(const object& o); + explicit value(const char* s); + value(const char* s, size_t len); + ~value(); + value(const value& x); + value& operator=(const value& x); +#if PICOJSON_USE_RVALUE_REFERENCE + value(value&& x)throw(); + value& operator=(value&& x)throw(); +#endif + void swap(value& x)throw(); + template bool is() const; + template const T& get() const; + template T& get(); + bool evaluate_as_boolean() const; + const value& get(size_t idx) const; + const value& get(const std::string& key) const; + value& get(size_t idx); + value& get(const std::string& key); + + bool contains(size_t idx) const; + bool contains(const std::string& key) const; + std::string to_str() const; + template void serialize(Iter os, bool prettify = false) const; + std::string serialize(bool prettify = false) const; + private: + template value(const T*); // intentionally defined to block implicit conversion of pointer to bool + template static void _indent(Iter os, int indent); + template void _serialize(Iter os, int indent) const; + std::string _serialize(int indent) const; + }; + + typedef value::array array; + typedef value::object object; + + inline value::value() : type_(null_type) {} + + inline value::value(int type, bool) : type_(type) { + switch (type) { +#define INIT(p, v) case p##type: u_.p = v; break + INIT(boolean_, false); + INIT(number_, 0.0); +#ifdef PICOJSON_USE_INT64 + INIT(int64_, 0); +#endif + INIT(string_, new std::string()); + INIT(array_, new array()); + INIT(object_, new object()); +#undef INIT + default: break; + } + } + + inline value::value(bool b) : type_(boolean_type) { + u_.boolean_ = b; + } + +#ifdef PICOJSON_USE_INT64 + inline value::value(int64_t i) : type_(int64_type) { + u_.int64_ = i; + } +#endif + + inline value::value(double n) : type_(number_type) { + if ( +#ifdef _MSC_VER + ! _finite(n) +#elif __cplusplus>=201103L || !(defined(isnan) && defined(isinf)) + std::isnan(n) || std::isinf(n) +#else + isnan(n) || isinf(n) +#endif + ) { + throw std::overflow_error(""); + } + u_.number_ = n; + } + + inline value::value(const std::string& s) : type_(string_type) { + u_.string_ = new std::string(s); + } + + inline value::value(const array& a) : type_(array_type) { + u_.array_ = new array(a); + } + + inline value::value(const object& o) : type_(object_type) { + u_.object_ = new object(o); + } + + inline value::value(const char* s) : type_(string_type) { + u_.string_ = new std::string(s); + } + + inline value::value(const char* s, size_t len) : type_(string_type) { + u_.string_ = new std::string(s, len); + } + + inline value::~value() { + switch (type_) { +#define DEINIT(p) case p##type: delete u_.p; break + DEINIT(string_); + DEINIT(array_); + DEINIT(object_); +#undef DEINIT + default: break; + } + } + + inline value::value(const value& x) : type_(x.type_) { + switch (type_) { +#define INIT(p, v) case p##type: u_.p = v; break + INIT(string_, new std::string(*x.u_.string_)); + INIT(array_, new array(*x.u_.array_)); + INIT(object_, new object(*x.u_.object_)); +#undef INIT + default: + u_ = x.u_; + break; + } + } + + inline value& value::operator=(const value& x) { + if (this != &x) { + value t(x); + swap(t); + } + return *this; + } + +#if PICOJSON_USE_RVALUE_REFERENCE + inline value::value(value&& x)throw() : type_(null_type) { + swap(x); + } + inline value& value::operator=(value&& x)throw() { + swap(x); + return *this; + } +#endif + inline void value::swap(value& x)throw() { + std::swap(type_, x.type_); + std::swap(u_, x.u_); + } + +#define IS(ctype, jtype) \ + template <> inline bool value::is() const { \ + return type_ == jtype##_type; \ + } + IS(null, null) + IS(bool, boolean) +#ifdef PICOJSON_USE_INT64 + IS(int64_t, int64) +#endif + IS(std::string, string) + IS(array, array) + IS(object, object) +#undef IS + template <> inline bool value::is() const { + return type_ == number_type +#ifdef PICOJSON_USE_INT64 + || type_ == int64_type +#endif + ; + } + +#define GET(ctype, var) \ + template <> inline const ctype& value::get() const { \ + PICOJSON_ASSERT("type mismatch! call is() before get()" \ + && is()); \ + return var; \ + } \ + template <> inline ctype& value::get() { \ + PICOJSON_ASSERT("type mismatch! call is() before get()" \ + && is()); \ + return var; \ + } + GET(bool, u_.boolean_) + GET(std::string, *u_.string_) + GET(array, *u_.array_) + GET(object, *u_.object_) +#ifdef PICOJSON_USE_INT64 + GET(double, (type_ == int64_type && (const_cast(this)->type_ = number_type, const_cast(this)->u_.number_ = u_.int64_), u_.number_)) + GET(int64_t, u_.int64_) +#else + GET(double, u_.number_) +#endif +#undef GET + + inline bool value::evaluate_as_boolean() const { + switch (type_) { + case null_type: + return false; + case boolean_type: + return u_.boolean_; + case number_type: + return u_.number_ != 0; +#ifdef PICOJSON_USE_INT64 + case int64_type: + return u_.int64_ != 0; +#endif + case string_type: + return ! u_.string_->empty(); + default: + return true; + } + } + + inline const value& value::get(size_t idx) const { + static value s_null; + PICOJSON_ASSERT(is()); + return idx < u_.array_->size() ? (*u_.array_)[idx] : s_null; + } + + inline value& value::get(size_t idx) { + static value s_null; + PICOJSON_ASSERT(is()); + return idx < u_.array_->size() ? (*u_.array_)[idx] : s_null; + } + + inline const value& value::get(const std::string& key) const { + static value s_null; + PICOJSON_ASSERT(is()); + object::const_iterator i = u_.object_->find(key); + return i != u_.object_->end() ? i->second : s_null; + } + + inline value& value::get(const std::string& key) { + static value s_null; + PICOJSON_ASSERT(is()); + object::iterator i = u_.object_->find(key); + return i != u_.object_->end() ? i->second : s_null; + } + + inline bool value::contains(size_t idx) const { + PICOJSON_ASSERT(is()); + return idx < u_.array_->size(); + } + + inline bool value::contains(const std::string& key) const { + PICOJSON_ASSERT(is()); + object::const_iterator i = u_.object_->find(key); + return i != u_.object_->end(); + } + + inline std::string value::to_str() const { + switch (type_) { + case null_type: return "null"; + case boolean_type: return u_.boolean_ ? "true" : "false"; +#ifdef PICOJSON_USE_INT64 + case int64_type: { + char buf[sizeof("-9223372036854775808")]; + SNPRINTF(buf, sizeof(buf), "%" PRId64, u_.int64_); + return buf; + } +#endif + case number_type: { + char buf[256]; + double tmp; + SNPRINTF(buf, sizeof(buf), fabs(u_.number_) < (1ULL << 53) && modf(u_.number_, &tmp) == 0 ? "%.f" : "%.17g", u_.number_); +#if PICOJSON_USE_LOCALE + char *decimal_point = localeconv()->decimal_point; + if (strcmp(decimal_point, ".") != 0) { + size_t decimal_point_len = strlen(decimal_point); + for (char *p = buf; *p != '\0'; ++p) { + if (strncmp(p, decimal_point, decimal_point_len) == 0) { + return std::string(buf, p) + "." + (p + decimal_point_len); + } + } + } +#endif + return buf; + } + case string_type: return *u_.string_; + case array_type: return "array"; + case object_type: return "object"; + default: PICOJSON_ASSERT(0); +#ifdef _MSC_VER + __assume(0); +#endif + } + return std::string(); + } + + template void copy(const std::string& s, Iter oi) { + std::copy(s.begin(), s.end(), oi); + } + + template void serialize_str(const std::string& s, Iter oi) { + *oi++ = '"'; + for (std::string::const_iterator i = s.begin(); i != s.end(); ++i) { + switch (*i) { +#define MAP(val, sym) case val: copy(sym, oi); break + MAP('"', "\\\""); + MAP('\\', "\\\\"); + MAP('/', "\\/"); + MAP('\b', "\\b"); + MAP('\f', "\\f"); + MAP('\n', "\\n"); + MAP('\r', "\\r"); + MAP('\t', "\\t"); +#undef MAP + default: + if (static_cast(*i) < 0x20 || *i == 0x7f) { + char buf[7]; + SNPRINTF(buf, sizeof(buf), "\\u%04x", *i & 0xff); + copy(buf, buf + 6, oi); + } else { + *oi++ = *i; + } + break; + } + } + *oi++ = '"'; + } + + template void value::serialize(Iter oi, bool prettify) const { + return _serialize(oi, prettify ? 0 : -1); + } + + inline std::string value::serialize(bool prettify) const { + return _serialize(prettify ? 0 : -1); + } + + template void value::_indent(Iter oi, int indent) { + *oi++ = '\n'; + for (int i = 0; i < indent * INDENT_WIDTH; ++i) { + *oi++ = ' '; + } + } + + template void value::_serialize(Iter oi, int indent) const { + switch (type_) { + case string_type: + serialize_str(*u_.string_, oi); + break; + case array_type: { + *oi++ = '['; + if (indent != -1) { + ++indent; + } + for (array::const_iterator i = u_.array_->begin(); + i != u_.array_->end(); + ++i) { + if (i != u_.array_->begin()) { + *oi++ = ','; + } + if (indent != -1) { + _indent(oi, indent); + } + i->_serialize(oi, indent); + } + if (indent != -1) { + --indent; + if (! u_.array_->empty()) { + _indent(oi, indent); + } + } + *oi++ = ']'; + break; + } + case object_type: { + *oi++ = '{'; + if (indent != -1) { + ++indent; + } + for (object::const_iterator i = u_.object_->begin(); + i != u_.object_->end(); + ++i) { + if (i != u_.object_->begin()) { + *oi++ = ','; + } + if (indent != -1) { + _indent(oi, indent); + } + serialize_str(i->first, oi); + *oi++ = ':'; + if (indent != -1) { + *oi++ = ' '; + } + i->second._serialize(oi, indent); + } + if (indent != -1) { + --indent; + if (! u_.object_->empty()) { + _indent(oi, indent); + } + } + *oi++ = '}'; + break; + } + default: + copy(to_str(), oi); + break; + } + if (indent == 0) { + *oi++ = '\n'; + } + } + + inline std::string value::_serialize(int indent) const { + std::string s; + _serialize(std::back_inserter(s), indent); + return s; + } + + template class input { + protected: + Iter cur_, end_; + int last_ch_; + bool ungot_; + int line_; + public: + input(const Iter& first, const Iter& last) : cur_(first), end_(last), last_ch_(-1), ungot_(false), line_(1) {} + int getc() { + if (ungot_) { + ungot_ = false; + return last_ch_; + } + if (cur_ == end_) { + last_ch_ = -1; + return -1; + } + if (last_ch_ == '\n') { + line_++; + } + last_ch_ = *cur_ & 0xff; + ++cur_; + return last_ch_; + } + void ungetc() { + if (last_ch_ != -1) { + PICOJSON_ASSERT(! ungot_); + ungot_ = true; + } + } + Iter cur() const { return cur_; } + int line() const { return line_; } + void skip_ws() { + while (1) { + int ch = getc(); + if (! (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r')) { + ungetc(); + break; + } + } + } + bool expect(int expect) { + skip_ws(); + if (getc() != expect) { + ungetc(); + return false; + } + return true; + } + bool match(const std::string& pattern) { + for (std::string::const_iterator pi(pattern.begin()); + pi != pattern.end(); + ++pi) { + if (getc() != *pi) { + ungetc(); + return false; + } + } + return true; + } + }; + + template inline int _parse_quadhex(input &in) { + int uni_ch = 0, hex; + for (int i = 0; i < 4; i++) { + if ((hex = in.getc()) == -1) { + return -1; + } + if ('0' <= hex && hex <= '9') { + hex -= '0'; + } else if ('A' <= hex && hex <= 'F') { + hex -= 'A' - 0xa; + } else if ('a' <= hex && hex <= 'f') { + hex -= 'a' - 0xa; + } else { + in.ungetc(); + return -1; + } + uni_ch = uni_ch * 16 + hex; + } + return uni_ch; + } + + template inline bool _parse_codepoint(String& out, input& in) { + int uni_ch; + if ((uni_ch = _parse_quadhex(in)) == -1) { + return false; + } + if (0xd800 <= uni_ch && uni_ch <= 0xdfff) { + if (0xdc00 <= uni_ch) { + // a second 16-bit of a surrogate pair appeared + return false; + } + // first 16-bit of surrogate pair, get the next one + if (in.getc() != '\\' || in.getc() != 'u') { + in.ungetc(); + return false; + } + int second = _parse_quadhex(in); + if (! (0xdc00 <= second && second <= 0xdfff)) { + return false; + } + uni_ch = ((uni_ch - 0xd800) << 10) | ((second - 0xdc00) & 0x3ff); + uni_ch += 0x10000; + } + if (uni_ch < 0x80) { + out.push_back(uni_ch); + } else { + if (uni_ch < 0x800) { + out.push_back(0xc0 | (uni_ch >> 6)); + } else { + if (uni_ch < 0x10000) { + out.push_back(0xe0 | (uni_ch >> 12)); + } else { + out.push_back(0xf0 | (uni_ch >> 18)); + out.push_back(0x80 | ((uni_ch >> 12) & 0x3f)); + } + out.push_back(0x80 | ((uni_ch >> 6) & 0x3f)); + } + out.push_back(0x80 | (uni_ch & 0x3f)); + } + return true; + } + + template inline bool _parse_string(String& out, input& in) { + while (1) { + int ch = in.getc(); + if (ch < ' ') { + in.ungetc(); + return false; + } else if (ch == '"') { + return true; + } else if (ch == '\\') { + if ((ch = in.getc()) == -1) { + return false; + } + switch (ch) { +#define MAP(sym, val) case sym: out.push_back(val); break + MAP('"', '\"'); + MAP('\\', '\\'); + MAP('/', '/'); + MAP('b', '\b'); + MAP('f', '\f'); + MAP('n', '\n'); + MAP('r', '\r'); + MAP('t', '\t'); +#undef MAP + case 'u': + if (! _parse_codepoint(out, in)) { + return false; + } + break; + default: + return false; + } + } else { + out.push_back(ch); + } + } + return false; + } + + template inline bool _parse_array(Context& ctx, input& in) { + if (! ctx.parse_array_start()) { + return false; + } + size_t idx = 0; + if (in.expect(']')) { + return ctx.parse_array_stop(idx); + } + do { + if (! ctx.parse_array_item(in, idx)) { + return false; + } + idx++; + } while (in.expect(',')); + return in.expect(']') && ctx.parse_array_stop(idx); + } + + template inline bool _parse_object(Context& ctx, input& in) { + if (! ctx.parse_object_start()) { + return false; + } + if (in.expect('}')) { + return true; + } + do { + std::string key; + if (! in.expect('"') + || ! _parse_string(key, in) + || ! in.expect(':')) { + return false; + } + if (! ctx.parse_object_item(in, key)) { + return false; + } + } while (in.expect(',')); + return in.expect('}'); + } + + template inline std::string _parse_number(input& in) { + std::string num_str; + while (1) { + int ch = in.getc(); + if (('0' <= ch && ch <= '9') || ch == '+' || ch == '-' + || ch == 'e' || ch == 'E') { + num_str.push_back(ch); + } else if (ch == '.') { +#if PICOJSON_USE_LOCALE + num_str += localeconv()->decimal_point; +#else + num_str.push_back('.'); +#endif + } else { + in.ungetc(); + break; + } + } + return num_str; + } + + template inline bool _parse(Context& ctx, input& in) { + in.skip_ws(); + int ch = in.getc(); + switch (ch) { +#define IS(ch, text, op) case ch: \ + if (in.match(text) && op) { \ + return true; \ + } else { \ + return false; \ + } + IS('n', "ull", ctx.set_null()); + IS('f', "alse", ctx.set_bool(false)); + IS('t', "rue", ctx.set_bool(true)); +#undef IS + case '"': + return ctx.parse_string(in); + case '[': + return _parse_array(ctx, in); + case '{': + return _parse_object(ctx, in); + default: + if (('0' <= ch && ch <= '9') || ch == '-') { + double f; + char *endp; + in.ungetc(); + std::string num_str = _parse_number(in); + if (num_str.empty()) { + return false; + } +#ifdef PICOJSON_USE_INT64 + { + errno = 0; + intmax_t ival = strtoimax(num_str.c_str(), &endp, 10); + if (errno == 0 + && std::numeric_limits::min() <= ival + && ival <= std::numeric_limits::max() + && endp == num_str.c_str() + num_str.size()) { + ctx.set_int64(ival); + return true; + } + } +#endif + f = strtod(num_str.c_str(), &endp); + if (endp == num_str.c_str() + num_str.size()) { + ctx.set_number(f); + return true; + } + return false; + } + break; + } + in.ungetc(); + return false; + } + + class deny_parse_context { + public: + bool set_null() { return false; } + bool set_bool(bool) { return false; } +#ifdef PICOJSON_USE_INT64 + bool set_int64(int64_t) { return false; } +#endif + bool set_number(double) { return false; } + template bool parse_string(input&) { return false; } + bool parse_array_start() { return false; } + template bool parse_array_item(input&, size_t) { + return false; + } + bool parse_array_stop(size_t) { return false; } + bool parse_object_start() { return false; } + template bool parse_object_item(input&, const std::string&) { + return false; + } + }; + + class default_parse_context { + protected: + value* out_; + public: + default_parse_context(value* out) : out_(out) {} + bool set_null() { + *out_ = value(); + return true; + } + bool set_bool(bool b) { + *out_ = value(b); + return true; + } +#ifdef PICOJSON_USE_INT64 + bool set_int64(int64_t i) { + *out_ = value(i); + return true; + } +#endif + bool set_number(double f) { + *out_ = value(f); + return true; + } + template bool parse_string(input& in) { + *out_ = value(string_type, false); + return _parse_string(out_->get(), in); + } + bool parse_array_start() { + *out_ = value(array_type, false); + return true; + } + template bool parse_array_item(input& in, size_t) { + array& a = out_->get(); + a.push_back(value()); + default_parse_context ctx(&a.back()); + return _parse(ctx, in); + } + bool parse_array_stop(size_t) { return true; } + bool parse_object_start() { + *out_ = value(object_type, false); + return true; + } + template bool parse_object_item(input& in, const std::string& key) { + object& o = out_->get(); + default_parse_context ctx(&o[key]); + return _parse(ctx, in); + } + private: + default_parse_context(const default_parse_context&); + default_parse_context& operator=(const default_parse_context&); + }; + + class null_parse_context { + public: + struct dummy_str { + void push_back(int) {} + }; + public: + null_parse_context() {} + bool set_null() { return true; } + bool set_bool(bool) { return true; } +#ifdef PICOJSON_USE_INT64 + bool set_int64(int64_t) { return true; } +#endif + bool set_number(double) { return true; } + template bool parse_string(input& in) { + dummy_str s; + return _parse_string(s, in); + } + bool parse_array_start() { return true; } + template bool parse_array_item(input& in, size_t) { + return _parse(*this, in); + } + bool parse_array_stop(size_t) { return true; } + bool parse_object_start() { return true; } + template bool parse_object_item(input& in, const std::string&) { + return _parse(*this, in); + } + private: + null_parse_context(const null_parse_context&); + null_parse_context& operator=(const null_parse_context&); + }; + + // obsolete, use the version below + template inline std::string parse(value& out, Iter& pos, const Iter& last) { + std::string err; + pos = parse(out, pos, last, &err); + return err; + } + + template inline Iter _parse(Context& ctx, const Iter& first, const Iter& last, std::string* err) { + input in(first, last); + if (! _parse(ctx, in) && err != NULL) { + char buf[64]; + SNPRINTF(buf, sizeof(buf), "syntax error at line %d near: ", in.line()); + *err = buf; + while (1) { + int ch = in.getc(); + if (ch == -1 || ch == '\n') { + break; + } else if (ch >= ' ') { + err->push_back(ch); + } + } + } + return in.cur(); + } + + template inline Iter parse(value& out, const Iter& first, const Iter& last, std::string* err) { + default_parse_context ctx(&out); + return _parse(ctx, first, last, err); + } + + inline std::string parse(value& out, const std::string& s) { + std::string err; + parse(out, s.begin(), s.end(), &err); + return err; + } + + inline std::string parse(value& out, std::istream& is) { + std::string err; + parse(out, std::istreambuf_iterator(is.rdbuf()), + std::istreambuf_iterator(), &err); + return err; + } + + template struct last_error_t { + static std::string s; + }; + template std::string last_error_t::s; + + inline void set_last_error(const std::string& s) { + last_error_t::s = s; + } + + inline const std::string& get_last_error() { + return last_error_t::s; + } + + inline bool operator==(const value& x, const value& y) { + if (x.is()) + return y.is(); +#define PICOJSON_CMP(type) \ + if (x.is()) \ + return y.is() && x.get() == y.get() + PICOJSON_CMP(bool); + PICOJSON_CMP(double); + PICOJSON_CMP(std::string); + PICOJSON_CMP(array); + PICOJSON_CMP(object); +#undef PICOJSON_CMP + PICOJSON_ASSERT(0); +#ifdef _MSC_VER + __assume(0); +#endif + return false; + } + + inline bool operator!=(const value& x, const value& y) { + return ! (x == y); + } +} + +#if !PICOJSON_USE_RVALUE_REFERENCE +namespace std { + template<> inline void swap(picojson::value& x, picojson::value& y) + { + x.swap(y); + } +} +#endif + +inline std::istream& operator>>(std::istream& is, picojson::value& x) +{ + picojson::set_last_error(std::string()); + std::string err = picojson::parse(x, is); + if (! err.empty()) { + picojson::set_last_error(err); + is.setstate(std::ios::failbit); + } + return is; +} + +inline std::ostream& operator<<(std::ostream& os, const picojson::value& x) +{ + x.serialize(std::ostream_iterator(os)); + return os; +} +#ifdef _MSC_VER + #pragma warning(pop) +#endif + +#endif diff --git a/src/game/src/engine/core/GameLoopSystem.cpp b/src/game/src/engine/core/GameLoopSystem.cpp index 3716788afcde244eceaff1eaa357a8d3fe72b3fb..0875495a7c14d0dc4581d89b0d67577eed6356e9 100644 --- a/src/game/src/engine/core/GameLoopSystem.cpp +++ b/src/game/src/engine/core/GameLoopSystem.cpp @@ -13,11 +13,14 @@ #include bool GameLoopSystem::startup() { + RESOLVE_DEPENDENCY(m_settings); RESOLVE_DEPENDENCY(m_events); RESOLVE_DEPENDENCY(m_window); RESOLVE_DEPENDENCY(m_renderer); RESOLVE_DEPENDENCY(m_audio); + m_targetFrameRate = m_settings->getTargetFps(); + m_events->subscribe<"DrawUI"_sh>([this] { static bool opened = true; ImGui::SetNextWindowPos(ImVec2(10, 10)); diff --git a/src/game/src/engine/core/SettingsSystem.cpp b/src/game/src/engine/core/SettingsSystem.cpp index a9e29cce457c4520ad05a2a2ed0d4d358cbc8161..5b83e48a778736608b21efe6bf838331ec52dd3a 100644 --- a/src/game/src/engine/core/SettingsSystem.cpp +++ b/src/game/src/engine/core/SettingsSystem.cpp @@ -2,14 +2,128 @@ #include #include +#define PICOJSON_USE_INT64 +#include + +#include + + using namespace ACGL::Base; +std::string getDirectory(std::string filename) { + size_t found; + found = filename.find_last_of("/\\"); + return filename.substr(0, found); +} + bool SettingsSystem::startup() { Settings::the()->setResourcePath(m_resourcePath); Settings::the()->setTexturePath(m_texturePath); Settings::the()->setGeometryPath(m_geometryPath); Settings::the()->setShaderPath(m_shaderPath); + + std::ifstream configFile(m_resourcePath + m_configFilePath); + + if (!configFile.is_open()) { + std::cerr << "Could not open config file " << m_configFilePath << "!" << std::endl; + return false; + } + + picojson::value config; + configFile >> config; + + if (!config.is()) { + std::cerr << "Could not read config file " << m_configFilePath << "!" << std::endl; + return false; + } + + const picojson::object& o = config.get(); + + m_availablePlanets = { }; + m_resolution = { 1280, 720 }; + m_qualitySetting = QualitySetting::High; + m_fullscreen = false; + m_targetFps = 60; + m_defaultScene = "AtmosphereTest"; + +#define VALIDATE_TYPE(p, type) if(!p.second.is()) { std::cout << "Warning: Setting \"" << i.first << "\": " << i.second << " is not of expected type " #type "." << std::endl; continue; } + + for (auto& i : o) { + if (i.first == "available_planet_prefabs") { + VALIDATE_TYPE(i, picojson::array); + const picojson::array& planets = i.second.get(); + m_availablePlanets.clear(); + for (auto& planet : planets) { + + auto planetName = planet.get(); + std::string fullPath = m_resourcePath + getDirectory(m_configFilePath) + "/planets/" + planetName + ".json"; + std::ifstream planetFile(fullPath); + + if (!planetFile.is_open()) { + std::cerr << "Could not open planet file " << fullPath << "!" << std::endl; + continue; + } + + picojson::value planetVal; + planetFile >> planetVal; + + if (!planetVal.is()) { + std::cerr << "Could not read planet file " << fullPath << "!" << std::endl; + return false; + } + + const picojson::object& planetObj = planetVal.get(); + + + PlanetMetaData planet; + planet.name = planetName; + for (auto& prop : planetObj) { + if (prop.first == "shaders") { + VALIDATE_TYPE(prop, std::string); + planet.shaders = prop.second.get(); + } else if (prop.first == "atmopshere") { + VALIDATE_TYPE(prop, bool); + planet.hasAtmosphere = prop.second.get(); + } else if (prop.first == "water") { + VALIDATE_TYPE(prop, bool); + planet.hasWater = prop.second.get(); + } else if (prop.first == "moons") { + VALIDATE_TYPE(prop, int64_t); + planet.moonCount = prop.second.get(); + } + } + + m_availablePlanets.push_back(planet); + } + } else if(i.first == "resolution") { + VALIDATE_TYPE(i, picojson::array); + const picojson::array& res = i.second.get(); + m_resolution.x = res[0].get(); + m_resolution.y = res[1].get(); + } else if (i.first == "fullscreen") { + VALIDATE_TYPE(i, bool); + m_fullscreen = i.second.get(); + } else if (i.first == "target_fps") { + VALIDATE_TYPE(i, int64_t); + m_targetFps = i.second.get(); + } else if (i.first == "quality") { + VALIDATE_TYPE(i, std::string); + auto setting = i.second.get(); + + if (setting == "low") m_qualitySetting = QualitySetting::Low; + else if (setting == "medium") m_qualitySetting = QualitySetting::Medium; + else if (setting == "high") m_qualitySetting = QualitySetting::High; + + } else if (i.first == "scene") { + VALIDATE_TYPE(i, std::string); + m_defaultScene = i.second.get(); + } else { + std::cout << "Warning: Unknown setting \"" << i.first << "\"." << std::endl; + } + } +#undef VALIDATE_TYPE + return true; } diff --git a/src/game/src/engine/core/WindowSystem.cpp b/src/game/src/engine/core/WindowSystem.cpp index 79f756bf003de74767fe6e6fab8451a501bc46f9..190bfb65395a97e24e714eff3cf28694ffc65038 100644 --- a/src/game/src/engine/core/WindowSystem.cpp +++ b/src/game/src/engine/core/WindowSystem.cpp @@ -85,7 +85,7 @@ bool WindowSystem::createWindow() { // request an OpenGL debug context: m_sdlWindow = SDL_CreateWindow( "Edge of Space", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, - m_windowSize.x, m_windowSize.y, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN); + m_windowSize.x, m_windowSize.y, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | (m_fullscreen & SDL_WINDOW_FULLSCREEN)); if (!m_sdlWindow) { error() << "Failed to open a SDL window - requested OpenGL: " @@ -139,6 +139,10 @@ bool WindowSystem::createWindow() { } bool WindowSystem::startup() { + RESOLVE_DEPENDENCY(m_settings); + m_fullscreen = m_settings->getFullscreen(); + m_windowSize = m_settings->getResolution(); + ///////////////////////////////////////////////////////////////////////////////////// // Create OpenGL capable window: if (!createWindow()) { diff --git a/src/game/src/engine/scene/OrbitalSimulationSystem.cpp b/src/game/src/engine/scene/OrbitalSimulationSystem.cpp index 2d15bdd4c2d7b34dcf267866c48e4d829dda84e4..7738cc3f47690d25e2ee3d569cf75998bc881d7a 100644 --- a/src/game/src/engine/scene/OrbitalSimulationSystem.cpp +++ b/src/game/src/engine/scene/OrbitalSimulationSystem.cpp @@ -23,7 +23,10 @@ #include +#include + bool OrbitalSimulationSystem::startup() { + RESOLVE_DEPENDENCY(m_settings); RESOLVE_DEPENDENCY(m_events); RESOLVE_DEPENDENCY(m_scene); RESOLVE_DEPENDENCY(m_renderer); @@ -64,19 +67,27 @@ bool OrbitalSimulationSystem::startup() { .attributeLocations(playerIconGeometry.vao->getAttributeLocations()) .fragmentDataLocations(m_renderer->getGBufferLocations())); -// auto dispMappingShader = ShaderProgramFileManager::the()->get(ShaderProgramCreator("DispMapping") -// .attributeLocations(m_renderer->m_transformFeedbackVAO->getAttributeLocations()) -// .fragmentDataLocations(m_renderer->getGBufferLocations())); - auto earthShader = ShaderProgramFileManager::the()->get(ShaderProgramCreator("planets/earth") - .attributeLocations(m_renderer->m_transformFeedbackVAO->getAttributeLocations()) - .fragmentDataLocations(m_renderer->getGBufferLocations())); + auto planets = m_settings->getAvailablePlanets(); - auto jupiterShader = ShaderProgramFileManager::the()->get(ShaderProgramCreator("planets/jupiter") - .attributeLocations(m_renderer->m_transformFeedbackVAO->getAttributeLocations()) - .fragmentDataLocations(m_renderer->getGBufferLocations())); + for (auto planet : planets) { + auto planetShader = ShaderProgramFileManager::the()->get( + ShaderProgramCreator(planet.shaders + "/" + planet.name) + .attributeLocations( + m_renderer->m_transformFeedbackVAO->getAttributeLocations()) + .fragmentDataLocations(m_renderer->getGBufferLocations())); - auto moonShader = ShaderProgramFileManager::the()->get(ShaderProgramCreator("planets/moon") + planetMaterials[planet.name] = {glm::vec4(1, 1, 1, 1), + glm::vec4(0, 0, 0, 1), + texture, + nullptr, + nullptr, + planetShader, + 1, + RenderQueue::OPAQUE}; + } + + auto moonShader = ShaderProgramFileManager::the()->get(ShaderProgramCreator("planets/moon/moon") .attributeLocations(m_renderer->m_transformFeedbackVAO->getAttributeLocations()) .fragmentDataLocations(m_renderer->getGBufferLocations())); @@ -88,33 +99,6 @@ bool OrbitalSimulationSystem::startup() { .attributeLocations(m_renderer->m_transformFeedbackVAO->getAttributeLocations()) .fragmentDataLocations(m_renderer->getGBufferLocations())); -// planetMat = {glm::vec4(1, 1, 1, 1), -// glm::vec4(0, 0, 0, 1), -// texture, -// nullptr, -// nullptr, -// dispMappingShader, -// 1, -// RenderQueue::OPAQUE}; - - earthMat = {glm::vec4(1, 1, 1, 1), - glm::vec4(0, 0, 0, 1), - texture, - nullptr, - nullptr, - earthShader, - 1, - RenderQueue::OPAQUE}; - - jupiterMat = {glm::vec4(1, 1, 1, 1), - glm::vec4(0, 0, 0, 1), - texture, - nullptr, - nullptr, - jupiterShader, - 1, - RenderQueue::OPAQUE}; - moonMat = {glm::vec4(1, 1, 1, 1), glm::vec4(0, 0, 0, 1), texture, @@ -460,14 +444,14 @@ computeInscatteringTexture(GLubyte* transmittance, const int VIEW_SUN_LAYERS = 8; const int PIXELS_PER_SUN_LAYER = WIDTH / VIEW_SUN_LAYERS; - auto inscattering = new GLubyte[WIDTH * HEIGHT * DEPTH * 4]; + auto inscattering = new float[WIDTH * HEIGHT * DEPTH * 4]; SharedTextureData inscatteringData = std::make_shared(); inscatteringData->setWidth(WIDTH); inscatteringData->setHeight(HEIGHT); inscatteringData->setDepth(DEPTH); - inscatteringData->setData(inscattering); + inscatteringData->setData((GLubyte*)inscattering); inscatteringData->setFormat(GL_RGBA); - inscatteringData->setType(GL_UNSIGNED_BYTE); + inscatteringData->setType(GL_FLOAT); double Rg = planetRadius; double Rt = atmosphereRadius; @@ -521,13 +505,10 @@ computeInscatteringTexture(GLubyte* transmittance, glm::vec4(inscatter(transmittance, r, mu, muS, nu, planetRadius, atmosphereRadius, atmosphereRadius + 100, 8000, 1200, constBetaRayleigh, constBetaMie)); - - val = glm::clamp(val, 0, 1); - - pixel[0] = (GLubyte)(val.r * 255); - pixel[1] = (GLubyte)(val.g * 255); - pixel[2] = (GLubyte)(val.b * 255); - pixel[3] = (GLubyte)(val.a * 255); + pixel[0] = val.r; + pixel[1] = val.g; + pixel[2] = val.b; + pixel[3] = val.a; pixel += 4; } } @@ -610,9 +591,9 @@ Entity OrbitalSimulationSystem::addPlanet(Transform::Handle sun, std::string n, planetTransform->position = pos; if (isEarthlike) { - planetEntity.assign(defaultGeom, earthMat, 2, m_renderer->getRenderPassId("Main"_sh)); + planetEntity.assign(defaultGeom, planetMaterials["earth"], 2, m_renderer->getRenderPassId("Main"_sh)); } else { - planetEntity.assign(defaultGeom, jupiterMat, 2, m_renderer->getRenderPassId("Main"_sh)); + planetEntity.assign(defaultGeom, planetMaterials["jupiter"], 2, m_renderer->getRenderPassId("Main"_sh)); } diff --git a/src/game/src/main.cpp b/src/game/src/main.cpp index 8e89d459eade94b92a65060ac1b521832dc7d764..589b77cd4ac15a6238efdd9c57a8ea0d3d2a328c 100644 --- a/src/game/src/main.cpp +++ b/src/game/src/main.cpp @@ -16,11 +16,11 @@ #include #include -static std::unique_ptr createScene(std::string sceneType, std::string sceneIni, Context* context) { +static std::unique_ptr createScene(std::string sceneType, Context* context) { if (sceneType == "Orbits") { -return std::make_unique(context, sceneIni); +return std::make_unique(context, ""); } else if (sceneType == "AtmosphereTest") { -return std::make_unique(context, sceneIni); +return std::make_unique(context, ""); } // Add your scenes here else { @@ -30,19 +30,19 @@ return std::make_unique(context, sceneIni); int main(int argc, char *argv[]) { - - if (argc != 3) { - std::cout << "Usage: " << std::endl; + + if (argc != 2) { + std::cout << "Usage: " << std::endl; return -1; } - + // Set up the systems we want to use. // They depends on each other so we need to add them to the context in the right order // This also makes sure that dependencies are initialized before things that depend on them // If you try to initialize a system before it's dependencies you'll get an error message in the console Context context; - WindowSystem window(&context, 1280, 720); - SettingsSystem settings(&context, "data/", "textures/", "geometry/", "shader/", "sound/"); + SettingsSystem settings(&context, "data/", "textures/", "geometry/", "shader/", "sound/", argv[1]); + WindowSystem window(&context, 1280, 720, false); EventSystem events(&context); RendererSystem renderer(&context); SceneGraphSystem sceneGraph(&context); @@ -52,8 +52,6 @@ int main(int argc, char *argv[]) { OrbitalSimulationSystem orbitals(&context); PlayerSystem player(&context); // Should be the last one - auto scene = createScene(argv[1], argv[2], &context); - // Call the startup functions of the systems above in the order they are listed. // This means it's safe to access other systems in a startup function as long // as you depend on them @@ -62,6 +60,9 @@ int main(int argc, char *argv[]) { << std::endl; return -1; } + + auto scene = createScene(settings.getDefaultScene(), &context); + scene->startup(); // Kickoff the gameloop // This is what actually runs the game