Merge branch 'master' into thesis/2021/skybrowser

# Conflicts:
#	data/assets/util/webgui.asset
#	modules/webbrowser/src/screenspacebrowser.cpp
#	src/rendering/renderengine.cpp
This commit is contained in:
sylvass
2021-11-30 10:47:46 -05:00
1050 changed files with 35905 additions and 29646 deletions

View File

@@ -1,183 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* 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. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___ABUFFERRENDERER___H__
#define __OPENSPACE_CORE___ABUFFERRENDERER___H__
#ifdef OPENSPACE_WITH_ABUFFER_RENDERER
#include <openspace/rendering/renderer.h>
#include <openspace/rendering/raycasterlistener.h>
#include <ghoul/glm.h>
#include <ghoul/misc/dictionary.h>
#include <ghoul/opengl/ghoul_gl.h>
#include <map>
#include <memory>
#include <string>
#include <vector>
namespace ghoul::filesystem { class File; }
namespace ghoul::opengl {
class ProgramObject;
class Texture;
} // namespace ghoul::opengl
namespace openspace {
struct RaycasterTask;
class RenderableVolume;
class Camera;
class Scene;
struct RaycastData;
class ABufferRenderer : public Renderer, public RaycasterListener {
public:
virtual ~ABufferRenderer() = default;
void initialize() override;
void deinitialize() override;
void setResolution(glm::ivec2 res) override;
void setNAaSamples(int nAaSamples) override;
void setBlurrinessLevel(int level) override;
void setHDRExposure(float hdrExposure) override;
void setGamma(float gamma) override;
void setMaxWhite(float maxWhite) override;
void setToneMapOperator(int tmOp) override;
void setBloomThreMin(float minV) override;
void setBloomThreMax(float maxV) override;
void setBloomOrigFactor(float origFactor) override;
void setBloomNewFactor(float newFactor) override;
void setKey(float key) override;
void setYwhite(float white) override;
void setTmoSaturation(float sat) override;
void setHue(float hue) override;
void setValue(float value) override;
void setSaturation(float sat) override;
void setLightness(float lightness) override;
void setColorSpace(unsigned int colorspace) override;
void enableBloom(bool enable) override;
void enableHistogram(bool enable) override;
int nAaSamples() const override;
const std::vector<double>& mSSAPattern() const override;
using Renderer::preRaycast;
void preRaycast(const RaycasterTask& raycasterTask);
using Renderer::postRaycast;
void postRaycast(const RaycasterTask& raycasterTask);
void update() override;
void render(Scene* scene, Camera* camera, float blackoutFactor) override;
/**
* Update render data
* Responsible for calling renderEngine::setRenderData
*/
virtual void updateRendererData() override;
virtual void raycastersChanged(VolumeRaycaster& raycaster,
IsAttached attached) override;
private:
void clear();
void updateResolution();
void updateRaycastData();
void updateResolveDictionary();
void updateMSAASamplingPattern();
void saveTextureToMemory(GLenum color_buffer_attachment, int width, int height,
std::vector<double> & memory) const;
glm::ivec2 _resolution = glm::ivec2(0);
bool _dirtyResolution = true;
bool _dirtyRendererData = true;
bool _dirtyRaycastData = true;
bool _dirtyResolveDictionary = true;
std::unique_ptr<ghoul::opengl::ProgramObject> _resolveProgram = nullptr;
/**
* When a volume is attached or detached from the scene graph,
* the resolve program needs to be recompiled.
* The _volumes map keeps track of which volumes that can
* be rendered using the current resolve program, along with their raycast data
* (id, namespace, etc)
*/
std::map<VolumeRaycaster*, RaycastData> _raycastData;
std::map<
VolumeRaycaster*, std::unique_ptr<ghoul::opengl::ProgramObject>
> _boundsPrograms;
std::vector<std::string> _helperPaths;
ghoul::Dictionary _resolveDictionary;
GLuint _mainColorTexture;
GLuint _mainDepthTexture;
GLuint _mainFramebuffer;
GLuint _screenQuad;
GLuint _anchorPointerTexture;
GLuint _anchorPointerTextureInitializer;
GLuint _atomicCounterBuffer;
GLuint _fragmentBuffer;
GLuint _fragmentTexture;
GLuint _vertexPositionBuffer;
int _nAaSamples;
int _blurrinessLevel = 1;
float _hdrExposure = 0.4f;
float _hdrBackground = 2.8f;
float _gamma = 2.2f;
float _maxWhite = 1.f;
float _blackoutFactor;
bool _bloomEnabled = false;
float _bloomThresholdMin = 0.0;
float _bloomThresholdMax = 1.0;
float _bloomOrigFactor = 1.0;
float _bloomNewFactor = 1.0;
int _toneMapOperator = 0;
bool _histogramEnabled = false;
int _numberOfBins = 1024; // JCC TODO: Add a parameter control for this.
float _tmoKey = 0.18f;
float _tmoYwhite = 1e6f;
float _tmoSaturation = 1.0f;
float _hue = 1.f;
float _saturation = 1.f;
float _value = 1.f;
float _lightness = 1.f;
unsigned int _colorSpace = 1;
std::vector<double> _mSAAPattern;
ghoul::Dictionary _rendererData;
};
} // namespace openspace
#endif // OPENSPACE_WITH_ABUFFER_RENDERER
#endif // __OPENSPACE_CORE___ABUFFERRENDERER___H__

