mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-07 04:00:37 -06:00
Added HDR bypass.
This commit is contained in:
@@ -138,6 +138,7 @@ public:
|
||||
void setSaturation(float sat) override;
|
||||
|
||||
int nAaSamples() const override;
|
||||
void disableHDR(bool disable) override;
|
||||
|
||||
void update() override;
|
||||
void performRaycasterTasks(const std::vector<RaycasterTask>& tasks);
|
||||
@@ -197,6 +198,7 @@ private:
|
||||
|
||||
glm::ivec2 _resolution = glm::ivec2(0);
|
||||
int _nAaSamples;
|
||||
bool _disableHDR = false;
|
||||
|
||||
float _hdrExposure = 3.7f;
|
||||
float _gamma = 0.95f;
|
||||
|
||||
@@ -56,6 +56,7 @@ public:
|
||||
virtual void setValue(float value) = 0;
|
||||
virtual void setSaturation(float sat) = 0;
|
||||
virtual int nAaSamples() const = 0;
|
||||
virtual void disableHDR(bool disable) = 0;
|
||||
|
||||
/**
|
||||
* Set raycasting uniforms on the program object, and setup raycasting.
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <#{fragmentPath}>
|
||||
|
||||
#define exposure #{rendererData.hdrExposure}
|
||||
#define disableHDRPipeline #{rendererData.disableHDR}
|
||||
#define DeltaError 0.013f
|
||||
#define MaxValueColorBuffer 1E10
|
||||
|
||||
@@ -37,7 +38,8 @@ layout(location = 3) out vec4 filterBuffer;
|
||||
void main() {
|
||||
Fragment f = getFragment();
|
||||
|
||||
if (f.disableLDR2HDR) {
|
||||
// Color is already in HDR space
|
||||
if (f.disableLDR2HDR || (disableHDRPipeline == 1)) {
|
||||
_out_color_ = f.color;
|
||||
} else {
|
||||
_out_color_ = vec4((log2(vec3(1.0) - (f.color.rgb - vec3(DeltaError)))/(-exposure)), f.color.a);
|
||||
|
||||
@@ -816,8 +816,13 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, _defaultFBO);
|
||||
glViewport(0, 0, _resolution.x, _resolution.y);
|
||||
|
||||
// Apply the selected TMO on the results and resolve the result for the default FBO
|
||||
applyTMO(blackoutFactor);
|
||||
if (_disableHDR) {
|
||||
resolveMSAA(blackoutFactor);
|
||||
}
|
||||
else {
|
||||
// Apply the selected TMO on the results and resolve the result for the default FBO
|
||||
applyTMO(blackoutFactor);
|
||||
}
|
||||
}
|
||||
|
||||
void FramebufferRenderer::performRaycasterTasks(const std::vector<RaycasterTask>& tasks) {
|
||||
@@ -1016,27 +1021,31 @@ void FramebufferRenderer::setNAaSamples(int nAaSamples) {
|
||||
_dirtyMsaaSamplingPattern = true;
|
||||
}
|
||||
|
||||
void FramebufferRenderer::disableHDR(bool disable) {
|
||||
_disableHDR = std::move(disable);
|
||||
}
|
||||
|
||||
void FramebufferRenderer::setHDRExposure(float hdrExposure) {
|
||||
ghoul_assert(hdrExposure > 0.f, "HDR exposure must be greater than zero");
|
||||
_hdrExposure = hdrExposure;
|
||||
_hdrExposure = std::move(hdrExposure);
|
||||
updateRendererData();
|
||||
}
|
||||
|
||||
void FramebufferRenderer::setGamma(float gamma) {
|
||||
ghoul_assert(gamma > 0.f, "Gamma value must be greater than zero");
|
||||
_gamma = gamma;
|
||||
_gamma = std::move(gamma);
|
||||
}
|
||||
|
||||
void FramebufferRenderer::setHue(float hue) {
|
||||
_hue = hue;
|
||||
_hue = std::move(hue);
|
||||
}
|
||||
|
||||
void FramebufferRenderer::setValue(float value) {
|
||||
_value = value;
|
||||
_value = std::move(value);
|
||||
}
|
||||
|
||||
void FramebufferRenderer::setSaturation(float sat) {
|
||||
_saturation = sat;
|
||||
_saturation = std::move(sat);
|
||||
}
|
||||
|
||||
int FramebufferRenderer::nAaSamples() const {
|
||||
@@ -1047,6 +1056,7 @@ void FramebufferRenderer::updateRendererData() {
|
||||
ghoul::Dictionary dict;
|
||||
dict.setValue("fragmentRendererPath", std::string(RenderFragmentShaderPath));
|
||||
dict.setValue("hdrExposure", std::to_string(_hdrExposure));
|
||||
dict.setValue("disableHDR", std::to_string(_disableHDR));
|
||||
_rendererData = dict;
|
||||
global::renderEngine.setRendererData(dict);
|
||||
}
|
||||
|
||||
@@ -319,7 +319,7 @@ RenderEngine::RenderEngine()
|
||||
|
||||
_disableHDRPipeline.onChange([this]() {
|
||||
if (_renderer) {
|
||||
//_renderer->setHDRExposure(_hdrExposure);
|
||||
_renderer->disableHDR(_disableHDRPipeline);
|
||||
}
|
||||
});
|
||||
addProperty(_disableHDRPipeline);
|
||||
|
||||
Reference in New Issue
Block a user