Blue Brain BioExplorer
RenderingParameters.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2024, EPFL/Blue Brain Project
3  * All rights reserved. Do not distribute without permission.
4  *
5  * This file is part of Blue Brain BioExplorer <https://github.com/BlueBrain/BioExplorer>
6  *
7  * This library is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU Lesser General Public License version 3.0 as published
9  * by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14  * details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #include "RenderingParameters.h"
23 
24 namespace
25 {
26 const std::string PARAM_ACCUMULATION = "disable-accumulation";
27 const std::string PARAM_BACKGROUND_COLOR = "background-color";
28 const std::string PARAM_CAMERA = "camera";
29 const std::string PARAM_RENDERER = "renderer";
30 const std::string PARAM_VARIANCE_THRESHOLD = "variance-threshold";
31 const std::string PARAM_NUM_NON_DENOISED_FRAMES = "num-non-denoised-frames";
32 const std::string PARAM_DENOISE_BLEND = "denoise-blend";
33 const std::string PARAM_TONE_MAPPER_EXPOSURE = "tone-mapper-exposure";
34 const std::string PARAM_TONE_MAPPER_GAMMA = "tone-mapper-gamma";
35 
36 const std::string ACCUMULATION_TYPES[3] = {"none", "linear", "ai-denoised"};
37 } // namespace
38 
39 namespace core
40 {
42  : AbstractParameters("Rendering")
43 {
44  _parameters.add_options() //
45  (PARAM_RENDERER.c_str(), po::value<std::string>(),
46  "The renderer to use") //
47  (PARAM_ACCUMULATION.c_str(), po::bool_switch()->default_value(false),
48  "Disable accumulation") //
49  (PARAM_CAMERA.c_str(), po::value<std::string>(),
50  "The camera to use") //
51  (PARAM_VARIANCE_THRESHOLD.c_str(), po::value<double>(&_varianceThreshold),
52  "Threshold for adaptive accumulation [float]") //
53  (PARAM_NUM_NON_DENOISED_FRAMES.c_str(), po::value<uint32_t>(&_numNonDenoisedFrames), //
54  "Optix 6 only: Number of frames that show the original image before switching on denoising"),
55  (PARAM_DENOISE_BLEND.c_str(), po::value<float>(&_denoiseBlend), //
56  "Optix 6 only: Amount of the original image that is blended with the denoised result ranging from 0.0 to 1.0"),
57  (PARAM_TONE_MAPPER_EXPOSURE.c_str(), po::value<float>(&_toneMapperExposure), //
58  "Optix 6 only: Tone mapper exposure"),
59  (PARAM_TONE_MAPPER_GAMMA.c_str(), po::value<float>(&_toneMapperGamma), //
60  "Optix 6 only: Tone mapper gamma");
61 }
62 
63 void RenderingParameters::parse(const po::variables_map& vm)
64 {
65  if (vm.count(PARAM_RENDERER))
66  {
67  const std::string& rendererName = vm[PARAM_RENDERER].as<std::string>();
68  addRenderer(rendererName);
69  }
70  if (vm.count(PARAM_CAMERA))
71  {
72  const std::string& cameraName = vm[PARAM_CAMERA].as<std::string>();
73  _camera = cameraName;
74  if (std::find(_cameras.begin(), _cameras.end(), cameraName) == _cameras.end())
75  _cameras.push_front(cameraName);
76  }
77  markModified();
78 }
79 
81 {
82  return ACCUMULATION_TYPES[static_cast<size_t>(value)];
83 }
84 
86 {
88  CORE_INFO("Supported renderers : ");
89  for (const auto& renderer : _renderers)
90  CORE_INFO("- " << renderer);
91  CORE_INFO("Camera : " << _camera);
92  CORE_INFO("Accumulation type : " << getAccumulationTypeAsString(_accumulationType));
93  CORE_INFO("Number of non-denoised frames : " << _numNonDenoisedFrames);
94  CORE_INFO("Denoise blend : " << _denoiseBlend);
95  CORE_INFO("Tone mapper exposure : " << _toneMapperExposure);
96  CORE_INFO("Tone mapper gamma : " << _toneMapperGamma);
97 }
98 } // namespace core
po::options_description _parameters
void markModified(const bool triggerCallback=true)
Definition: BaseObject.h:65
void parse(const po::variables_map &vm) final
std::deque< std::string > _renderers
std::deque< std::string > _cameras
void addRenderer(const std::string &renderer)
const std::string getAccumulationTypeAsString(const AccumulationType value)
AccumulationType _accumulationType
AccumulationType
Definition: Types.h:215
#define CORE_INFO(__msg)
Definition: Logs.h:33