View File

@@ -25,6 +25,7 @@
#ifndef __OPENSPACE_CORE___DEFERREDCASTER___H
#define __OPENSPACE_CORE___DEFERREDCASTER___H
#include <filesystem>
#include <string>
namespace ghoul::opengl {
@@ -46,31 +47,28 @@ public:
const DeferredcastData& /*deferredData*/,
ghoul::opengl::ProgramObject& /*program*/) {};
virtual void postRaycast(const RenderData & /*renderData*/,
virtual void postRaycast(const RenderData& /*renderData*/,
const DeferredcastData& /*deferredData*/,
ghoul::opengl::ProgramObject& /*program*/) {};
virtual std::string deferredcastPath() const = 0;
virtual std::filesystem::path deferredcastVSPath() const = 0;
virtual std::string deferredcastVSPath() const = 0;
virtual std::string deferredcastFSPath() const = 0;
virtual std::filesystem::path deferredcastFSPath() const = 0;
virtual void initializeCachedVariables(ghoul::opengl::ProgramObject&) = 0;
virtual void update(const UpdateData&) = 0;
/**
* Return a path to a glsl file with helper functions required for the
* transformation and raycast steps.
* This file will be included once per shader program generated,
* regardless of how many volumes say they require the file.
* Ideal to avoid redefinitions of helper functions.
* Return a path to a GLSL file with helper functions required for the transformation
* and raycast steps. This file will be included once per shader program generated,
* regardless of how many volumes say they require the file. Ideal to avoid
* redefinitions of helper functions.
*
* The shader preprocessor will have access to the #{namespace} variable (unique per
* helper file) which should be a prefix to all symbols defined by the helper
*/
virtual std::string helperPath() const = 0;
virtual std::filesystem::path helperPath() const = 0;
};
} // namespace openspace

View File

@@ -25,8 +25,6 @@
#ifndef __OPENSPACE_CORE___FRAMEBUFFERRENDERER___H__
#define __OPENSPACE_CORE___FRAMEBUFFERRENDERER___H__
#include <openspace/rendering/renderer.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/rendering/raycasterlistener.h>
#include <openspace/rendering/deferredcasterlistener.h>
@@ -56,14 +54,14 @@ struct RaycasterTask;
class Scene;
struct UpdateStructures;
class FramebufferRenderer : public Renderer, public RaycasterListener,
class FramebufferRenderer : public RaycasterListener,
public DeferredcasterListener
{
public:
virtual ~FramebufferRenderer() = default;
void initialize() override;
void deinitialize() override;
void initialize();
void deinitialize();
void updateResolution();
void updateRaycastData();
@@ -72,26 +70,28 @@ public:
void updateFXAA();
void updateDownscaledVolume();
void setResolution(glm::ivec2 res) override;
void setHDRExposure(float hdrExposure) override;
void setGamma(float gamma) override;
void setHue(float hue) override;
void setValue(float value) override;
void setSaturation(float sat) override;
void setResolution(glm::ivec2 res);
void setHDRExposure(float hdrExposure);
void setGamma(float gamma);
void setHue(float hue);
void setValue(float value);
void setSaturation(float sat);
void enableFXAA(bool enable) override;
void setDisableHDR(bool disable) override;
void enableFXAA(bool enable);
void setDisableHDR(bool disable);
void update() override;
void performRaycasterTasks(const std::vector<RaycasterTask>& tasks);
void performDeferredTasks(const std::vector<DeferredcasterTask>& tasks);
void render(Scene* scene, Camera* camera, float blackoutFactor) override;
void update();
void performRaycasterTasks(const std::vector<RaycasterTask>& tasks,
const glm::ivec4& viewport);
void performDeferredTasks(const std::vector<DeferredcasterTask>& tasks,
const glm::ivec4& viewport);
void render(Scene* scene, Camera* camera, float blackoutFactor);
/**
* Update render data
* Responsible for calling renderEngine::setRenderData
*/
virtual void updateRendererData() override;
virtual void updateRendererData();
virtual void raycastersChanged(VolumeRaycaster& raycaster,
RaycasterListener::IsAttached attached) override;
@@ -109,11 +109,11 @@ private:
>;
void resolveMSAA(float blackoutFactor);
void applyTMO(float blackoutFactor);
void applyFXAA();
void applyTMO(float blackoutFactor, const glm::ivec4& viewport);
void applyFXAA(const glm::ivec4& viewport);
void updateDownscaleTextures();
void updateExitVolumeTextures();
void writeDownscaledVolume();
void writeDownscaledVolume(const glm::ivec4& viewport);
std::map<VolumeRaycaster*, RaycastData> _raycastData;
RaycasterProgObjMap _exitPrograms;
@@ -129,10 +129,11 @@ private:
std::unique_ptr<ghoul::opengl::ProgramObject> _downscaledVolumeProgram;
UniformCache(hdrFeedingTexture, blackoutFactor, hdrExposure, gamma,
Hue, Saturation, Value) _hdrUniformCache;
UniformCache(renderedTexture, inverseScreenSize) _fxaaUniformCache;
UniformCache(downscaledRenderedVolume, downscaledRenderedVolumeDepth)
_writeDownscaledVolumeUniformCache;
Hue, Saturation, Value, Viewport, Resolution) _hdrUniformCache;
UniformCache(renderedTexture, inverseScreenSize, Viewport,
Resolution) _fxaaUniformCache;
UniformCache(downscaledRenderedVolume, downscaledRenderedVolumeDepth, viewport,
resolution) _writeDownscaledVolumeUniformCache;
GLint _defaultFBO;
GLuint _screenQuad;

