Separated filters and cache from HDR.

This commit is contained in:
Jonathas Costa
2019-07-22 10:25:44 -04:00
parent dc1ab017c6
commit df6c90b1ee
17 changed files with 55 additions and 1721 deletions

View File

@@ -22,10 +22,6 @@ asset.onInitialize(function ()
openspace.setPropertyValueSingle('RenderEngine.ToneMapOperator', 8);
openspace.setPropertyValueSingle('RenderEngine.Lightness', 1.1);
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)
asset.onDeinitialize(function ()

View File

@@ -93,7 +93,6 @@ private:
typedef struct {
GLuint _colorTexture;
GLuint _filterTexture;
GLuint _positionTexture;
GLuint _normalTexture;
GLuint _depthTexture;
@@ -105,35 +104,11 @@ private:
GLuint colorTexture[2];
} PingPongBuffers;
typedef struct {
GLuint _histoVao;
GLuint _histoVbo;
GLuint _histoTexture;
GLuint _histoFramebuffer;
} HistoBuffers;
typedef struct {
GLuint _bloomVAO = 0u;
GLuint _bloomFilterFBO[3];
GLuint _bloomTexture[3];
} BloomBuffers;
typedef struct {
GLuint _hdrFilteringFramebuffer;
GLuint _hdrFilteringTexture;
} HDRBuffers;
typedef struct {
GLuint _computeAveLumFBO;
GLuint _computeAveLumTexture;
} AverageLumBuffers;
typedef struct {
GLuint _tmoTexture;
GLuint _tmoFramebuffer;
GLuint _tmoHdrSampler;
} MipMappingTMOBuffers;
public:
typedef std::map<
VolumeRaycaster*,
@@ -153,23 +128,14 @@ public:
void updateRaycastData();
void updateDeferredcastData();
void updateHDRAndFiltering();
void updateAveLum();
void updateBloomConfig();
void updateHistogramConfig();
void updateTMOViaMipMappingConfig();
void updateMSAASamplingPattern();
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;
@@ -179,10 +145,6 @@ public:
void setLightness(float lightness) override;
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;
const std::vector<double>& mSSAPattern() const override;
@@ -203,16 +165,9 @@ public:
DeferredcasterListener::IsAttached isAttached) override;
private:
void captureAndSetOpenGLDefaultState();
void resolveMSAA(float blackoutFactor);
void applyTMO(float blackoutFactor);
float computeBufferAveLuminance();
float computeBufferAveLuminanceGPU();
void applyBloomFilter(bool noDeferredTaskExecuted);
void computeImageHistogram();
void computeMipMappingFromHDRBuffer(GLuint oglImageBuffer);
private:
std::map<VolumeRaycaster*, RaycastData> _raycastData;
RaycasterProgObjMap _exitPrograms;
@@ -223,11 +178,6 @@ private:
DeferredcasterProgObjMap _deferredcastPrograms;
std::unique_ptr<ghoul::opengl::ProgramObject> _hdrFilteringProgram;
std::unique_ptr<ghoul::opengl::ProgramObject> _aveLumProgram;
std::unique_ptr<ghoul::opengl::ProgramObject> _bloomProgram;
std::unique_ptr<ghoul::opengl::ProgramObject> _bloomResolveProgram;
std::unique_ptr<ghoul::opengl::ProgramObject> _histoProgram;
std::unique_ptr<ghoul::opengl::ProgramObject> _histoApplyProgram;
std::unique_ptr<ghoul::opengl::ProgramObject> _tmoProgram;
std::unique_ptr<ghoul::opengl::ProgramObject> _resolveProgram;
@@ -237,16 +187,7 @@ private:
toneMapOperator, aveLum, maxWhite, Hue, Saturation, Value,
Lightness, colorSpace, nAaSamples) _hdrUniformCache;
UniformCache(renderedImage, bloomImage, bloomOrigFactor, bloomNewFactor,
numberOfSamples) _bloomUniformCache;
UniformCache(numberOfSamples, msaaTexture, blurriness)
_bloomFilterUniformCache;
UniformCache(renderedImage, maxWhite, imageWidth, imageHeight) _histoUniformCache;
UniformCache(hdrSampler, key, Ywhite, sat) _tmoUniformCache;
GLint _defaultFBO;
GLuint _screenQuad;
GLuint _vertexPositionBuffer;
GLuint _exitColorTexture;
@@ -255,12 +196,8 @@ private:
GBuffers _gBuffers;
PingPongBuffers _pingPongBuffers;
HistoBuffers _histoBuffers;
BloomBuffers _bloomBuffers;
HDRBuffers _hdrBuffers;
AverageLumBuffers _aLumBuffers;
MipMappingTMOBuffers _mMappingTMOBuffers;
unsigned int _pingPongIndex = 0u;
bool _dirtyDeferredcastData;
@@ -270,19 +207,11 @@ private:
glm::ivec2 _resolution = glm::ivec2(0);
int _nAaSamples;
int _blurrinessLevel = 1;
float _hdrExposure = 3.7f;
float _gamma = 0.95f;
float _maxWhite = 1.0f;
bool _bloomEnabled = false;
bool _automaticBloomEnabled = false;
float _bloomThresholdMin = 0.5f;
float _bloomThresholdMax = 8.1f;
float _bloomOrigFactor = 1.0f;
float _bloomNewFactor = 1.0f;
float _maxWhite = 5.0f;
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;
@@ -296,9 +225,6 @@ private:
std::vector<float> _histoPoints;
ghoul::Dictionary _rendererData;
// Capture Default OpenSpace GL State
RenderEngine::GLDefaultState _osDefaultGLState;
};
} // namespace openspace

