Merge branch 'feature/FXAA' into integration/FXAA_Vol_Milkway

This commit is contained in:
Alexander Bock
2019-08-20 14:49:31 +02:00
13 changed files with 163 additions and 186 deletions

View File

@@ -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;

View File

@@ -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 ()

View File

@@ -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

View File

@@ -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<ghoul::opengl::ProgramObject>
> RaycasterProgObjMap;
typedef std::map<
Deferredcaster*,
std::unique_ptr<ghoul::opengl::ProgramObject>
> 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<RaycasterTask>& tasks);
@@ -162,10 +98,19 @@ public:
DeferredcasterListener::IsAttached isAttached) override;
private:
using RaycasterProgObjMap = std::map<
VolumeRaycaster*,
std::unique_ptr<ghoul::opengl::ProgramObject>
>;
using DeferredcasterProgObjMap = std::map<
Deferredcaster*,
std::unique_ptr<ghoul::opengl::ProgramObject>
>;
void resolveMSAA(float blackoutFactor);
void applyTMO(float blackoutFactor);
void applyFXAA();
private:
std::map<VolumeRaycaster*, RaycastData> _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;

View File

@@ -34,8 +34,6 @@
#include <openspace/properties/vector/vec3property.h>
#include <openspace/properties/triggerproperty.h>
#include <ghoul/opengl/ghoul_gl.h>
namespace ghoul {
class Dictionary;
class SharedMemory;

View File

@@ -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.

View File

@@ -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 *

View File

@@ -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);
}
}

View File

@@ -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 *

View File

@@ -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));
}

View File

@@ -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<std::string>(KeyAnchor);
const bool hasPosition = dictionary.hasValue<glm::dvec3>(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<glm::dvec3> up,
double yaw,
double pitch)
NavigationHandler::NavigationState::NavigationState(std::string anchor, std::string aim,
std::string referenceFrame,
glm::dvec3 position,
std::optional<glm::dvec3> 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,

View File

@@ -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<double>& 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<RaycasterTask>
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<RaycasterTask>
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<glm::vec2>(_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);
}

View File

@@ -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<float>()),
glm::vec3(glm::pi<float>())
)
)
{
_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);