mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-03-06 12:28:34 -06:00
Improved final image quality. Enabled automatic bloom. Fixed inverse HDR.
This commit is contained in:
@@ -17,13 +17,14 @@ asset.onInitialize(function ()
|
||||
openspace.globebrowsing.goToGeo(58.5877, 16.1924, 20000000)
|
||||
|
||||
-- HDR / Image options:
|
||||
openspace.setPropertyValueSingle('RenderEngine.Gamma', 0.86);
|
||||
openspace.setPropertyValueSingle('RenderEngine.HDRExposure', 1.68);
|
||||
openspace.setPropertyValueSingle('RenderEngine.Gamma', 0.95);
|
||||
openspace.setPropertyValueSingle('RenderEngine.HDRExposure', 3.7);
|
||||
openspace.setPropertyValueSingle('RenderEngine.ToneMapOperator', 8);
|
||||
openspace.setPropertyValueSingle('RenderEngine.Lightness', 1.1);
|
||||
openspace.setPropertyValueSingle('RenderEngine.Saturation', 1.45);
|
||||
openspace.setPropertyValueSingle('RenderEngine.BloomNewColorFactor', 6.0);
|
||||
--openspace.setPropertyValueSingle('RenderEngine.', );
|
||||
openspace.setPropertyValueSingle('RenderEngine.Saturation', 1.2);
|
||||
openspace.setPropertyValueSingle('RenderEngine.BloomThreshouldMin', 0.15);
|
||||
openspace.setPropertyValueSingle('RenderEngine.BloomThreshouldMax', 2.0);
|
||||
openspace.setPropertyValueSingle('RenderEngine.BloomNewColorFactor', 4.7);
|
||||
|
||||
end)
|
||||
|
||||
|
||||
@@ -175,6 +175,7 @@ public:
|
||||
void setColorSpace(unsigned int colorspace) override;
|
||||
|
||||
void enableBloom(bool enable) override;
|
||||
void enableAutomaticBloom(bool enable) override;
|
||||
void enableHistogram(bool enable) override;
|
||||
|
||||
int nAaSamples() const override;
|
||||
@@ -265,22 +266,23 @@ private:
|
||||
glm::ivec2 _resolution = glm::ivec2(0);
|
||||
int _nAaSamples;
|
||||
int _blurrinessLevel = 1;
|
||||
float _hdrExposure = 1.68f;
|
||||
float _gamma = 0.86f;
|
||||
float _hdrExposure = 3.7f;
|
||||
float _gamma = 0.95f;
|
||||
float _maxWhite = 1.0f;
|
||||
bool _bloomEnabled = false;
|
||||
float _bloomThresholdMin = 0.0;
|
||||
float _bloomThresholdMax = 1.0;
|
||||
bool _automaticBloomEnabled = false;
|
||||
float _bloomThresholdMin = 0.5;
|
||||
float _bloomThresholdMax = 8.1;
|
||||
float _bloomOrigFactor = 1.0;
|
||||
float _bloomNewFactor = 1.0;
|
||||
int _toneMapOperator = 8; // JCC TODO: temporarilly set to 8 because setProperty seems not to be working for OptionProperty
|
||||
int _toneMapOperator = 8;
|
||||
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.45f;
|
||||
float _saturation = 1.2f;
|
||||
float _value = 1.f;
|
||||
float _lightness = 1.1f;
|
||||
unsigned int _colorSpace = 1;
|
||||
|
||||
@@ -69,6 +69,7 @@ public:
|
||||
virtual void setColorSpace(unsigned int colorspace) = 0;
|
||||
|
||||
virtual void enableBloom(bool enable) = 0;
|
||||
virtual void enableAutomaticBloom(bool enable) = 0;
|
||||
virtual void enableHistogram(bool enable) = 0;
|
||||
|
||||
virtual int nAaSamples() const = 0;
|
||||
|
||||
@@ -25,22 +25,24 @@
|
||||
#include "floatoperations.glsl"
|
||||
#include <#{fragmentPath}>
|
||||
|
||||
#define exposure #{rendererData.hdrExposure}
|
||||
#define automaticBloom #{rendererData.automaticBloom}
|
||||
#define bloom_thresh_min #{rendererData.bloom_thresh_min}
|
||||
#define bloom_thresh_max #{rendererData.bloom_thresh_max}
|
||||
|
||||
layout(location = 0) out vec4 _out_color_;
|
||||
layout(location = 1) out vec4 gPosition;
|
||||
layout(location = 2) out vec4 gNormal;
|
||||
layout(location = 3) out vec4 filterBuffer;
|
||||
|
||||
uniform bool automaticBloom;
|
||||
uniform float bloom_thresh_min;
|
||||
uniform float bloom_thresh_max;
|
||||
|
||||
void main() {
|
||||
Fragment f = getFragment();
|
||||
_out_color_ = f.color;
|
||||
_out_color_ = vec4((log2(vec3(1.0) - f.color.rgb)/(-exposure)), f.color.a);
|
||||
//_out_color_ = f.color;
|
||||
gPosition = f.gPosition;
|
||||
gNormal = f.gNormal;
|
||||
|
||||
if (automaticBloom) {
|
||||
if (automaticBloom == 1) {
|
||||
// Extract luminance
|
||||
float Y = dot(f.color.rgb, vec3(0.299, 0.587, 0.144));
|
||||
|
||||
|
||||
@@ -1082,7 +1082,7 @@ void FramebufferRenderer::updateResolution() {
|
||||
glTexImage2DMultisample(
|
||||
GL_TEXTURE_2D_MULTISAMPLE,
|
||||
_nAaSamples,
|
||||
GL_RGBA16F,
|
||||
GL_RGBA32F,
|
||||
_resolution.x,
|
||||
_resolution.y,
|
||||
GL_TRUE
|
||||
@@ -1092,7 +1092,7 @@ void FramebufferRenderer::updateResolution() {
|
||||
glTexImage2DMultisample(
|
||||
GL_TEXTURE_2D_MULTISAMPLE,
|
||||
_nAaSamples,
|
||||
GL_RGBA16F,
|
||||
GL_RGBA32F,
|
||||
_resolution.x,
|
||||
_resolution.y,
|
||||
GL_TRUE
|
||||
@@ -1133,7 +1133,7 @@ void FramebufferRenderer::updateResolution() {
|
||||
glTexImage2DMultisample(
|
||||
GL_TEXTURE_2D_MULTISAMPLE,
|
||||
_nAaSamples,
|
||||
GL_RGBA16F,
|
||||
GL_RGBA32F,
|
||||
_resolution.x,
|
||||
_resolution.y,
|
||||
GL_TRUE
|
||||
@@ -1146,7 +1146,7 @@ void FramebufferRenderer::updateResolution() {
|
||||
glTexImage2D(
|
||||
GL_TEXTURE_2D,
|
||||
0,
|
||||
GL_RGBA16F,
|
||||
GL_RGBA32F,
|
||||
_resolution.x,
|
||||
_resolution.y,
|
||||
0,
|
||||
@@ -1181,7 +1181,7 @@ void FramebufferRenderer::updateResolution() {
|
||||
glTexImage2DMultisample(
|
||||
GL_TEXTURE_2D_MULTISAMPLE,
|
||||
_nAaSamples,
|
||||
GL_RGBA16F,
|
||||
GL_RGBA32F,
|
||||
i ? _resolution.x : _resolution.y,
|
||||
i ? _resolution.y : _resolution.x,
|
||||
GL_TRUE
|
||||
@@ -1196,6 +1196,7 @@ void FramebufferRenderer::updateResolution() {
|
||||
GL_RGBA32F,
|
||||
_numberOfBins,
|
||||
1,
|
||||
|
||||
0,
|
||||
GL_RGBA,
|
||||
GL_FLOAT,
|
||||
@@ -2131,6 +2132,7 @@ void FramebufferRenderer::setBlurrinessLevel(int level) {
|
||||
void FramebufferRenderer::setHDRExposure(float hdrExposure) {
|
||||
ghoul_assert(hdrExposure > 0.f, "HDR exposure must be greater than zero");
|
||||
_hdrExposure = hdrExposure;
|
||||
updateRendererData();
|
||||
}
|
||||
|
||||
void FramebufferRenderer::setGamma(float gamma) {
|
||||
@@ -2149,10 +2151,12 @@ void FramebufferRenderer::setToneMapOperator(int tmOp) {
|
||||
|
||||
void FramebufferRenderer::setBloomThreMin(float minV) {
|
||||
_bloomThresholdMin = minV;
|
||||
updateRendererData();
|
||||
}
|
||||
|
||||
void FramebufferRenderer::setBloomThreMax(float maxV) {
|
||||
_bloomThresholdMax = maxV;
|
||||
updateRendererData();
|
||||
}
|
||||
|
||||
void FramebufferRenderer::setBloomOrigFactor(float origFactor) {
|
||||
@@ -2199,6 +2203,14 @@ void FramebufferRenderer::enableBloom(bool enable) {
|
||||
_bloomEnabled = enable;
|
||||
}
|
||||
|
||||
void FramebufferRenderer::enableAutomaticBloom(bool enable) {
|
||||
_automaticBloomEnabled = enable;
|
||||
if (_automaticBloomEnabled) {
|
||||
_bloomEnabled = true;
|
||||
}
|
||||
updateRendererData();
|
||||
}
|
||||
|
||||
void FramebufferRenderer::enableHistogram(bool enable) {
|
||||
_histogramEnabled = enable;
|
||||
}
|
||||
@@ -2214,6 +2226,10 @@ const std::vector<double>& FramebufferRenderer::mSSAPattern() const {
|
||||
void FramebufferRenderer::updateRendererData() {
|
||||
ghoul::Dictionary dict;
|
||||
dict.setValue("fragmentRendererPath", std::string(RenderFragmentShaderPath));
|
||||
dict.setValue("hdrExposure", std::to_string(_hdrExposure));
|
||||
dict.setValue("automaticBloom", std::to_string(_automaticBloomEnabled));
|
||||
dict.setValue("bloom_thresh_min", std::to_string(_bloomThresholdMin));
|
||||
dict.setValue("bloom_thresh_max", std::to_string(_bloomThresholdMax));
|
||||
_rendererData = dict;
|
||||
global::renderEngine.setRendererData(dict);
|
||||
}
|
||||
|
||||
@@ -543,9 +543,9 @@ RenderEngine::RenderEngine()
|
||||
addProperty(_enableBloom);
|
||||
|
||||
_automaticBloom.onChange([this]() {
|
||||
if (_renderer && _automaticBloom) {
|
||||
_renderer->enableBloom(true);
|
||||
_enableBloom = true;
|
||||
if (_renderer) {
|
||||
_renderer->enableAutomaticBloom(_automaticBloom);
|
||||
_renderer->enableBloom(_automaticBloom);
|
||||
}
|
||||
});
|
||||
addProperty(_automaticBloom);
|
||||
|
||||
Reference in New Issue
Block a user