View File

@@ -88,23 +88,6 @@ public:
HSL
};
struct GLDefaultState {
GLboolean blendEnabled;
GLboolean blend0Enabled;
GLboolean blend1Enabled;
GLboolean blend2Enabled;
GLboolean blend3Enabled;
GLboolean cullFaceEnabled;
GLboolean depthTestEnabled;
GLint defaultFBO;
GLenum blendEquationRGB;
GLenum blendEquationAlpha;
GLenum blendDestAlpha;
GLenum blendDestRGB;
GLenum blendSrcAlpha;
GLenum blendSrcRGB;
};
RenderEngine();
~RenderEngine();
@@ -191,9 +174,6 @@ public:
*/
static scripting::LuaLibrary luaLibrary();
const RenderEngine::GLDefaultState& glDefaultState() const;
void setGLDefaultState(RenderEngine::GLDefaultState glDS);
glm::ivec2 renderingResolution() const;
glm::ivec2 fontResolution() const;
@@ -216,8 +196,6 @@ private:
Camera* _camera = nullptr;
Scene* _scene = nullptr;
GLDefaultState _glDefaultState;
properties::BoolProperty _doPerformanceMeasurements;
std::unique_ptr<Renderer> _renderer;
@@ -240,15 +218,6 @@ private:
properties::FloatProperty _globalBlackOutFactor;
properties::IntProperty _nAaSamples;
properties::PropertyOwner _bloomOwner;
properties::BoolProperty _enableBloom;
properties::BoolProperty _automaticBloom;
properties::IntProperty _bloomBlurrinessLevel;
properties::FloatProperty _bloomThreshouldMin;
properties::FloatProperty _bloomThreshouldMax;
properties::FloatProperty _bloomOrigColorFactor;
properties::FloatProperty _bloomNewColorFactor;
properties::PropertyOwner _tmoOwner;
properties::FloatProperty _hdrExposure;
properties::FloatProperty _maxWhite;

View File

@@ -50,15 +50,10 @@ public:
virtual void setResolution(glm::ivec2 res) = 0;
virtual void setNAaSamples(int nAaSamples) = 0;
virtual void setBlurrinessLevel(int level) = 0;
virtual void setHDRExposure(float hdrExposure) = 0;
virtual void setGamma(float gamma) = 0;
virtual void setMaxWhite(float maxWhite) = 0;
virtual void setToneMapOperator(int tmOp) = 0;
virtual void setBloomThreMin(float minV) = 0;
virtual void setBloomThreMax(float maxV) = 0;
virtual void setBloomOrigFactor(float origFactor) = 0;
virtual void setBloomNewFactor(float newFactor) = 0;
virtual void setKey(float key) = 0;
virtual void setYwhite(float white) = 0;
virtual void setTmoSaturation(float sat) = 0;
@@ -68,10 +63,6 @@ public:
virtual void setLightness(float lightness) = 0;
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;
virtual const std::vector<double>& mSSAPattern() const = 0;

View File