View File

@@ -32,8 +32,11 @@
#include <openspace/properties/scalar/intproperty.h>
#include <openspace/properties/scalar/floatproperty.h>
#include <openspace/properties/vector/vec3property.h>
#include <openspace/properties/vector/vec4property.h>
#include <openspace/properties/triggerproperty.h>
#include <openspace/rendering/framebufferrenderer.h>
#include <chrono>
#include <filesystem>
namespace ghoul {
namespace fontrendering { class Font; }
@@ -53,7 +56,6 @@ namespace scripting { struct LuaLibrary; }
class Camera;
class RaycasterManager;
class DeferredcasterManager;
class Renderer;
class Scene;
class SceneManager;
class ScreenLog;
@@ -62,12 +64,6 @@ struct ShutdownInformation;
class RenderEngine : public properties::PropertyOwner {
public:
enum class RendererImplementation {
Framebuffer = 0,
ABuffer,
Invalid
};
RenderEngine();
~RenderEngine();
@@ -79,9 +75,6 @@ public:
Scene* scene();
void updateScene();
const Renderer& renderer() const;
RendererImplementation rendererImplementation() const;
ghoul::opengl::OpenGLStateCache& openglStateCache();
void updateShaderPrograms();
@@ -109,33 +102,21 @@ public:
std::vector<ScreenSpaceRenderable*> screenSpaceRenderables() const;
std::unique_ptr<ghoul::opengl::ProgramObject> buildRenderProgram(
const std::string& name, const std::string& vsPath, std::string fsPath,
ghoul::Dictionary data = ghoul::Dictionary());
const std::string& name, const std::filesystem::path& vsPath,
std::filesystem::path fsPath, ghoul::Dictionary data = ghoul::Dictionary());
std::unique_ptr<ghoul::opengl::ProgramObject> buildRenderProgram(
const std::string& name, const std::string& vsPath, std::string fsPath,
const std::string& csPath, ghoul::Dictionary data = ghoul::Dictionary());
const std::string& name, const std::filesystem::path& vsPath,
std::filesystem::path fsPath, const std::filesystem::path& csPath,
ghoul::Dictionary data = ghoul::Dictionary());
void removeRenderProgram(ghoul::opengl::ProgramObject* program);
/**
* Set raycasting uniforms on the program object, and setup raycasting.
*/
void preRaycast(ghoul::opengl::ProgramObject& programObject);
/**
* Tear down raycasting for the specified program object.
*/
void postRaycast(ghoul::opengl::ProgramObject& programObject);
/**
* Set the camera to use for rendering
*/
void setCamera(Camera* camera);
void setRendererFromString(const std::string& renderingMethod);
/**
* Lets the renderer update the data to be brought into the rendererer programs
* as a 'rendererData' variable in the dictionary.
@@ -174,9 +155,6 @@ public:
uint64_t frameNumber() const;
private:
void setRenderer(std::unique_ptr<Renderer> renderer);
RendererImplementation rendererFromString(const std::string& renderingMethod) const;
void renderScreenLog();
void renderVersionInformation();
void renderCameraInformation();
@@ -186,13 +164,12 @@ private:
Camera* _camera = nullptr;
Scene* _scene = nullptr;
std::unique_ptr<Renderer> _renderer;
RendererImplementation _rendererImplementation = RendererImplementation::Invalid;
FramebufferRenderer _renderer;
ghoul::Dictionary _rendererData;
ghoul::Dictionary _resolveData;
ScreenLog* _log = nullptr;
ghoul::opengl::OpenGLStateCache* _openglStateCache;
ghoul::opengl::OpenGLStateCache* _openglStateCache = nullptr;
properties::BoolProperty _showOverlayOnSlaves;
properties::BoolProperty _showLog;
@@ -231,8 +208,9 @@ private:
std::vector<ghoul::opengl::ProgramObject*> _programs;
std::shared_ptr<ghoul::fontrendering::Font> _fontFrameInfo;
std::shared_ptr<ghoul::fontrendering::Font> _fontInfo;
std::shared_ptr<ghoul::fontrendering::Font> _fontDate;
std::shared_ptr<ghoul::fontrendering::Font> _fontCameraInfo;
std::shared_ptr<ghoul::fontrendering::Font> _fontVersionInfo;
std::shared_ptr<ghoul::fontrendering::Font> _fontShutdown;
std::shared_ptr<ghoul::fontrendering::Font> _fontLog;
struct {
@@ -242,6 +220,9 @@ private:
} _cameraButtonLocations;
std::string _versionString;
properties::Vec4Property _enabledFontColor;
properties::Vec4Property _disabledFontColor;
};
} // namespace openspace

View File

@@ -1,83 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* 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. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___RENDERER___H__
#define __OPENSPACE_CORE___RENDERER___H__
#include <ghoul/glm.h>
#include <vector>
namespace ghoul { class Dictionary; }
namespace ghoul::filesystem { class File; }
namespace ghoul::opengl {
class ProgramObject;
class Texture;
} // namespace ghoul::opengl
namespace openspace {
class RenderableVolume;
class Camera;
class Scene;
class Renderer {
public:
virtual ~Renderer() = default;
virtual void initialize() = 0;
virtual void deinitialize() = 0;
virtual void setResolution(glm::ivec2 res) = 0;
virtual void setHDRExposure(float hdrExposure) = 0;
virtual void setGamma(float gamma) = 0;
virtual void setHue(float hue) = 0;
virtual void setValue(float value) = 0;
virtual void setSaturation(float sat) = 0;
virtual void enableFXAA(bool enable) = 0;
virtual void setDisableHDR(bool disable) = 0;
/**
* Set raycasting uniforms on the program object, and setup raycasting.
*/
virtual void preRaycast(ghoul::opengl::ProgramObject& /*programObject*/) {};
/**
* Tear down raycasting for the specified program object.
*/
virtual void postRaycast(ghoul::opengl::ProgramObject& /*programObject*/) {};
virtual void update() = 0;
virtual void render(Scene* scene, Camera* camera, float blackoutFactor) = 0;
/**
* Update render data
* Responsible for calling renderEngine::setRenderData
*/
virtual void updateRendererData() = 0;
};
} // openspace
#endif // __OPENSPACE_CORE___RENDERER___H__

