From 05021973365a0a30cd598691c17e67a9ad11ddae Mon Sep 17 00:00:00 2001 From: Jonathas Costa Date: Mon, 25 Feb 2019 10:02:25 -0500 Subject: [PATCH] Improved memory consumption and performance. Added default parameters. --- data/assets/default.scene | 9 +++++-- .../openspace/rendering/framebufferrenderer.h | 2 +- include/openspace/rendering/renderengine.h | 24 +++++++++---------- .../shaders/atmosphere_deferred_fs.glsl | 16 ++++++++----- shaders/framebuffer/hdrAndFiltering.frag | 2 +- src/rendering/framebufferrenderer.cpp | 6 ++--- 6 files changed, 34 insertions(+), 25 deletions(-) diff --git a/data/assets/default.scene b/data/assets/default.scene index 4e53b0a0a7..90777c2e39 100644 --- a/data/assets/default.scene +++ b/data/assets/default.scene @@ -104,8 +104,13 @@ asset.onInitialize(function () openspace.globebrowsing.goToGeo(58.5877, 16.1924, 20000000) -- HDR / Image options: - openspace.setPropertyValueSingle('RenderEngine.Gamma', 1.8); - + openspace.setPropertyValueSingle('RenderEngine.Gamma', 0.47); + openspace.setPropertyValueSingle('RenderEngine.HDRExposure', 0.47); + openspace.setPropertyValueSingle('RenderEngine.Background Exposure', 7.85); + openspace.setPropertyValueSingle('RenderEngine.ToneMapOperator', 8); + openspace.setPropertyValueSingle('RenderEngine.Lightness', 0.995); + openspace.setPropertyValueSingle('RenderEngine.BloomNewColorFactor', 9.0); + --openspace.setPropertyValueSingle('RenderEngine.', ); end) diff --git a/include/openspace/rendering/framebufferrenderer.h b/include/openspace/rendering/framebufferrenderer.h index 1c7b8e0e6c..1f2694fea6 100644 --- a/include/openspace/rendering/framebufferrenderer.h +++ b/include/openspace/rendering/framebufferrenderer.h @@ -211,7 +211,7 @@ private: float _bloomThresholdMax = 1.0; float _bloomOrigFactor = 1.0; float _bloomNewFactor = 1.0; - int _toneMapOperator = 0; + int _toneMapOperator = 8; // JCC TODO: temporarilly set to 8 because setProperty seems not to be working for OptionProperty bool _histogramEnabled = false; int _numberOfBins = 1024; // JCC TODO: Add a parameter control for this. float _tmoKey = 0.18f; diff --git a/include/openspace/rendering/renderengine.h b/include/openspace/rendering/renderengine.h index ea9ef56e48..3c8dfe318f 100644 --- a/include/openspace/rendering/renderengine.h +++ b/include/openspace/rendering/renderengine.h @@ -68,18 +68,18 @@ public: // defines in hdr.glsl file. enum class ToneMapOperators { EXPONENTIAL = 0, - LINEAR, - SIMPLE_REINHARD, - LUM_BASED_REINHARD, - WHITE_PRESERVING, - ROM_BIN_DA_HOUSE, - FILMIC, - UNCHARTED, - COSTA, - ADAPTIVE, - GLOBAL, - PHOTOGRAPHIC_REINHARD, - MIPMAPPING + LINEAR, //1 + SIMPLE_REINHARD, //2 + LUM_BASED_REINHARD, //3 + WHITE_PRESERVING, //4 + ROM_BIN_DA_HOUSE, //5 + FILMIC, //6 + UNCHARTED, //7 + COSTA, //8 + ADAPTIVE, //8 + GLOBAL, //9 + PHOTOGRAPHIC_REINHARD, //10 + MIPMAPPING //11 }; enum class COLORSPACE { diff --git a/modules/atmosphere/shaders/atmosphere_deferred_fs.glsl b/modules/atmosphere/shaders/atmosphere_deferred_fs.glsl index deb258f12c..451aa7405f 100644 --- a/modules/atmosphere/shaders/atmosphere_deferred_fs.glsl +++ b/modules/atmosphere/shaders/atmosphere_deferred_fs.glsl @@ -422,6 +422,7 @@ vec3 inscatterRadiance(inout vec3 x, inout float t, inout float irradianceFactor // we can change it on the fly with no precomputations) // return radiance * sunRadiance; vec3 finalScatteringRadiance = radiance * sunIntensity; + if (groundHit) { return finalScatteringRadiance; } else { @@ -542,6 +543,7 @@ void main() { if (cullAtmosphere == 0) { vec4 atmosphereFinalColor = vec4(0.0f); + vec4 backgroundFinalColor = vec4(0.0f); int nSamples = 1; // First we determine if the pixel is complex (different fragments on it) @@ -691,14 +693,18 @@ void main() { } else { // no intersection //atmosphereFinalColor += vec4(HDR(color.xyz * backgroundConstant, atmExposure), color.a); - atmosphereFinalColor += vec4(color.xyz * backgroundConstant, color.a); + //atmosphereFinalColor += vec4(color.xyz * backgroundConstant, color.a); + //backgroundFinalColor += color; + discard; } } - renderTarget = atmosphereFinalColor / float(nSamples); + renderTarget = atmosphereFinalColor / float(nSamples); - // if (complex) - // renderTarget = vec4(1.0, 0.0, 0.0, 1.0); + // renderTarget = vec4( + // (atmosphereFinalColor.xyz + (backgroundFinalColor.xyz * backgroundConstant)) / float(nSamples), + // (atmosphereFinalColor.a + backgroundFinalColor.a) / float(nSamples) + // ); } else { // culling if (firstPaint) { @@ -714,8 +720,6 @@ void main() { else { discard; } - //renderTarget = vec4(1.0, 0.0, 0.0, 1.0); - } } diff --git a/shaders/framebuffer/hdrAndFiltering.frag b/shaders/framebuffer/hdrAndFiltering.frag index 781cd11b74..afa8de682f 100644 --- a/shaders/framebuffer/hdrAndFiltering.frag +++ b/shaders/framebuffer/hdrAndFiltering.frag @@ -119,7 +119,7 @@ void main() { } if (colorSpace == HSL_COLOR) { - vec3 hslColor = rgb2hsl(tColor); + vec3 hslColor = rgb2hsl(tColor); hslColor.x *= Hue; hslColor.y *= Saturation; hslColor.z *= Lightness; diff --git a/src/rendering/framebufferrenderer.cpp b/src/rendering/framebufferrenderer.cpp index f015a3bb9c..008289dfcc 100644 --- a/src/rendering/framebufferrenderer.cpp +++ b/src/rendering/framebufferrenderer.cpp @@ -855,7 +855,7 @@ void FramebufferRenderer::updateResolution() { glTexImage2DMultisample( GL_TEXTURE_2D_MULTISAMPLE, _nAaSamples, - GL_RGBA32F, + GL_RGBA16F, _resolution.x, _resolution.y, true @@ -866,7 +866,7 @@ void FramebufferRenderer::updateResolution() { glTexImage2DMultisample( GL_TEXTURE_2D_MULTISAMPLE, _nAaSamples, - GL_RGBA32F, + GL_RGBA16F, _resolution.x, _resolution.y, true @@ -878,7 +878,7 @@ void FramebufferRenderer::updateResolution() { glTexImage2D( GL_TEXTURE_2D, 0, - GL_RGBA32F, + GL_RGBA16F, _resolution.x, _resolution.y, 0,