@@ -1,159 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2018 *
* *
* 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. *
****************************************************************************************/
#version __CONTEXT__
layout (location = 0) out vec4 finalColor;
uniform int numberOfSamples;
uniform int blurriness;
uniform sampler2DMS msaaTexture;
// Gaussian Weights from OpenGL SuperBible 7 ed.
const float weights2[] = float[](0.0024499299678342,
0.0043538453346397,
0.0073599963704157,
0.0118349786570722,
0.0181026699707781,
0.0263392293891488,
0.0364543006660986,
0.0479932050577658,
0.0601029809166942,
0.0715974486241365,
0.0811305381519717,
0.0874493212267511,
0.0896631113333857,
0.0874493212267511,
0.0811305381519717,
0.0715974486241365,
0.0601029809166942,
0.0479932050577658,
0.0364543006660986,
0.0263392293891488,
0.0181026699707781,
0.0118349786570722,
0.0073599963704157,
0.0043538453346397,
0.0024499299678342);
// Gaussian weights calculated by http://dev.theomader.com/gaussian-kernel-calculator/
// sigma = 4.4625, kernel size = 5
const float weights1[] = float[](0.190079,
0.204885,
0.210072,
0.204885,
0.190079);
// Gaussian weights calculated by http://dev.theomader.com/gaussian-kernel-calculator/
// sigma = 8, kernel size = 45
const float weights3[] = float[](0.001147,
0.001605,
0.002209,
0.002995,
0.003998,
0.005253,
0.006795,
0.008655,
0.010852,
0.013397,
0.016283,
0.019484,
0.022952,
0.02662,
0.030396,
0.03417,
0.037817,
0.041206,
0.044204,
0.046685,
0.048543,
0.049692,
0.050082,
0.049692,
0.048543,
0.046685,
0.044204,
0.041206,
0.037817,
0.03417,
0.030396,
0.02662,
0.022952,
0.019484,
0.016283,
0.013397,
0.010852,
0.008655,
0.006795,
0.005253,
0.003998,
0.002995,
0.002209,
0.001605,
0.001147);
vec4 applyConvolution(const int version)
{
vec4 color = vec4(0.0);
// Transpose the image so the filter can be applied on X and Y
// P is the central position in the filter mask
int weightsLength = 0;
if (version == 1) {
weightsLength = weights1.length();
} else if (version == 2) {
weightsLength = weights2.length();
} else if (version == 3) {
weightsLength = weights3.length();
}
ivec2 P = ivec2(gl_FragCoord.yx) - ivec2(0, weightsLength >> 1);
for (int w = 0; w < weightsLength; w++)
{
ivec2 texelCoord = P + ivec2(0, w);
vec4 tmpColor = vec4(0.0);
for (int s = 0; s < numberOfSamples; ++s) {
tmpColor += texelFetch(msaaTexture, texelCoord, s);
}
tmpColor /= numberOfSamples;
if (version == 1) {
color += tmpColor * weights1[w];
} else if (version == 2) {
color += tmpColor * weights2[w];
} else if (version == 3) {
color += tmpColor * weights3[w];
}
}
return color;
}
void main(void)
{
finalColor = applyConvolution(blurriness);
}

View File

@@ -1,35 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2018 *
* *
* 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. *
****************************************************************************************/
#version __CONTEXT__
void main(void)
{
const vec4 vertices[] = vec4[](vec4(-1.0, -1.0, 1.0, 1.0),
vec4( 1.0, -1.0, 1.0, 1.0),
vec4(-1.0, 1.0, 1.0, 1.0),
vec4( 1.0, 1.0, 1.0, 1.0));
gl_Position = vertices[gl_VertexID];
}

View File

@@ -1,49 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2018 *
* *
* 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. *
****************************************************************************************/
#version __CONTEXT__
layout (location = 0) out vec4 finalColor;
uniform int numberOfSamples;
uniform float bloomOrigFactor;
uniform float bloomNewFactor;
uniform sampler2DMS renderedImage;
uniform sampler2DMS bloomImage;
void main(void)
{
vec4 color = vec4(0.0);
vec4 renderedImageTmpColor = vec4(0.0);
vec4 bloomImageTmpColor = vec4(0.0);
for (int s = 0; s < numberOfSamples; ++s) {
renderedImageTmpColor += texelFetch(renderedImage, ivec2(gl_FragCoord), s);
bloomImageTmpColor += texelFetch(bloomImage, ivec2(gl_FragCoord), s);
}
renderedImageTmpColor /= numberOfSamples;
bloomImageTmpColor /= numberOfSamples;
finalColor = renderedImageTmpColor * bloomOrigFactor + bloomImageTmpColor * bloomNewFactor;
}

View File