View File

@@ -117,11 +117,12 @@ protected:
properties::Vec3Property _localRotation;
properties::FloatProperty _scale;
properties::Vec3Property _multiplyColor;
properties::FloatProperty _opacity;
properties::TriggerProperty _delete;
glm::ivec2 _objectSize = glm::ivec2(0);
UniformCache(alpha, modelTransform, viewProj, texture) _uniformCache;
UniformCache(color, opacity, mvp, texture) _uniformCache;
std::unique_ptr<ghoul::opengl::ProgramObject> _shader;
};

View File

@@ -26,6 +26,7 @@
#define __OPENSPACE_CORE___TEXTURECOMPONENT___H__
#include <ghoul/opengl/texture.h>
#include <filesystem>
namespace ghoul::filesystem { class File; }
namespace ghoul::opengl {class Texture; }
@@ -48,7 +49,7 @@ public:
void uploadToGpu();
// Loads a texture from a file on disk
void loadFromFile(const std::string& path);
void loadFromFile(const std::filesystem::path& path);
// Function to call in a renderable's update function to make sure
// the texture is kept up to date

View File

@@ -26,6 +26,7 @@
#define __OPENSPACE_CORE___TRANSFERFUNCTION___H__
#include <ghoul/glm.h>
#include <filesystem>
#include <functional>
#include <memory>
#include <string>
@@ -58,7 +59,7 @@ private:
void setTextureFromImage();
void uploadTexture();
std::string _filepath;
std::filesystem::path _filepath;
std::unique_ptr<ghoul::filesystem::File> _file;
std::shared_ptr<ghoul::opengl::Texture> _texture;
bool _needsUpdate = false;