From 739c1b6d8e19ac995baffbb01e9bd6ff0e12d661 Mon Sep 17 00:00:00 2001 From: Moroz Michael <47035925+MichaelMoroz@users.noreply.github.com> Date: Tue, 27 Aug 2019 03:08:49 +0300 Subject: [PATCH] Added level editor features --- .../shaders/compute/distance_estimators.glsl | 2 +- src/Camera.h | 2 +- src/Overlays.cpp | 27 ++++++++++++------- src/Scene.cpp | 4 +-- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/game_folder/shaders/compute/distance_estimators.glsl b/game_folder/shaders/compute/distance_estimators.glsl index c4e7b042..93d0a896 100644 --- a/game_folder/shaders/compute/distance_estimators.glsl +++ b/game_folder/shaders/compute/distance_estimators.glsl @@ -10,7 +10,7 @@ uniform vec3 iMarblePos; uniform float iMarbleRad; uniform float iFlagScale; uniform vec3 iFlagPos; -#define FRACTAL_ITER 16 +uniform int FRACTAL_ITER; ///Original MM distance estimators diff --git a/src/Camera.h b/src/Camera.h index 2e3f2007..d7247b1a 100644 --- a/src/Camera.h +++ b/src/Camera.h @@ -38,7 +38,7 @@ class Camera }; Camera(): alpha(0), beta(0), gamma(0), cur_mode(Free), radius(1.f), - smooth(0.3f), FOV(75.f), focus(1e10), bokeh(0), mblur(0.01), speckle(10), size(0), exposure(1.0f), bloomintensity(0.2), bloomtreshold(3), bloomradius(2) + smooth(0.3f), FOV(75.f), focus(1e10), bokeh(0), mblur(0.01), speckle(10), size(0), exposure(1.0f), bloomintensity(0.12), bloomtreshold(2.7), bloomradius(3) { //camera directions dirx = quat(0, 1, 0, 0); diff --git a/src/Overlays.cpp b/src/Overlays.cpp index 161a57ee..e61b5728 100644 --- a/src/Overlays.cpp +++ b/src/Overlays.cpp @@ -493,19 +493,26 @@ void Overlays::SetAntTweakBar(int Width, int Height, float &fps, Scene *scene, R TwAddVarRW(level_editor, "Sun color", TW_TYPE_DIR3F, copy->light_col.data(), "group='Level parameters'"); TwAddVarRW(level_editor, "Background color", TW_TYPE_DIR3F, copy->background_col.data(), "group='Level parameters'"); TwAddVarRW(level_editor, "Gravity strenght", TW_TYPE_FLOAT, ©->gravity, "min=0 max=0.5 step=0.0001 group='Level parameters'"); + TwAddVarRW(level_editor, "Level restart y position", TW_TYPE_FLOAT, ©->kill_y, "min=-100 max=100 step=0.1 group='Level parameters'"); + TwAddVarRW(level_editor, "Is planet", TW_TYPE_BOOLCPP, ©->planet, "group='Level parameters'"); + TwAddVarRW(level_editor, "Starting look direction angle", TW_TYPE_FLOAT, ©->start_look_x, "min=-3.14159 max=3.14159 step=0.01 group='Level parameters'"); + fractal_editor = TwNewBar("FractalEditor"); - TwAddVarRW(fractal_editor, "PBR roughness", TW_TYPE_FLOAT, ©->PBR_roughness, "min=0 max=1 step=0.001 "); - TwAddVarRW(fractal_editor, "PBR metallic", TW_TYPE_FLOAT, ©->PBR_metal, "min=0 max=1 step=0.001"); + TwAddVarRW(fractal_editor, "PBR roughness", TW_TYPE_FLOAT, ©->PBR_roughness, "min=0 max=1 step=0.001 group='Fractal Material'"); + TwAddVarRW(fractal_editor, "PBR metallic", TW_TYPE_FLOAT, ©->PBR_metal, "min=0 max=1 step=0.001 group='Fractal Material'"); float *p = copy->params.data(); - TwAddVarRW(fractal_editor, "Fractal Iterations", TW_TYPE_INT32, ©->FractalIter, "min=1 max=20 step=1"); - TwAddVarRW(fractal_editor, "Fractal Scale", TW_TYPE_FLOAT, p, "min=0 max=5 step=0.0001"); - TwAddVarRW(fractal_editor, "Fractal Angle1", TW_TYPE_FLOAT, p + 1, "min=-10 max=10 step=0.0001 "); - TwAddVarRW(fractal_editor, "Fractal Angle2", TW_TYPE_FLOAT, p + 2, "min=-10 max=10 step=0.0001 "); - TwAddVarRW(fractal_editor, "Fractal Shift", TW_TYPE_DIR3F, p + 3, ""); - TwAddVarRW(fractal_editor, "Fractal Color", TW_TYPE_DIR3F, p + 6, ""); - - //TwAddButton(stats, "Info1.1", NULL, NULL, string); + TwAddVarRW(fractal_editor, "Fractal Iterations", TW_TYPE_INT32, ©->FractalIter, "min=1 max=20 step=1 group='Fractal Coefficients'"); + TwAddVarRW(fractal_editor, "Fractal Scale", TW_TYPE_FLOAT, p, "min=0 max=5 step=0.0001 group='Fractal Coefficients'"); + TwAddVarRW(fractal_editor, "Fractal Angle1", TW_TYPE_FLOAT, p + 1, "min=-10 max=10 step=0.0001 group='Fractal Coefficients'"); + TwAddVarRW(fractal_editor, "Fractal Angle2", TW_TYPE_FLOAT, p + 2, "min=-10 max=10 step=0.0001 group='Fractal Coefficients'"); + TwAddVarRW(fractal_editor, "Fractal Shift", TW_TYPE_DIR3F, p + 3, "group='Fractal Coefficients'"); + TwAddVarRW(fractal_editor, "Fractal Color", TW_TYPE_DIR3F, p + 6, "group='Fractal Coefficients'"); + + TwAddVarRW(fractal_editor, "Fractal Animation1", TW_TYPE_FLOAT, ©->anim_1, "min=0 max=0.5 step=0.0001 group='Fractal Animation'"); + TwAddVarRW(fractal_editor, "Fractal Animation2", TW_TYPE_FLOAT, ©->anim_2, "min=0 max=0.5 step=0.0001 group='Fractal Animation'"); + TwAddVarRW(fractal_editor, "Fractal Animation3", TW_TYPE_FLOAT, ©->anim_3, "min=0 max=0.5 step=0.0001 group='Fractal Animation'"); + confirmation_box = TwNewBar("confirm"); diff --git a/src/Scene.cpp b/src/Scene.cpp index 69fe09ba..00b02871 100644 --- a/src/Scene.cpp +++ b/src/Scene.cpp @@ -756,7 +756,7 @@ void Scene::Write(sf::Shader& shader) const { shader.setUniform("SHADOWS_ENABLED", Shadows_Enabled); shader.setUniform("CAMERA_SIZE", camera_size*level_copy.marble_rad/0.035f); - shader.setUniform("FRACTAL_ITER", Fractal_Iterations); + shader.setUniform("FRACTAL_ITER", level_copy.FractalIter); shader.setUniform("REFL_REFR_ENABLED", Refl_Refr_Enabled); shader.setUniform("MARBLE_MODE", MarbleType); } @@ -836,7 +836,7 @@ void Scene::WriteShader(ComputeShader& shader) shader.setUniform("SHADOWS_ENABLED", Shadows_Enabled); shader.setUniform("CAMERA_SIZE", camera_size*level_copy.marble_rad / 0.035f); - shader.setUniform("FRACTAL_ITER", Fractal_Iterations); + shader.setUniform("FRACTAL_ITER", level_copy.FractalIter); shader.setUniform("REFL_REFR_ENABLED", Refl_Refr_Enabled); shader.setUniform("MARBLE_MODE", MarbleType); }