@@ -1,35 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2018 *
* *
* 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. *
****************************************************************************************/
#version __CONTEXT__
void main(void)
{
const vec4 vertices[] = vec4[](vec4(-1.0, -1.0, 0.5, 1.0),
vec4( 1.0, -1.0, 0.5, 1.0),
vec4(-1.0, 1.0, 0.5, 1.0),
vec4( 1.0, 1.0, 0.5, 1.0));
gl_Position = vertices[gl_VertexID];
}

View File

@@ -1,51 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2018 *
* *
* 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. *
****************************************************************************************/
#version __CONTEXT__
layout (location = 0) out vec4 finalColor;
uniform int bufferWidth;
uniform int bufferHeight;
uniform sampler2D hdrTexture;
in vec2 texCoord;
void main() {
vec4 color = vec4(0.0);
float fH = float(bufferHeight);
float fW = float(bufferWidth);
float sum = 0.f;
for (int i = 0; i < bufferHeight; ++i) {
for (int j = 0; j < bufferWidth; ++j) {
vec2 texCoord = vec2(float(i) / fH, float(j) / fW);
vec4 tmpColor = texture(hdrTexture, texCoord);
float lum = dot(tmpColor.xyz, vec3(0.2126f, 0.7152f, 0.0722f));
sum += log(lum + 0.00001); // 0.00001 to avoid log(0) from black pixels
}
}
finalColor = vec4(vec3(exp(sum / (fH * fW))), 1.0);
}

View File

@@ -1,31 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2018 *
* *
* 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. *
****************************************************************************************/
#version __CONTEXT__
layout(location = 0) in vec4 position;
void main() {
gl_Position = position;
}

View File

@@ -1,35 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2018 *
* *
* 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. *
****************************************************************************************/
#version __CONTEXT__
layout (location = 0) out vec4 finalColor;
in vec3 pColor;
void main()
{
//finalColor = vec4(1.0, 0.0, 0.0, 1.0);
finalColor = vec4(pColor, 1.0);
}

View File

@@ -1,63 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2018 *
* *
* 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. *
****************************************************************************************/
#version __CONTEXT__
layout(location = 0) in vec4 pixelCoord;
uniform float maxWhite;
//uniform int numberOfPixels;
//uniform int numberOfBins;
uniform float imageWidth;
uniform float imageHeight;
uniform sampler2D renderedImage;
flat out vec3 pColor;
void main()
{
vec2 texCoord;
texCoord.x = float(int(pixelCoord.x / imageWidth)) / imageWidth;
texCoord.y = float(int(pixelCoord.x) % int(imageWidth)) / imageHeight;
vec3 pixelColor = texture(renderedImage, texCoord).xyz;
pColor = pixelColor;
float pixelLuminosity = dot(pixelColor, vec3(0.2126f, 0.7152f, 0.0722f));
//gl_Position = vec4(-1.0 + (2.0 * pixelLuminosity / maxWhite), 0.0, 0.0, 1.0);
//gl_Position = vec4(2.0 * texCoord - vec2(1.0), 0.0, 1.0);
//gl_Position = vec4(0.5, 2.0 * texCoord.y - 1.0, 0.0, 1.0);
//gl_Position = vec4(-1.0 + (pixelLuminosity * 0.0078125), -1.0, 0.0, 1.0);
//gl_Position = vec4(0.5, -1.0 + (pixelLuminosity * 0.0078125), 0.0, 1.0);
//gl_Position = vec4(0.0, -1.0 + (2.0 * pixelLuminosity / maxWhite), 0.0, 1.0);
gl_Position = vec4((2.0 * pixelLuminosity / maxWhite) - 1.0, 2.0 * texCoord.y - 1.0, 0.0, 1.0);
gl_PointSize = 1.0;
}

View File

