From 971381b150a52e8a3f74c73b12e1d0bff391580c Mon Sep 17 00:00:00 2001 From: Michal Marcinkowski Date: Wed, 18 Feb 2015 19:41:56 -0500 Subject: [PATCH 1/2] fov lines, check. --- openspace-data | 2 +- openspace.cfg | 46 ----------- scripts/default_settings_michal.lua | 12 +++ scripts/default_startup.lua | 2 +- shaders/fov_fs.glsl | 56 +++++++++++++ shaders/fov_vs.glsl | 78 +++++++++++++++++++ src/rendering/planets/renderableplanet.cpp | 5 +- .../planets/renderableplanetprojection.cpp | 20 +++-- src/rendering/renderablefov.cpp | 2 +- src/rendering/renderengine.cpp | 2 +- src/scenegraph/scenegraph.cpp | 13 +++- 11 files changed, 176 insertions(+), 62 deletions(-) delete mode 100644 openspace.cfg create mode 100644 scripts/default_settings_michal.lua create mode 100644 shaders/fov_fs.glsl create mode 100644 shaders/fov_vs.glsl diff --git a/openspace-data b/openspace-data index 20780bb41e..5ebfcd98c2 160000 --- a/openspace-data +++ b/openspace-data @@ -1 +1 @@ -Subproject commit 20780bb41e4df4efc33f54f9f8ca5343bdc2f334 +Subproject commit 5ebfcd98c22cd48fce8e6bf9f0af635ba6a98b24 diff --git a/openspace.cfg b/openspace.cfg deleted file mode 100644 index fef3e199b0..0000000000 --- a/openspace.cfg +++ /dev/null @@ -1,46 +0,0 @@ -return { - Paths = { - SGCT = "${BASE_PATH}/config/sgct", - SCRIPTS = "${BASE_PATH}/scripts", - SHADERS = "${BASE_PATH}/shaders", - SHADERS_GENERATED = "${SHADERS}/generated", - OPENSPACE_DATA = "${BASE_PATH}/openspace-data", - TESTDIR = "${BASE_PATH}/src/tests", - CONFIG = "${BASE_PATH}/config", - CACHE = "${BASE_PATH}/cache", - FONTS = "${OPENSPACE_DATA}/fonts", - PLUTO_KERNELS = "${OPENSPACE_DATA}/spice/Pluto", - JP_KERNELS = "${OPENSPACE_DATA}/spice/JP_KERNELS" - }, - SpiceKernel = { - Time = "${OPENSPACE_DATA}/spice/naif0010.tls", - LeapSecond = "${OPENSPACE_DATA}/spice/pck00010.tpc", - NewHorizons = "${OPENSPACE_DATA}/spice/nhmeta.tm" - }, - Fonts = { - Mono = "${FONTS}/Droid_Sans_Mono/DroidSansMono.ttf", - Light = "${FONTS}/Roboto/Roboto-Regular.ttf" - }, - StartupScripts = { - "${SCRIPTS}/default_startup.lua" - }, - SettingsScripts = { - "${SCRIPTS}/default_settings.lua" - }, - Logging = { - LogLevel = "Debug", - ImmediateFlush = true, - Logs = { - { Type = "HTML", FileName = "${BASE_PATH}/log.html", Append = false } - } - }, - LuaDocumentationFile = { - Type = "text", - File = "${BASE_PATH}/LuaScripting.txt" - }, - SGCTConfig = "${SGCT}/single.xml", - --SGCTConfig = "${SGCT}/single_fisheye.xml", - --SGCTConfig = "${SGCT}/two_nodes.xml", - --SGCTConfig = "${SGCT}/single_sbs_stereo.xml", - Scene = "${OPENSPACE_DATA}/scene/default_michal.scene", -} \ No newline at end of file diff --git a/scripts/default_settings_michal.lua b/scripts/default_settings_michal.lua new file mode 100644 index 0000000000..7c5fa59a2e --- /dev/null +++ b/scripts/default_settings_michal.lua @@ -0,0 +1,12 @@ +openspace.printInfo("Setting default values"); +openspace.setPropertyValue("Constellation Bounds.renderable.enabled", false); + +openspace.setPropertyValue("Stars.renderable.magnitudeClamp", {0.941, 3.824}); +openspace.setPropertyValue("Stars.renderable.exponentialOffset", 6.180); +openspace.setPropertyValue("Stars.renderable.exponentialDampening", 0.838); +openspace.setPropertyValue("Stars.renderable.scaleFactor", 0.563); + +openspace.setPropertyValue("MilkyWay.renderable.transparency", 0.65); +openspace.setPropertyValue("MilkyWay.renderable.segments", 50); + +openspace.printInfo("Done setting default values"); \ No newline at end of file diff --git a/scripts/default_startup.lua b/scripts/default_startup.lua index 8d255f6e20..69c728b290 100644 --- a/scripts/default_startup.lua +++ b/scripts/default_startup.lua @@ -1,6 +1,6 @@ --openspace.setPropertyValue('Earth.renderable.colorTexture', '${OPENSPACE_DATA}/modules/mars/textures/mars.png') ---openspace.time.setTime("2015-07-14T10:50:00.00") -- PLUTO +openspace.time.setTime("2015-07-14T10:50:00.00") -- PLUTO -- NH takes series of images from visible to dark side (across terminator) -- Sequence lasts ~10 mins, (recommended dt = 10) diff --git a/shaders/fov_fs.glsl b/shaders/fov_fs.glsl new file mode 100644 index 0000000000..61631f3e77 --- /dev/null +++ b/shaders/fov_fs.glsl @@ -0,0 +1,56 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + +#version __CONTEXT__ + +uniform mat4 ViewProjection; +uniform mat4 ModelTransform; + +in vec4 vs_point_position; +in vec4 vs_point_velocity; + + +//out vec4 diffuse; + +#include "ABuffer/abufferStruct.hglsl" +#include "ABuffer/abufferAddToBuffer.hglsl" +#include "PowerScaling/powerScaling_fs.hglsl" + +void main() +{ + + vec4 position = vs_point_position; + float depth = pscDepth(position); + + // set the depth + //gl_FragDepth = depth; + + //float l = length(vs_point_velocity); + + vec4 diffuse = vs_point_velocity; + + ABufferStruct_t frag = createGeometryFragment(diffuse, position, depth); + addToBuffer(frag); + +} \ No newline at end of file diff --git a/shaders/fov_vs.glsl b/shaders/fov_vs.glsl new file mode 100644 index 0000000000..2f777b8528 --- /dev/null +++ b/shaders/fov_vs.glsl @@ -0,0 +1,78 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + +#version __CONTEXT__ + +uniform mat4 ViewProjection; +uniform mat4 ModelTransform; +//uniform vec4 etColor; +uniform vec4 objectVelocity; + +layout(location = 0) in vec4 in_point_position; +layout(location = 1) in vec4 in_point_velocity; +layout(location = 2) in vec2 in_point_timeindex; + + +out vec4 vs_point_position; +out vec4 vs_point_velocity; + +#include "PowerScaling/powerScaling_vs.hglsl" + +void main() +{ + vs_point_velocity = in_point_velocity; + + vec4 tmp = in_point_position; + vec4 position = pscTransform(tmp, ModelTransform); + vs_point_position = tmp; + position = ViewProjection * position; + gl_Position = z_normalization(position); +/* + //vs_point_position = objpos; + + // rotate and scale vertex with model transform and add the translation + vec3 local_vertex_pos = mat3(ModelTransform) * in_point_position.xyz; + //vec4 lvp = ModelTransform * in_point_position; + + // PSC addition; local vertex position and the object power scaled world position + vs_point_position = psc_addition(vec4(local_vertex_pos,in_point_position.w),objpos); + //vs_point_position = psc_addition(lvp,objpos); + + // PSC addition; rotated and viewscaled vertex and the cmaeras negative position + vs_point_position = psc_addition(vs_point_position,vec4(-campos.xyz,campos.w)); + + // rotate the camera + local_vertex_pos = mat3(camrot) * vs_point_position.xyz; + vs_point_position = vec4(local_vertex_pos, vs_point_position.w); + //vs_point_position = camrot* vs_point_position; + + // project using the rescaled coordinates, + //vec4 vs_point_position_rescaled = psc_scaling(vs_point_position, scaling); + vec4 vs_point_position_rescaled = psc_to_meter(vs_point_position, scaling); + //vs_point_position = vs_point_position_rescaled; + + // project the position to view space + gl_Position = ViewProjection * vs_point_position_rescaled; + */ +} \ No newline at end of file diff --git a/src/rendering/planets/renderableplanet.cpp b/src/rendering/planets/renderableplanet.cpp index cd1b43b733..4168893917 100644 --- a/src/rendering/planets/renderableplanet.cpp +++ b/src/rendering/planets/renderableplanet.cpp @@ -79,7 +79,7 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary) _geometry = planetgeometry::PlanetGeometry::createFromDictionary(geometryDictionary); } - dictionary.getValue(keyFrame, _target); + dictionary.getValue(keyFrame, _frame); bool b1 = dictionary.getValue(keyBody, _target); assert(b1 == true); @@ -170,9 +170,6 @@ void RenderablePlanet::render(const RenderData& data) // setup the data to the shader // _programObject->setUniform("camdir", camSpaceEye); - int shadows = (_target == "SUN") ? 0 : 1; - _programObject->setUniform("shadows", shadows); - _programObject->setUniform("sun_pos", sun_pos.vec3()); _programObject->setUniform("ViewProjection", data.camera.viewProjectionMatrix()); _programObject->setUniform("ModelTransform", transform); setPscUniforms(_programObject, &data.camera, data.position); diff --git a/src/rendering/planets/renderableplanetprojection.cpp b/src/rendering/planets/renderableplanetprojection.cpp index ed79420d7c..c2be6d57f2 100644 --- a/src/rendering/planets/renderableplanetprojection.cpp +++ b/src/rendering/planets/renderableplanetprojection.cpp @@ -27,6 +27,8 @@ #include #include +#include + #include //#include #include @@ -55,6 +57,12 @@ namespace { const std::string keyInstrumentFar = "Instrument.Far"; const std::string keySequenceDir = "Projection.Sequence"; + const std::string keyFrame = "Frame"; + const std::string keyGeometry = "Geometry"; + const std::string keyShading = "PerformShading"; + + const std::string keyBody = "Body"; + const std::string _mainFrame = "GALACTIC"; } namespace openspace { @@ -100,14 +108,14 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& ghoul::Dictionary geometryDictionary; success = dictionary.getValue( - constants::renderableplanet::keyGeometry, geometryDictionary); + keyGeometry, geometryDictionary); if (success) { geometryDictionary.setValue(constants::scenegraphnode::keyName, name); geometryDictionary.setValue(constants::scenegraph::keyPathModule, path); _geometry = planetgeometryprojection::PlanetGeometryProjection::createFromDictionary(geometryDictionary); } - dictionary.getValue(constants::renderableplanet::keyFrame, _target); + dictionary.getValue(keyFrame, _target); // TODO: textures need to be replaced by a good system similar to the geometry as soon // as the requirements are fixed (ab) @@ -136,8 +144,8 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& bool loaded = openspace::ImageSequencer::ref().loadSequence(_sequenceDir); if (!loaded) LDEBUG(name + " did not load sequence " + _sequenceDir + " check mod file path"); */ - //openspace::ImageSequencer::ref().parsePlaybook("C:/Users/michal/playbook", "txt"); - openspace::ImageSequencer::ref().parsePlaybook("C:/Users/joaki56/Desktop/ProjectionsOfInterest/playbook", "txt"); + openspace::ImageSequencer::ref().parsePlaybook("C:/Users/michal/playbook", "txt"); + //openspace::ImageSequencer::ref().parsePlaybook("C:/Users/joaki56/Desktop/ProjectionsOfInterest/playbook", "txt"); } } @@ -150,11 +158,11 @@ bool RenderablePlanetProjection::initialize(){ bool completeSuccess = true; if (_programObject == nullptr) completeSuccess - &= OsEng.ref().configurationManager().getValue("projectiveProgram", _programObject); + &= OsEng.ref().configurationManager()->getValue("projectiveProgram", _programObject); if (_fboProgramObject == nullptr) completeSuccess - &= OsEng.ref().configurationManager().getValue("fboPassProgram", _fboProgramObject); + &= OsEng.ref().configurationManager()->getValue("fboPassProgram", _fboProgramObject); loadTexture(); loadProjectionTexture(); diff --git a/src/rendering/renderablefov.cpp b/src/rendering/renderablefov.cpp index f8781ad157..cdae844dc6 100644 --- a/src/rendering/renderablefov.cpp +++ b/src/rendering/renderablefov.cpp @@ -122,7 +122,7 @@ RenderableFov::~RenderableFov(){ bool RenderableFov::initialize(){ bool completeSuccess = true; if (_programObject == nullptr) - completeSuccess &= OsEng.ref().configurationManager().getValue("EphemerisProgram", _programObject); + completeSuccess &= OsEng.ref().configurationManager()->getValue("FovProgram", _programObject); allocateData(); sendToGPU(); diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index 85e56c3261..1aab790e90 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -435,7 +435,7 @@ namespace openspace { // GUI PRINT // Using a macro to shorten line length and increase readability -#define PrintText(i, format, size, ...) Freetype::print(font, size, static_cast(startY - font_size_mono * i * 2), format, __VA_ARGS__); +#define PrintText(i, format, ...) Freetype::print(font, 10, static_cast(startY - font_size_mono * i * 2), format, __VA_ARGS__); #define PrintColorText(i, format, size, color, ...) Freetype::print(font, size, static_cast(startY - font_size_mono * i * 2), color, format, __VA_ARGS__); int i = 0; diff --git a/src/scenegraph/scenegraph.cpp b/src/scenegraph/scenegraph.cpp index b49f065e11..b4c485de26 100644 --- a/src/scenegraph/scenegraph.cpp +++ b/src/scenegraph/scenegraph.cpp @@ -172,7 +172,7 @@ bool SceneGraph::initialize() if (!tmpProgram) return false; tmpProgram->setProgramObjectCallback(cb); _programs.push_back(tmpProgram); - OsEng.ref().configurationManager().setValue("fboPassProgram", tmpProgram); + OsEng.ref().configurationManager()->setValue("fboPassProgram", tmpProgram); // projection program tmpProgram = ProgramObject::Build("projectiveProgram", @@ -181,7 +181,7 @@ bool SceneGraph::initialize() if (!tmpProgram) return false; tmpProgram->setProgramObjectCallback(cb); _programs.push_back(tmpProgram); - OsEng.ref().configurationManager().setValue("projectiveProgram", tmpProgram); + OsEng.ref().configurationManager()->setValue("projectiveProgram", tmpProgram); // pscstandard tmpProgram = ProgramObject::Build("pscstandard", @@ -193,6 +193,15 @@ bool SceneGraph::initialize() _programs.push_back(tmpProgram); OsEng.ref().configurationManager()->setValue("pscShader", tmpProgram); + // pscstandard + tmpProgram = ProgramObject::Build("FovProgram", + "${SHADERS}/fov_vs.glsl", + "${SHADERS}/fov_fs.glsl"); + if (!tmpProgram) return false; + tmpProgram->setProgramObjectCallback(cb); + _programs.push_back(tmpProgram); + OsEng.ref().configurationManager()->setValue("FovProgram", tmpProgram); + // RaycastProgram tmpProgram = ProgramObject::Build("RaycastProgram", "${SHADERS}/exitpoints.vert", From 88c976e16e3f6033028d1f03ff403c877391bb35 Mon Sep 17 00:00:00 2001 From: Michal Marcinkowski Date: Wed, 18 Feb 2015 19:51:57 -0500 Subject: [PATCH 2/2] progress indicator back. --- src/rendering/renderengine.cpp | 43 ++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index 1aab790e90..5bfaf2a3ec 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -435,19 +435,42 @@ namespace openspace { // GUI PRINT // Using a macro to shorten line length and increase readability -#define PrintText(i, format, ...) Freetype::print(font, 10, static_cast(startY - font_size_mono * i * 2), format, __VA_ARGS__); +#define PrintText(i, format, size, ...) Freetype::print(font, size, static_cast(startY - font_size_mono * i * 2), format, __VA_ARGS__); #define PrintColorText(i, format, size, color, ...) Freetype::print(font, size, static_cast(startY - font_size_mono * i * 2), color, format, __VA_ARGS__); + int i = 0; - PrintText(i++, "Date: %s", Time::ref().currentTimeUTC().c_str()); - PrintText(i++, "Avg. Frametime: %.5f", sgct::Engine::instance()->getAvgDt()); - PrintText(i++, "Drawtime: %.5f", sgct::Engine::instance()->getDrawTime()); - PrintText(i++, "Frametime: %.5f", sgct::Engine::instance()->getDt()); - PrintText(i++, "Origin: (% .5f, % .5f, % .5f, % .5f)", origin[0], origin[1], origin[2], origin[3]); - PrintText(i++, "Cam pos: (% .5f, % .5f, % .5f, % .5f)", position[0], position[1], position[2], position[3]); - PrintText(i++, "View dir: (% .5f, % .5f, % .5f)", viewdirection[0], viewdirection[1], viewdirection[2]); - PrintText(i++, "Cam->origin: (% .15f, % .4f)", pssl[0], pssl[1]); - PrintText(i++, "Scaling: (% .5f, % .5f)", scaling[0], scaling[1]); + + PrintText(i++, "Date: %s", 20, Time::ref().currentTimeUTC().c_str()); + PrintText(i++, "Avg. Frametime: %.5f", 10, sgct::Engine::instance()->getAvgDt()); + PrintText(i++, "Drawtime: %.5f", 10, sgct::Engine::instance()->getDrawTime()); + PrintText(i++, "Frametime: %.5f", 10, sgct::Engine::instance()->getDt()); + PrintText(i++, "Origin: (% .5f, % .5f, % .5f, % .5f)", 10, origin[0], origin[1], origin[2], origin[3]); + PrintText(i++, "Cam pos: (% .5f, % .5f, % .5f, % .5f)", 10, position[0], position[1], position[2], position[3]); + PrintText(i++, "View dir: (% .5f, % .5f, % .5f)", 10, viewdirection[0], viewdirection[1], viewdirection[2]); + PrintText(i++, "Cam->origin: (% .15f, % .4f)", 10, pssl[0], pssl[1]); + PrintText(i++, "Scaling: (% .5f, % .5f)", 10, scaling[0], scaling[1]); + + double remaining = openspace::ImageSequencer::ref().getNextCaptureTime() - Time::ref().currentTime(); + double t = 0.0; + t = 1.f - remaining / openspace::ImageSequencer::ref().getIntervalLength(); + std::string progress = "|"; + int g = ((t)* 20) + 1; + for (int i = 0; i < g; i++) progress.append("-"); progress.append(">"); + for (int i = 0; i < 21 - g; i++) progress.append(" "); + + std::string str = ""; + openspace::SpiceManager::ref().getDateFromET(openspace::ImageSequencer::ref().getNextCaptureTime(), str); + + progress.append("|"); + if (remaining > 0){ + glm::vec4 g1(0, t, 0, 1); + glm::vec4 g2(1 - t); + PrintColorText(i++, "Next projection in | %.0f seconds", 10, g1 + g2, remaining); + PrintColorText(i++, "%s %.1f %%", 10, g1 + g2, progress.c_str(), t * 100); + } + glm::vec4 w(1); + PrintColorText(i++, "Ucoming : %s", 10, w, str.c_str()); #undef PrintText }