diff --git a/apps/OpenSpace-MinVR/main.cpp b/apps/OpenSpace-MinVR/main.cpp index 5931027dda..c2d857cc7c 100644 --- a/apps/OpenSpace-MinVR/main.cpp +++ b/apps/OpenSpace-MinVR/main.cpp @@ -200,6 +200,7 @@ void Handler::onVREvent(const VRDataIndex& eventData) { if (button == MouseButton::Right && action == MouseAction::Press) { windowingGlobals.mouseButtons |= 1 << 2; } + using KM = KeyModifier; KM mod = KM::NoModifier; mod |= keyboardState.modifierShift ? KM::Shift : KM::NoModifier; diff --git a/data/assets/default.scene b/data/assets/default.scene index 46e59bf846..c6d3e2523c 100644 --- a/data/assets/default.scene +++ b/data/assets/default.scene @@ -10,11 +10,6 @@ asset.onInitialize(function () openspace.globebrowsing.goToGeo("Earth", 58.5877, 16.1924, 20000000) openspace.markInterestingNodes({ "Earth", "Mars", "Moon", "Sun" }) - - -- HDR / Image options: - openspace.setPropertyValueSingle('RenderEngine.Gamma', 0.95); - openspace.setPropertyValueSingle('RenderEngine.HDRExposure', 3.7); - openspace.setPropertyValueSingle('RenderEngine.Saturation', 1.0); end) asset.onDeinitialize(function () diff --git a/data/assets/util/webgui.asset b/data/assets/util/webgui.asset index bfce9452fc..29a6437b42 100644 --- a/data/assets/util/webgui.asset +++ b/data/assets/util/webgui.asset @@ -58,12 +58,14 @@ end) asset.onDeinitialize(function () -- Remove the frontend endpoint local directories = openspace.getPropertyValue("Modules.WebGui.Directories") - local newDirectories; + local newDirectories = {}; openspace.setPropertyValueSingle("Modules.WebGui.DefaultEndpoint", "") for i = 0, #directories, 2 do - if (string.find(directories[i], "frontend") == nil) then + -- @TODO(abock, 2019-08-20) The explicit check for directories[i] is a workaround + -- for an error that was otherwise thrown when directories[i] was nil + if (directories[i] and string.find(directories[i], "frontend") == nil) then newDirectories[#newDirectories + 1] = directories[i] newDirectories[#newDirectories + 1] = directories[i + 1] end diff --git a/include/openspace/rendering/framebufferrenderer.h b/include/openspace/rendering/framebufferrenderer.h index d5fab211fa..d116c54bce 100644 --- a/include/openspace/rendering/framebufferrenderer.h +++ b/include/openspace/rendering/framebufferrenderer.h @@ -59,70 +59,6 @@ struct UpdateStructures; class FramebufferRenderer : public Renderer, public RaycasterListener, public DeferredcasterListener { -private: - inline static const GLenum ColorAttachment0Array[1] = { - GL_COLOR_ATTACHMENT0 - }; - - inline static const GLenum ColorAttachment1Array[1] = { - GL_COLOR_ATTACHMENT1 - }; - - inline static const GLenum ColorAttachment01Array[2] = { - GL_COLOR_ATTACHMENT0, - GL_COLOR_ATTACHMENT1 - }; - - inline static const GLenum ColorAttachment03Array[2] = { - GL_COLOR_ATTACHMENT0, - GL_COLOR_ATTACHMENT3 - }; - - inline static const GLenum ColorAttachment012Array[3] = { - GL_COLOR_ATTACHMENT0, - GL_COLOR_ATTACHMENT1, - GL_COLOR_ATTACHMENT2 - }; - - inline static const GLenum ColorAttachment0123Array[4] = { - GL_COLOR_ATTACHMENT0, - GL_COLOR_ATTACHMENT1, - GL_COLOR_ATTACHMENT2, - GL_COLOR_ATTACHMENT3 - }; - - typedef struct { - GLuint _colorTexture; - GLuint _positionTexture; - GLuint _normalTexture; - GLuint _depthTexture; - GLuint _framebuffer; - } GBuffers; - - typedef struct { - GLuint framebuffer; - GLuint colorTexture[2]; - } PingPongBuffers; - - typedef struct { - GLuint _hdrFilteringFramebuffer; - GLuint _hdrFilteringTexture; - } HDRBuffers; - - typedef struct { - GLuint _fxaaFramebuffer; - GLuint _fxaaTexture; - } FXAABuffers; - -public: - typedef std::map< - VolumeRaycaster*, - std::unique_ptr - > RaycasterProgObjMap; - typedef std::map< - Deferredcaster*, - std::unique_ptr - > DeferredcasterProgObjMap; public: virtual ~FramebufferRenderer() = default; @@ -143,7 +79,7 @@ public: void setSaturation(float sat) override; void enableFXAA(bool enable) override; - void disableHDR(bool disable) override; + void setDisableHDR(bool disable) override; void update() override; void performRaycasterTasks(const std::vector& tasks); @@ -162,10 +98,19 @@ public: DeferredcasterListener::IsAttached isAttached) override; private: + using RaycasterProgObjMap = std::map< + VolumeRaycaster*, + std::unique_ptr + >; + using DeferredcasterProgObjMap = std::map< + Deferredcaster*, + std::unique_ptr + >; + + void resolveMSAA(float blackoutFactor); void applyTMO(float blackoutFactor); void applyFXAA(); -private: std::map _raycastData; RaycasterProgObjMap _exitPrograms; RaycasterProgObjMap _raycastPrograms; @@ -191,11 +136,29 @@ private: GLuint _exitDepthTexture; GLuint _exitFramebuffer; - GBuffers _gBuffers; - PingPongBuffers _pingPongBuffers; - HDRBuffers _hdrBuffers; - FXAABuffers _fxaaBuffers; + struct { + GLuint colorTexture; + GLuint positionTexture; + GLuint normalTexture; + GLuint depthTexture; + GLuint framebuffer; + } _gBuffers; + + struct { + GLuint framebuffer; + GLuint colorTexture[2]; + } _pingPongBuffers; + + struct { + GLuint hdrFilteringFramebuffer; + GLuint hdrFilteringTexture; + } _hdrBuffers; + struct { + GLuint fxaaFramebuffer; + GLuint fxaaTexture; + } _fxaaBuffers; + unsigned int _pingPongIndex = 0u; bool _dirtyDeferredcastData; diff --git a/include/openspace/rendering/renderengine.h b/include/openspace/rendering/renderengine.h index 992a28d011..2abeeaae0a 100644 --- a/include/openspace/rendering/renderengine.h +++ b/include/openspace/rendering/renderengine.h @@ -34,8 +34,6 @@ #include #include -#include - namespace ghoul { class Dictionary; class SharedMemory; diff --git a/include/openspace/rendering/renderer.h b/include/openspace/rendering/renderer.h index 9e018609fd..d8b38f0450 100644 --- a/include/openspace/rendering/renderer.h +++ b/include/openspace/rendering/renderer.h @@ -55,7 +55,7 @@ public: virtual void setValue(float value) = 0; virtual void setSaturation(float sat) = 0; virtual void enableFXAA(bool enable) = 0; - virtual void disableHDR(bool disable) = 0; + virtual void setDisableHDR(bool disable) = 0; /** * Set raycasting uniforms on the program object, and setup raycasting. diff --git a/modules/base/translation/timelinetranslation.h b/modules/base/translation/timelinetranslation.h index 304f1654b7..0d528d36a6 100644 --- a/modules/base/translation/timelinetranslation.h +++ b/modules/base/translation/timelinetranslation.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2018 * + * Copyright (c) 2014-2019 * * * * 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 * diff --git a/shaders/framebuffer/hdrAndFiltering.frag b/shaders/framebuffer/hdrAndFiltering.frag index 997c68780a..eda90c9b14 100644 --- a/shaders/framebuffer/hdrAndFiltering.frag +++ b/shaders/framebuffer/hdrAndFiltering.frag @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2018 * + * Copyright (c) 2014-2019 * * * * 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 * @@ -59,4 +59,4 @@ void main() { // Gamma Correction finalColor = vec4(gammaCorrection(hsv2rgb(hsvColor), gamma), color.a); -} \ No newline at end of file +} diff --git a/shaders/framebuffer/hdrAndFiltering.vert b/shaders/framebuffer/hdrAndFiltering.vert index 06506ba824..f737e51882 100644 --- a/shaders/framebuffer/hdrAndFiltering.vert +++ b/shaders/framebuffer/hdrAndFiltering.vert @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2018 * + * Copyright (c) 2014-2019 * * * * 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 * diff --git a/shaders/hdr.glsl b/shaders/hdr.glsl index 033f805b48..c9909b03ea 100644 --- a/shaders/hdr.glsl +++ b/shaders/hdr.glsl @@ -28,16 +28,16 @@ const float HCY_EPSILON = 1e-7; // White given by D65 const mat3 RGB2XYZ = mat3( - vec3(0.4124, 0.2126, 0.0193), - vec3(0.3576, 0.7152, 0.1192), - vec3(0.1805, 0.0722, 0.9505) - ); + vec3(0.4124, 0.2126, 0.0193), + vec3(0.3576, 0.7152, 0.1192), + vec3(0.1805, 0.0722, 0.9505) +); const mat3 XYZ2RGB = mat3( - vec3(3.2406, -0.9689, 0.0557), - vec3(-1.5372, 1.8758, -0.2040), - vec3(-0.4986, 0.0415, 1.0570) - ); + vec3(3.2406, -0.9689, 0.0557), + vec3(-1.5372, 1.8758, -0.2040), + vec3(-0.4986, 0.0415, 1.0570) +); // Gamma correction for linear RGB to sRGB // See wiki: https://en.wikipedia.org/wiki/SRGB#The_sRGB_transfer_function_.28.22gamma.22.29 @@ -45,7 +45,7 @@ const float gammaF(const float u) { if (u < 0.0031308) { return 12.92 * u; } else { - return 1.055 * pow(u, 1.0/2.4) - 0.055; + return 1.055 * pow(u, 1.0 / 2.4) - 0.055; } } @@ -53,7 +53,7 @@ float invgammaF(const float u) { if (u < 0.04045) { return u / 12.92; } else { - return pow((u+0.055)/1.055, 2.4); + return pow((u + 0.055) / 1.055, 2.4); } } @@ -77,9 +77,8 @@ vec3 XYZToSRGB(const vec3 XYZ) { } // HSV code taken from http://lolengine.net/blog/2013/07/27/rgb-to-hsv-in-glsl. -vec3 rgb2hsv(const vec3 c) -{ - vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); +vec3 rgb2hsv(const vec3 c) { + const vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); @@ -89,9 +88,8 @@ vec3 rgb2hsv(const vec3 c) } // All components are in the range [0…1], including hue. -vec3 hsv2rgb(const vec3 c) -{ - vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); +vec3 hsv2rgb(const vec3 c) { + const vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } @@ -108,16 +106,14 @@ See top of the file for full license terms. */ // Converts from pure Hue to linear RGB -vec3 hue2rgb(float hue) -{ +vec3 hue2rgb(float hue) { float R = abs(hue * 6 - 3) - 1; float G = 2 - abs(hue * 6 - 2); float B = 2 - abs(hue * 6 - 4); return clamp(vec3(R,G,B), 0, 1); } // Converts a value from linear RGB to HCV (Hue, Chroma, Value) -vec3 rgb2hcv(vec3 rgb) -{ +vec3 rgb2hcv(vec3 rgb) { // Based on work by Sam Hocevar and Emil Persson vec4 P = (rgb.g < rgb.b) ? vec4(rgb.bg, -1.0, 2.0/3.0) : vec4(rgb.gb, 0.0, -1.0/3.0); vec4 Q = (rgb.r < P.x) ? vec4(P.xyw, rgb.r) : vec4(rgb.r, P.yzx); @@ -127,36 +123,34 @@ vec3 rgb2hcv(vec3 rgb) } // Converts from HSL to linear RGB -vec3 hsl2rgb(vec3 hsl) -{ +vec3 hsl2rgb(vec3 hsl) { vec3 rgb = hue2rgb(hsl.x); float C = (1 - abs(2 * hsl.z - 1)) * hsl.y; return (rgb - 0.5) * C + hsl.z; } // Converts from linear rgb to HSL -vec3 rgb2hsl(vec3 rgb) -{ +vec3 rgb2hsl(vec3 rgb) { vec3 HCV = rgb2hcv(rgb); float L = HCV.z - HCV.y * 0.5; float S = HCV.y / (1 - abs(L * 2 - 1) + HSL_EPSILON); return vec3(HCV.x, S, L); } -vec3 exponentialToneMapping(vec3 color, const float exposure, const float gamma) { +vec3 exponentialToneMapping(vec3 color, float exposure, float gamma) { color *= exposure; - + color.r = color.r < 1.413 ? pow(color.r * 0.38317, 1.0 / gamma) : 1.0 - exp2(-exposure * color.r); color.g = color.g < 1.413 ? pow(color.g * 0.38317, 1.0 / gamma) : 1.0 - exp2(-exposure * color.g); color.b = color.b < 1.413 ? pow(color.b * 0.38317, 1.0 / gamma) : 1.0 - exp2(-exposure * color.b); - + return color; } -vec3 toneMappingOperator(vec3 color, const float exposure) { +vec3 toneMappingOperator(vec3 color, float exposure) { return 1.0 - exp2(-exposure * color); } -vec3 gammaCorrection(vec3 color, const float gamma) { +vec3 gammaCorrection(vec3 color, float gamma) { return pow(color, vec3(1.0f / gamma)); } \ No newline at end of file diff --git a/src/interaction/navigationhandler.cpp b/src/interaction/navigationhandler.cpp index 45dc1713f9..ba7a2ea4f3 100644 --- a/src/interaction/navigationhandler.cpp +++ b/src/interaction/navigationhandler.cpp @@ -65,10 +65,7 @@ namespace { namespace openspace::interaction { - -ghoul::Dictionary - openspace::interaction::NavigationHandler::NavigationState::dictionary() const -{ +ghoul::Dictionary NavigationHandler::NavigationState::dictionary() const { ghoul::Dictionary cameraDict; cameraDict.setValue(KeyPosition, position); cameraDict.setValue(KeyAnchor, anchor); @@ -93,9 +90,7 @@ ghoul::Dictionary return cameraDict; } -openspace::interaction::NavigationHandler::NavigationState::NavigationState( - const ghoul::Dictionary& dictionary) -{ +NavigationHandler::NavigationState::NavigationState(const ghoul::Dictionary& dictionary) { const bool hasAnchor = dictionary.hasValue(KeyAnchor); const bool hasPosition = dictionary.hasValue(KeyPosition); if (!hasAnchor || !hasPosition) { @@ -129,14 +124,12 @@ openspace::interaction::NavigationHandler::NavigationState::NavigationState( } } -openspace::interaction::NavigationHandler::NavigationState::NavigationState( - std::string anchor, - std::string aim, - std::string referenceFrame, - glm::dvec3 position, - std::optional up, - double yaw, - double pitch) +NavigationHandler::NavigationState::NavigationState(std::string anchor, std::string aim, + std::string referenceFrame, + glm::dvec3 position, + std::optional up, + double yaw, + double pitch) : anchor(std::move(anchor)) , aim(std::move(aim)) , referenceFrame(std::move(referenceFrame)) @@ -332,7 +325,7 @@ void NavigationHandler::keyboardCallback(Key key, KeyModifier modifier, KeyActio } NavigationHandler::NavigationState NavigationHandler::navigationState( - const SceneGraphNode& referenceFrame) const + const SceneGraphNode& referenceFrame) const { const SceneGraphNode* anchor = _orbitalNavigator.anchorNode(); const SceneGraphNode* aim = _orbitalNavigator.aimNode(); @@ -375,7 +368,7 @@ NavigationHandler::NavigationState NavigationHandler::navigationState( } void NavigationHandler::saveNavigationState(const std::string& filepath, - const std::string& referenceFrameIdentifier) + const std::string& referenceFrameIdentifier) { const SceneGraphNode* referenceFrame = _orbitalNavigator.followingAnchorRotation() ? _orbitalNavigator.anchorNode() : @@ -429,9 +422,9 @@ void NavigationHandler::loadNavigationState(const std::string& filepath) { } void NavigationHandler::setJoystickAxisMapping(int axis, - JoystickCameraStates::AxisType mapping, - JoystickCameraStates::AxisInvert shouldInvert, - JoystickCameraStates::AxisNormalize shouldNormalize) + JoystickCameraStates::AxisType mapping, + JoystickCameraStates::AxisInvert shouldInvert, + JoystickCameraStates::AxisNormalize shouldNormalize) { _orbitalNavigator.joystickStates().setAxisMapping( axis, @@ -442,9 +435,9 @@ void NavigationHandler::setJoystickAxisMapping(int axis, } void NavigationHandler::setWebsocketAxisMapping(int axis, - WebsocketCameraStates::AxisType mapping, - WebsocketCameraStates::AxisInvert shouldInvert, - WebsocketCameraStates::AxisNormalize shouldNormalize) + WebsocketCameraStates::AxisType mapping, + WebsocketCameraStates::AxisInvert shouldInvert, + WebsocketCameraStates::AxisNormalize shouldNormalize) { _orbitalNavigator.websocketStates().setAxisMapping( axis, @@ -456,7 +449,7 @@ void NavigationHandler::setWebsocketAxisMapping(int axis, JoystickCameraStates::AxisInformation - NavigationHandler::joystickAxisMapping(int axis) const +NavigationHandler::joystickAxisMapping(int axis) const { return _orbitalNavigator.joystickStates().axisMapping(axis); } @@ -470,9 +463,9 @@ float NavigationHandler::joystickAxisDeadzone(int axis) const { } void NavigationHandler::bindJoystickButtonCommand(int button, std::string command, - JoystickAction action, - JoystickCameraStates::ButtonCommandRemote remote, - std::string documentation) + JoystickAction action, + JoystickCameraStates::ButtonCommandRemote remote, + std::string documentation) { _orbitalNavigator.joystickStates().bindButtonCommand( button, diff --git a/src/rendering/framebufferrenderer.cpp b/src/rendering/framebufferrenderer.cpp index c67f7d3945..4908ef7836 100644 --- a/src/rendering/framebufferrenderer.cpp +++ b/src/rendering/framebufferrenderer.cpp @@ -72,6 +72,37 @@ namespace { constexpr const char* RenderFragmentShaderPath = "${SHADERS}/framebuffer/renderframebuffer.frag"; + const GLenum ColorAttachment0Array[1] = { + GL_COLOR_ATTACHMENT0 + }; + + const GLenum ColorAttachment1Array[1] = { + GL_COLOR_ATTACHMENT1 + }; + + const GLenum ColorAttachment01Array[2] = { + GL_COLOR_ATTACHMENT0, + GL_COLOR_ATTACHMENT1 + }; + + const GLenum ColorAttachment03Array[2] = { + GL_COLOR_ATTACHMENT0, + GL_COLOR_ATTACHMENT3 + }; + + const GLenum ColorAttachment012Array[3] = { + GL_COLOR_ATTACHMENT0, + GL_COLOR_ATTACHMENT1, + GL_COLOR_ATTACHMENT2 + }; + + const GLenum ColorAttachment0123Array[4] = { + GL_COLOR_ATTACHMENT0, + GL_COLOR_ATTACHMENT1, + GL_COLOR_ATTACHMENT2, + GL_COLOR_ATTACHMENT3 + }; + void saveTextureToMemory(GLenum attachment, int width, int height, std::vector& memory) { @@ -132,15 +163,15 @@ void FramebufferRenderer::initialize() { glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_defaultFBO); // GBuffers - glGenTextures(1, &_gBuffers._colorTexture); - glGenTextures(1, &_gBuffers._depthTexture); - glGenTextures(1, &_gBuffers._positionTexture); - glGenTextures(1, &_gBuffers._normalTexture); - glGenFramebuffers(1, &_gBuffers._framebuffer); + glGenTextures(1, &_gBuffers.colorTexture); + glGenTextures(1, &_gBuffers.depthTexture); + glGenTextures(1, &_gBuffers.positionTexture); + glGenTextures(1, &_gBuffers.normalTexture); + glGenFramebuffers(1, &_gBuffers.framebuffer); // PingPong Buffers // The first pingpong buffer shares the color texture with the renderbuffer: - _pingPongBuffers.colorTexture[0] = _gBuffers._colorTexture; + _pingPongBuffers.colorTexture[0] = _gBuffers.colorTexture; glGenTextures(1, &_pingPongBuffers.colorTexture[1]); glGenFramebuffers(1, &_pingPongBuffers.framebuffer); @@ -150,12 +181,12 @@ void FramebufferRenderer::initialize() { glGenFramebuffers(1, &_exitFramebuffer); // HDR / Filtering Buffers - glGenFramebuffers(1, &_hdrBuffers._hdrFilteringFramebuffer); - glGenTextures(1, &_hdrBuffers._hdrFilteringTexture); + glGenFramebuffers(1, &_hdrBuffers.hdrFilteringFramebuffer); + glGenTextures(1, &_hdrBuffers.hdrFilteringTexture); // FXAA Buffers - glGenFramebuffers(1, &_fxaaBuffers._fxaaFramebuffer); - glGenTextures(1, &_fxaaBuffers._fxaaTexture); + glGenFramebuffers(1, &_fxaaBuffers.fxaaFramebuffer); + glGenTextures(1, &_fxaaBuffers.fxaaTexture); // Allocate Textures/Buffers Memory updateResolution(); @@ -166,29 +197,29 @@ void FramebufferRenderer::initialize() { //==============================// //===== GBuffers Buffers =====// //==============================// - glBindFramebuffer(GL_FRAMEBUFFER, _gBuffers._framebuffer); + glBindFramebuffer(GL_FRAMEBUFFER, _gBuffers.framebuffer); glFramebufferTexture( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - _gBuffers._colorTexture, + _gBuffers.colorTexture, 0 ); glFramebufferTexture( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, - _gBuffers._positionTexture, + _gBuffers.positionTexture, 0 ); glFramebufferTexture( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, - _gBuffers._normalTexture, + _gBuffers.normalTexture, 0 ); glFramebufferTexture( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, - _gBuffers._depthTexture, + _gBuffers.depthTexture, 0 ); @@ -216,7 +247,7 @@ void FramebufferRenderer::initialize() { glFramebufferTexture( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, - _gBuffers._depthTexture, + _gBuffers.depthTexture, 0 ); @@ -251,11 +282,11 @@ void FramebufferRenderer::initialize() { //===================================// //===== HDR/Filtering Buffers =====// //===================================// - glBindFramebuffer(GL_FRAMEBUFFER, _hdrBuffers._hdrFilteringFramebuffer); + glBindFramebuffer(GL_FRAMEBUFFER, _hdrBuffers.hdrFilteringFramebuffer); glFramebufferTexture( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - _hdrBuffers._hdrFilteringTexture, + _hdrBuffers.hdrFilteringTexture, 0 ); @@ -267,11 +298,11 @@ void FramebufferRenderer::initialize() { //===================================// //========== FXAA Buffers =========// //===================================// - glBindFramebuffer(GL_FRAMEBUFFER, _fxaaBuffers._fxaaFramebuffer); + glBindFramebuffer(GL_FRAMEBUFFER, _fxaaBuffers.fxaaFramebuffer); glFramebufferTexture( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - _fxaaBuffers._fxaaTexture, + _fxaaBuffers.fxaaTexture, 0 ); @@ -321,19 +352,19 @@ void FramebufferRenderer::initialize() { void FramebufferRenderer::deinitialize() { LINFO("Deinitializing FramebufferRenderer"); - glDeleteFramebuffers(1, &_gBuffers._framebuffer); + glDeleteFramebuffers(1, &_gBuffers.framebuffer); glDeleteFramebuffers(1, &_exitFramebuffer); - glDeleteFramebuffers(1, &_hdrBuffers._hdrFilteringFramebuffer); - glDeleteFramebuffers(1, &_fxaaBuffers._fxaaFramebuffer); + glDeleteFramebuffers(1, &_hdrBuffers.hdrFilteringFramebuffer); + glDeleteFramebuffers(1, &_fxaaBuffers.fxaaFramebuffer); glDeleteFramebuffers(1, &_pingPongBuffers.framebuffer); - glDeleteTextures(1, &_gBuffers._colorTexture); - glDeleteTextures(1, &_gBuffers._depthTexture); + glDeleteTextures(1, &_gBuffers.colorTexture); + glDeleteTextures(1, &_gBuffers.depthTexture); - glDeleteTextures(1, &_hdrBuffers._hdrFilteringTexture); - glDeleteTextures(1, &_fxaaBuffers._fxaaTexture); - glDeleteTextures(1, &_gBuffers._positionTexture); - glDeleteTextures(1, &_gBuffers._normalTexture); + glDeleteTextures(1, &_hdrBuffers.hdrFilteringTexture); + glDeleteTextures(1, &_fxaaBuffers.fxaaTexture); + glDeleteTextures(1, &_gBuffers.positionTexture); + glDeleteTextures(1, &_gBuffers.normalTexture); glDeleteTextures(1, &_pingPongBuffers.colorTexture[1]); @@ -413,7 +444,7 @@ void FramebufferRenderer::applyFXAA() { renderedTextureUnit.activate(); glBindTexture( GL_TEXTURE_2D, - _fxaaBuffers._fxaaTexture + _fxaaBuffers.fxaaTexture ); _fxaaProgram->setUniform( @@ -525,7 +556,7 @@ void FramebufferRenderer::update() { } void FramebufferRenderer::updateResolution() { - glBindTexture(GL_TEXTURE_2D, _gBuffers._colorTexture); + glBindTexture(GL_TEXTURE_2D, _gBuffers.colorTexture); glTexImage2D( GL_TEXTURE_2D, 0, @@ -540,7 +571,7 @@ void FramebufferRenderer::updateResolution() { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glBindTexture(GL_TEXTURE_2D, _gBuffers._positionTexture); + glBindTexture(GL_TEXTURE_2D, _gBuffers.positionTexture); glTexImage2D( GL_TEXTURE_2D, 0, @@ -555,7 +586,7 @@ void FramebufferRenderer::updateResolution() { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glBindTexture(GL_TEXTURE_2D, _gBuffers._normalTexture); + glBindTexture(GL_TEXTURE_2D, _gBuffers.normalTexture); glTexImage2D( GL_TEXTURE_2D, 0, @@ -570,7 +601,7 @@ void FramebufferRenderer::updateResolution() { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glBindTexture(GL_TEXTURE_2D, _gBuffers._depthTexture); + glBindTexture(GL_TEXTURE_2D, _gBuffers.depthTexture); glTexImage2D( GL_TEXTURE_2D, 0, @@ -601,7 +632,7 @@ void FramebufferRenderer::updateResolution() { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // HDR / Filtering - glBindTexture(GL_TEXTURE_2D, _hdrBuffers._hdrFilteringTexture); + glBindTexture(GL_TEXTURE_2D, _hdrBuffers.hdrFilteringTexture); glTexImage2D( GL_TEXTURE_2D, 0, @@ -617,7 +648,7 @@ void FramebufferRenderer::updateResolution() { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // FXAA - glBindTexture(GL_TEXTURE_2D, _fxaaBuffers._fxaaTexture); + glBindTexture(GL_TEXTURE_2D, _fxaaBuffers.fxaaTexture); glTexImage2D( GL_TEXTURE_2D, 0, @@ -843,7 +874,7 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac } // deferred g-buffer - glBindFramebuffer(GL_FRAMEBUFFER, _gBuffers._framebuffer); + glBindFramebuffer(GL_FRAMEBUFFER, _gBuffers.framebuffer); glDrawBuffers(3, ColorAttachment012Array); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -904,7 +935,7 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac glDisable(GL_DEPTH_TEST); if (_enableFXAA) { - glBindFramebuffer(GL_FRAMEBUFFER, _fxaaBuffers._fxaaFramebuffer); + glBindFramebuffer(GL_FRAMEBUFFER, _fxaaBuffers.fxaaFramebuffer); } else { // When applying the TMO, the result is saved to the default FBO to be displayed @@ -938,7 +969,7 @@ void FramebufferRenderer::performRaycasterTasks(const std::vector exitProgram->deactivate(); } - glBindFramebuffer(GL_FRAMEBUFFER, _gBuffers._framebuffer); + glBindFramebuffer(GL_FRAMEBUFFER, _gBuffers.framebuffer); glm::vec3 cameraPosition; bool isCameraInside = raycaster->isCameraInside( raycasterTask.renderData, @@ -984,7 +1015,7 @@ void FramebufferRenderer::performRaycasterTasks(const std::vector ghoul::opengl::TextureUnit mainDepthTextureUnit; mainDepthTextureUnit.activate(); - glBindTexture(GL_TEXTURE_2D, _gBuffers._depthTexture); + glBindTexture(GL_TEXTURE_2D, _gBuffers.depthTexture); raycastProgram->setUniform("mainDepthTexture", mainDepthTextureUnit); raycastProgram->setUniform("windowSize", static_cast(_resolution)); @@ -1049,7 +1080,7 @@ void FramebufferRenderer::performDeferredTasks( ghoul::opengl::TextureUnit mainPositionTextureUnit; mainPositionTextureUnit.activate(); - glBindTexture(GL_TEXTURE_2D, _gBuffers._positionTexture); + glBindTexture(GL_TEXTURE_2D, _gBuffers.positionTexture); deferredcastProgram->setUniform( "mainPositionTexture", mainPositionTextureUnit @@ -1057,7 +1088,7 @@ void FramebufferRenderer::performDeferredTasks( ghoul::opengl::TextureUnit mainNormalTextureUnit; mainNormalTextureUnit.activate(); - glBindTexture(GL_TEXTURE_2D, _gBuffers._normalTexture); + glBindTexture(GL_TEXTURE_2D, _gBuffers.normalTexture); deferredcastProgram->setUniform( "mainNormalTexture", mainNormalTextureUnit @@ -1100,7 +1131,7 @@ void FramebufferRenderer::setResolution(glm::ivec2 res) { _dirtyResolution = true; } -void FramebufferRenderer::disableHDR(bool disable) { +void FramebufferRenderer::setDisableHDR(bool disable) { _disableHDR = std::move(disable); } diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index 2d76e36340..72d6bd8014 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -275,7 +275,7 @@ RenderEngine::RenderEngine() , _enableFXAA(FXAAInfo, true) , _disableHDRPipeline(DisableHDRPipelineInfo, false) , _hdrExposure(HDRExposureInfo, 3.7f, 0.01f, 10.0f) - , _gamma(GammaInfo, 0.86f, 0.01f, 5.0f) + , _gamma(GammaInfo, 0.95f, 0.01f, 5.0f) , _hue(HueInfo, 180.f, 0.0f, 360.0f) , _saturation(SaturationInfo, 1.f, 0.0f, 2.0f) , _value(ValueInfo, 1.f, 0.0f, 2.0f) @@ -297,7 +297,7 @@ RenderEngine::RenderEngine() glm::vec3(0.f), glm::vec3(-glm::pi()), glm::vec3(glm::pi()) - ) + ) { _doPerformanceMeasurements.onChange([this](){ global::performanceManager.setEnabled(_doPerformanceMeasurements); @@ -318,7 +318,7 @@ RenderEngine::RenderEngine() _disableHDRPipeline.onChange([this]() { if (_renderer) { - _renderer->disableHDR(_disableHDRPipeline); + _renderer->setDisableHDR(_disableHDRPipeline); } }); addProperty(_disableHDRPipeline);