@@ -1,85 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2018 *
* *
* 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. *
****************************************************************************************/
#version __CONTEXT__
#include "hdr.glsl"
layout (location = 0) out vec4 finalColor;
uniform float key;
uniform float Ywhite;
uniform float sat;
uniform sampler2D hdrSampler;
in vec2 texCoord;
vec3 toneMapGlobal(vec3 hdrColor, float logAvgLum) {
vec3 XYZ = srgbToXYZ(hdrColor);
float Y = (key / logAvgLum) * XYZ.y;
float Yd = (Y * (1.0 + Y/(Ywhite * Ywhite))) / (1.0 + Y);
return pow(hdrColor / XYZ.y, vec3(sat)) * Yd;
}
vec3 toneMapLocal(vec3 hdrColor, float logAvgLum) {
vec3 XYZ = srgbToXYZ(hdrColor);
float Y = (key / logAvgLum) * XYZ.y;
float LocalAdaptation;
float factor = key / logAvgLum;
float epsilon = 0.05;
float phi = 8.0;
float scale[7] = float[7](1, 2, 4, 8, 16, 32, 64);
for (int i = 0; i < 7; ++i) {
float V1 = exp(texture(hdrSampler, texCoord, i).a) * factor;
float V2 = exp(texture(hdrSampler, texCoord, i+1).a) * factor;
if ( abs(V1-V2) / ((key * pow(2, phi) / (scale[i] * scale[i])) + V1)
> epsilon ) {
LocalAdaptation = V1;
break;
} else {
LocalAdaptation = V2;
}
}
float Yd = Y / (1.0 + LocalAdaptation);
return pow(hdrColor / XYZ.y, vec3(sat)) * Yd;
}
void main() {
vec3 hdrColor = texture(hdrSampler, texCoord).rgb;
float logAvgLum = exp(texture(hdrSampler, texCoord, 20).a);
//finalColor.rgb = toneMapGlobal(hdrColor, logAvgLum);
finalColor = vec4(toneMapGlobal(hdrColor, logAvgLum), 1.0);
finalColor = vec4(1.0, 0.0, 0.0, 1.0);
}

View File

@@ -1,33 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2018 *
* *
* 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. *
****************************************************************************************/
#version __CONTEXT__
layout(location = 0) in vec4 position;
out vec2 texCoord;
void main() {
texCoord = 0.5 + position.xy * 0.5;
gl_Position = position;
}

View File

@@ -26,10 +26,6 @@
#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}
#define deltaError 0.013
layout(location = 0) out vec4 _out_color_;
@@ -38,26 +34,10 @@ layout(location = 2) out vec4 gNormal;
layout(location = 3) out vec4 filterBuffer;
void main() {
Fragment f = getFragment();
vec4 tmpOutColor = vec4((log2(vec3(1.0) - (f.color.rgb - vec3(deltaError)))/(-exposure)), f.color.a);
//_out_color_ = f.color;
gPosition = f.gPosition;
gNormal = f.gNormal;
Fragment f = getFragment();
_out_color_ = vec4((log2(vec3(1.0) - (f.color.rgb - vec3(deltaError)))/(-exposure)), f.color.a);
gPosition = f.gPosition;
gNormal = f.gNormal;
if (automaticBloom == 1) {
// Extract luminance
float Y = dot(f.color.rgb, vec3(0.299, 0.587, 0.144));
// Apply Bloom on the bloom threshold range values
vec3 bColor = tmpOutColor.rgb * smoothstep(bloom_thresh_min, bloom_thresh_max, Y);
filterBuffer = vec4(bColor, f.color.a);
} else {
if (f.filterFlag == 1)
filterBuffer = f.color;
else
filterBuffer = vec4(0);
}
_out_color_ = tmpOutColor;
gl_FragDepth = normalizeFloat(f.depth);
gl_FragDepth = normalizeFloat(f.depth);
}

File diff suppressed because it is too large Load Diff

View File

