Commit 29478ae8 authored by unknown's avatar unknown
Browse files

Cleaned up the application properties.

parent 43325dcc
<settings>
<item name="fxaa">0</item>
<item name="window_size_x">1280</item>
<item name="window_size_y">720</item>
<item name="vsync">0</item>
<item name="msaa_samples">4</item>
<!-- Splash screen settings --/>
<item name="splash_image">/textures/splash.png</item>
<item name="splash_sound">/audio/swoosh.wav</item>
<item name="splash_background">0.1 0.4 0.7 1.0</item>
<item name="splash_duration">200</item>
<!-- General settings --/>
<item name="settings_window_title">GLARE Window</item>
<item name="settings_window_size_x">1280</item>
<item name="settings_window_size_y">720</item>
<item name="settings_vsync_mode">0</item>
<item name="settings_msaa_samples">4</item>
<!-- Pathtracer settings --/>
<item name="pathtrace_quality">0.4</item>
<item name="pathtrace_shadow_quality">0.04</item>
<item name="pathtrace_clamp_direct">8</item>
<item name="pathtrace_clamp_indirect">8</item>
<item name="pathtrace_bounces_diffuse">2</item>
<item name="pathtrace_bounces_translucent">4</item>
<item name="pathtrace_bounces_reflect">4</item>
<item name="pathtrace_bounces_refract">8</item>
<item name="pathtrace_bounces_transparent">8</item>
<item name="pathtrace_bounces_emissive">0</item>
<!-- Line Space settings --/>
<item name="linespace_max_resolution">16</item>
</settings>
\ No newline at end of file
......@@ -38,20 +38,28 @@ namespace glare
m_arguments = std::make_unique<io::Arguments>(argc, argv);
m_default_preferences = io::Resources::getInstance().getPreferences("default");
m_config.use_fxaa = m_default_preferences->get("fxaa", false);
m_config.vsync = VSyncMode(m_default_preferences->get("vsync", 0));
m_config.window_width = m_default_preferences->get("window_size_x", 1280u);
m_config.window_height = m_default_preferences->get("window_size_y", 720u);
m_config.sample_count = m_default_preferences->get("msaa_samples", 4);
core::EngineState::initialize(m_config.window_width, m_config.window_height, "GLARE Window");
m_config.window_width = m_default_preferences->get("settings_window_size_x", 1280u);
m_config.window_height = m_default_preferences->get("settings_window_size_y", 720u);
m_config.vsync = VSyncMode(m_default_preferences->get("settings_vsync_mode", 0));
m_config.sample_count = m_default_preferences->get("settings_msaa_samples", 4);
m_config.window_title = m_default_preferences->get<std::string>("settings_window_title", "GLARE");
auto splash_image = core::asset(m_default_preferences->get<std::string>("splash_image", ""));
auto splash_sound = core::asset(m_default_preferences->get<std::string>("splash_sound", ""));
auto splash_background = m_default_preferences->get("splash_background", Colors::White);
auto splash_duration = m_default_preferences->get("splash_duration", 200.f);
uint8_t effect_bounces_diffuse = m_default_preferences->get("pathtrace_bounces_diffuse", 2);
uint8_t effect_bounces_translucent = m_default_preferences->get("pathtrace_bounces_translucent", 4);
uint8_t effect_bounces_reflect = m_default_preferences->get("pathtrace_bounces_reflect", 4);
uint8_t effect_bounces_refract = m_default_preferences->get("pathtrace_bounces_refract", 8);
uint8_t effect_bounces_transparent = m_default_preferences->get("pathtrace_bounces_transparent", 8);
uint8_t effect_bounces_emissive = m_default_preferences->get("pathtrace_bounces_emissive", 0);
core::EngineState::initialize(m_config.window_width, m_config.window_height, m_config.window_title);
core::Callbacks::addKeyDownCallback("main_application", std::bind(&Application::onKeyDown, this, std::placeholders::_1, std::placeholders::_2));
auto dev = al::openDevice("");
auto cont = al::createContext(dev);
al::makeContextCurrent(cont);
core::SplashScreen splash_screen(core::asset("/textures/splash.png"), core::asset("/audio/swoosh.wav"), ColorUtilities::fromHex(0xff1A237E), 200);
core::SplashScreen splash_screen(splash_image, splash_sound, splash_background, splash_duration);
splash_screen.run();
m_current_scene_root = core::asset("/meshes/scenery/");
......@@ -65,14 +73,14 @@ namespace glare
//initializeScene(m_current_scene_root / "benchmark_suzanne_x1_diff.dae", 1.f);
//initializeScene(m_current_scene_root / "benchmark_suzanne_x2_diff.dae", 1.f);
//initializeScene(m_current_scene_root / "benchmark_teapot_diff.dae", 1.f);
//initializeScene(m_current_scene_root / "benchmark_stfd_bunny_diff.dae", 1.f);
initializeScene(m_current_scene_root / "benchmark_stfd_bunny_diff.dae", 1.f);
//initializeScene(m_current_scene_root / "benchmark_stfd_armadillo_diff.dae", 1.f);
//initializeScene(m_current_scene_root / "benchmark_stfd_dragon_diff.dae", 1.f);
//initializeScene(m_current_scene_root / "benchmark_stfd_asian_dragon_diff.dae", 1.f);
// ARTIFACT CHECK (GLASS)
//initializeScene(m_current_scene_root / "artifact_suzanne_x2_glass_0r.dae", 1.f);
initializeScene(m_current_scene_root / "artifact_suzanne_x2_glass_25r.dae", 1.f);
//initializeScene(m_current_scene_root / "artifact_suzanne_x2_glass_25r.dae", 1.f);
//initializeScene(m_current_scene_root / "artifact_suzanne_x2_glass_50r.dae", 1.f);
//initializeScene(m_current_scene_root / "artifact_suzanne_x2_glass_75r.dae", 1.f);
//initializeScene(m_current_scene_root / "artifact_suzanne_x2_glass_100r.dae", 1.f);
......@@ -88,11 +96,17 @@ namespace glare
//initializeScene(m_current_scene_root / "artifact_suzanne_x2_emissive.dae", 1.f);
//initializeScene(m_current_scene_root / "artifact_suzanne_x2_transparent.dae", 1.f);
// initializeScene(m_current_scene_root / "boxes.dae", 1.f);
//initializeScene(m_current_scene_root / "cornell_dragon.dae", 1.f);
initializeRenderRequirements();
initializeAdvanced();
initializeGUI();
m_raytracer->setEffectBounces(advanced::EffectType::eDiffuse, effect_bounces_diffuse);
m_raytracer->setEffectBounces(advanced::EffectType::eTranslucent, effect_bounces_translucent);
m_raytracer->setEffectBounces(advanced::EffectType::eReflection, effect_bounces_reflect);
m_raytracer->setEffectBounces(advanced::EffectType::eRefraction, effect_bounces_refract);
m_raytracer->setEffectBounces(advanced::EffectType::eTransparent, effect_bounces_transparent);
m_raytracer->setEffectBounces(advanced::EffectType::eEmissive, effect_bounces_emissive);
m_raytracer->setAccuracyThreshold(m_default_preferences->get<float>("pathtrace_quality", 0.5f));
m_raytracer->setShadowThreshold(m_default_preferences->get<float>("pathtrace_shadow_quality", 0.5f));
m_raytracer->setClampDirect(m_default_preferences->get<float>("pathtrace_clamp_direct", 8.f));
......@@ -153,9 +167,6 @@ namespace glare
ImGui::Render();
core::LightManager::getInstance().clear();
});
al::destroyContext(cont);
al::closeDevice(dev);
}
Application::~Application()
......
......@@ -72,11 +72,11 @@ namespace glare
struct
{
bool use_fxaa;
VSyncMode vsync;
unsigned window_width;
unsigned window_height;
unsigned sample_count;
std::string window_title;
} m_config;
};
......
......@@ -25,6 +25,13 @@ namespace glare
Raytracer::Raytracer(std::shared_ptr<SceneCollector> collector, std::shared_ptr<RayGeneratorBase> ray_generator)
{
m_bounce_count_thresholds[unsigned(EffectType::eDiffuse)] = 4;
m_bounce_count_thresholds[unsigned(EffectType::eTranslucent)] = 6;
m_bounce_count_thresholds[unsigned(EffectType::eReflection)] = 6;
m_bounce_count_thresholds[unsigned(EffectType::eRefraction)] = 12;
m_bounce_count_thresholds[unsigned(EffectType::eTransparent)] = 12;
m_bounce_count_thresholds[unsigned(EffectType::eEmissive)] = 0;
m_render_config.bounces = 8;
m_render_shader = core::ShaderProgram::makeUnique("/raytracer/pathtracer.compute");
m_ray_generator = ray_generator;
......@@ -39,6 +46,18 @@ namespace glare
}
void Raytracer::setEffectBounces(EffectType type, uint8_t bounces)
{
uint8_t clamped = bounces & 0xf;
if (clamped != bounces)
{
Log_Warn << bounces << " - value larger than 15 (0xf). Result of " << clamped << " may be unintended.";
}
m_bounce_count_thresholds[unsigned(type)] = clamped;
}
void Raytracer::reset()
{
m_render_config.current_sample = 0;
......@@ -98,13 +117,6 @@ namespace glare
m_render_shader->updateUniformFloat("u_linespace_properties.accuracy_quality", m_linespace_config.accuracy_threshold);
m_render_shader->updateUniformFloat("u_linespace_properties.shadow_quality", m_linespace_config.shadow_threshold);
m_bounce_count_thresholds[unsigned(EffectType::eDiffuse)] = 4;
m_bounce_count_thresholds[unsigned(EffectType::eTranslucent)] = 6;
m_bounce_count_thresholds[unsigned(EffectType::eReflection)] = 6;
m_bounce_count_thresholds[unsigned(EffectType::eRefraction)] = 12;
m_bounce_count_thresholds[unsigned(EffectType::eTransparent)] = 12;
m_bounce_count_thresholds[unsigned(EffectType::eEmissive)] = 0;
unsigned bounce_thresholds = 0;
for (int i = 0; i < 8; ++i)
......
......@@ -40,6 +40,8 @@ namespace glare
void saveRenderHDR(fs::path target) const;
void saveRender(fs::path target) const;
void setEffectBounces(EffectType type, uint8_t bounces);
//template<typename DataStruct>
void setGenerator(std::shared_ptr<RayGeneratorBase> generator);
void initialize(std::shared_ptr<SceneCollector> collector);
......
#include "AudioCore.h"
namespace glare
{
namespace core
{
AudioCore::AudioCore()
{
m_device = al::openDevice("");
m_context = al::createContext(m_device);
al::makeContextCurrent(m_context);
}
AudioCore::~AudioCore()
{
al::destroyContext(m_context);
al::closeDevice(m_device);
}
}
}
#ifndef __AUDIOCORE_H
#define __AUDIOCORE_H
#include <openal/OpenAL.h>
namespace glare
{
namespace core
{
class AudioCore
{
public:
AudioCore();
~AudioCore();
private:
al::device *m_device;
al::context *m_context;
};
}
}
#endif //__AUDIOCORE_H
......@@ -5,6 +5,7 @@ namespace glare
{
namespace core
{
std::shared_ptr<AudioCore> EngineState::audio_core;
std::shared_ptr<Camera> EngineState::main_camera;
std::shared_ptr<GLWrapper> EngineState::opengl_core;
std::shared_ptr<AnimationManager> EngineState::animation_manager = std::make_shared<AnimationManager>();
......@@ -13,6 +14,7 @@ namespace glare
{
opengl_core = std::make_shared<glare::core::GLWrapper>(width, height, title);
main_camera = std::make_shared<glare::core::Camera>(width, height, Camera::Projection::ePerspective);
audio_core = std::make_shared<AudioCore>();
Callbacks::initialize(opengl_core->getWindow());
}
......
......@@ -8,6 +8,7 @@
#include <map>
#include <filesystem>
#include "AudioCore.h"
#include "GLWrapper.h"
#include <control/Controls.h>
......@@ -29,6 +30,7 @@ namespace glare
static void quit();
static std::shared_ptr<AudioCore> audio_core;
static std::shared_ptr<Camera> main_camera;
static std::shared_ptr<GLWrapper> opengl_core;
static std::shared_ptr<AnimationManager> animation_manager;
......
......@@ -174,6 +174,7 @@ namespace glare
parsing_flags &= ~PARSER_TAG_TITLE_JUST_OPENED;
}
break;
case '!':
case '?':
if (parsing_flags & PARSER_IN_TAG)
{
......
......@@ -24,7 +24,7 @@ namespace glare
unsigned goodSubdivision(size_t polygon_count, glm::vec3 bounds_size)
{
return 4;// io::Resources::getInstance().getPreferences("default")->get<unsigned>("linespace_max_resolution", 16);// unsigned(2 * glm::ceil(glm::log2(glm::max(size_t(2), polygon_count)) * glm::log(log2((glm::compMax(bounds_size) / glm::compMin(bounds_size)) + 2 * glm::e<float>()))));
return io::Resources::getInstance().getPreferences("default")->get<unsigned>("linespace_max_resolution", 16);
}
}
......
......@@ -28,6 +28,9 @@ namespace glare
template<typename T>
T get(const std::string& preference, T default_value);
template<>
Color Preferences::get<Color>(const std::string &preference, Color default_value);
template<typename T>
void set(const std::string& preference, T value);
......@@ -57,6 +60,44 @@ namespace glare
return value;
}
inline Color decodeColor(const std::string &value)
{
Color c;
unsigned part = 0;
unsigned position = 0;
std::string c_val = "";
while (part < 4 && position < value.size())
{
const char current = value[position];
position++;
if (current == ' ')
{
c[part] = float(atof(c_val.c_str()));
part++;
c_val.clear();
continue;
}
c_val += current;
}
c[part] = float(atof(c_val.c_str()));
return c;
}
template<>
Color Preferences::get<Color>(const std::string &preference, Color default_value)
{
if (m_preferences.count(preference) == 0)
{
return default_value;
}
return decodeColor(m_preferences[preference]);
}
template <typename T>
void Preferences::set(const std::string& preference, T value)
{
......
Supports Markdown
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