@@ -228,30 +228,6 @@ namespace {
"Max value for white color [0.01-10.0] to be used by tone mapping operators."
};
constexpr openspace::properties::Property::PropertyInfo BloomThreshouldMinInfo = {
"BloomThreshouldMin",
"Bloom Threshould Min Value",
"Min value a pixel must have to be bloomed."
};
constexpr openspace::properties::Property::PropertyInfo BloomThreshouldMaxInfo = {
"BloomThreshouldMax",
"Bloom Threshould Max Value",
"Max value a pixel must have to be bloomed."
};
constexpr openspace::properties::Property::PropertyInfo BloomOrigColorFactorInfo = {
"BloomOrigColorFactor",
"Bloom Original Color Factor Value",
"Bloom Original Color Factor Value."
};
constexpr openspace::properties::Property::PropertyInfo BloomNewColorFactorInfo = {
"BloomNewColorFactor",
"Bloom New Color Factor Value",
"Bloom New Color Factor Value."
};
constexpr openspace::properties::Property::PropertyInfo ToneMapOperatorInfo = {
"ToneMapOperator",
"ToneMap Operator",
@@ -259,24 +235,6 @@ namespace {
"pixels using a LDR distribution."
};
constexpr openspace::properties::Property::PropertyInfo EnableBloomInfo = {
"EnableBloom",
"Enable/Disable Bloom",
"Enable/Disable Bloom."
};
constexpr openspace::properties::Property::PropertyInfo AutomaticBloomInfo = {
"AutomaticBloom",
"Enable/Disable Automatic Bloom",
"Enable/Disable Automatic Bloom."
};
constexpr openspace::properties::Property::PropertyInfo BlurrinessLevelBloomInfo = {
"BlurrinessLevelBloom",
"Increase/Decrease Bloom Blurriness Level",
"Increase/Decrease Bloom Blurriness Level."
};
constexpr openspace::properties::Property::PropertyInfo HueInfo = {
"Hue",
"Hue",
@@ -301,12 +259,6 @@ namespace {
"Lightness"
};
openspace::properties::PropertyOwner::PropertyOwnerInfo BloomInfo = {
"BloomOp",
"Bloom Options",
""
};
openspace::properties::PropertyOwner::PropertyOwnerInfo TMOInfo = {
"ToneMappingOp",
"Tone Mapping Options",
@@ -357,14 +309,6 @@ RenderEngine::RenderEngine()
, _disableMasterRendering(DisableMasterInfo, false)
, _globalBlackOutFactor(GlobalBlackoutFactorInfo, 1.f, 0.f, 1.f)
, _nAaSamples(AaSamplesInfo, 4, 1, 8)
, _bloomOwner(BloomInfo)
, _enableBloom(EnableBloomInfo, false)
, _automaticBloom(AutomaticBloomInfo, false)
, _bloomBlurrinessLevel(BlurrinessLevelBloomInfo, 1, 1, 3)
, _bloomThreshouldMin(BloomThreshouldMinInfo, 0.5, 0.0, 100.0)
, _bloomThreshouldMax(BloomThreshouldMaxInfo, 1.0, 0.0, 100.0)
, _bloomOrigColorFactor(BloomOrigColorFactorInfo, 1.0, 0.0, 100.0)
, _bloomNewColorFactor(BloomNewColorFactorInfo, 1.0, 0.0, 100.0)
, _tmoOwner(TMOInfo)
, _hdrExposure(HDRExposureInfo, 1.68f, 0.01f, 10.0f)
, _maxWhite(MaxWhiteInfo, 4.f, 0.001f, 100.0f)
@@ -534,59 +478,6 @@ RenderEngine::RenderEngine()
//this->addPropertySubOwner(_imageOwner);
_enableBloom.onChange([this]() {
if (_renderer) {
_renderer->enableBloom(_enableBloom);
}
});
addProperty(_enableBloom);
_automaticBloom.onChange([this]() {
if (_renderer) {
_renderer->enableAutomaticBloom(_automaticBloom);
_renderer->enableBloom(_automaticBloom);
}
});
addProperty(_automaticBloom);
_bloomBlurrinessLevel.onChange([this]() {
if (_renderer) {
_renderer->setBlurrinessLevel(_bloomBlurrinessLevel);
}
});
addProperty(_bloomBlurrinessLevel);
addProperty(_bloomThreshouldMin);
_bloomThreshouldMin.onChange([this]() {
if (_renderer) {
_renderer->setBloomThreMin(_bloomThreshouldMin);
}
});
addProperty(_bloomThreshouldMax);
_bloomThreshouldMax.onChange([this]() {
if (_renderer) {
_renderer->setBloomThreMax(_bloomThreshouldMax);
}
});
addProperty(_bloomOrigColorFactor);
_bloomOrigColorFactor.onChange([this]() {
if (_renderer) {
_renderer->setBloomOrigFactor(_bloomOrigColorFactor);
}
});
addProperty(_bloomNewColorFactor);
_bloomNewColorFactor.onChange([this]() {
if (_renderer) {
_renderer->setBloomNewFactor(_bloomNewColorFactor);
}
});
//this->addPropertySubOwner(_bloomOwner);
addProperty(_globalBlackOutFactor);
addProperty(_applyWarping);
@@ -1283,14 +1174,6 @@ scripting::LuaLibrary RenderEngine::luaLibrary() {
};
}
const RenderEngine::GLDefaultState& RenderEngine::glDefaultState() const {
return _glDefaultState;
}
void RenderEngine::setGLDefaultState(RenderEngine::GLDefaultState glDS) {
_glDefaultState = std::move(glDS);
}
void RenderEngine::addScreenSpaceRenderable(std::unique_ptr<ScreenSpaceRenderable> s) {
const std::string identifier = s->identifier();