| 186 | } |
| 187 | |
| 188 | bool RendererBase::updatePostProcessingGPUStruct(PostProcessing* pStaging) |
| 189 | { |
| 190 | PostProcessing settings; |
| 191 | |
| 192 | // Compute the scene range, i.e. the near and far distance of the scene bounding box from the |
| 193 | // current view. Since the view has a direction along the -Z axis, the range is determined as |
| 194 | // [-maxZ, -minZ]. |
| 195 | Foundation::BoundingBox viewBox = _pScene->bounds().transform(_cameraView); |
| 196 | vec2 sceneRange(-viewBox.max().z, -viewBox.min().z); |
| 197 | |
| 198 | // Prepare post-processing settings. |
| 199 | int debugMode = _values.asInt(kLabelDebugMode); |
| 200 | settings.debugMode = glm::max(0, glm::min(debugMode, kMaxDebugMode)); |
| 201 | settings.isDenoisingEnabled = _values.asBoolean(kLabelIsDenoisingEnabled) ? 1 : 0; |
| 202 | settings.isToneMappingEnabled = _values.asBoolean(kLabelIsToneMappingEnabled); |
| 203 | settings.isGammaCorrectionEnabled = _values.asBoolean(kLabelIsGammaCorrectionEnabled); |
| 204 | settings.isAlphaEnabled = _values.asBoolean(kLabelIsAlphaEnabled); |
| 205 | settings.brightness = _values.asFloat3(kLabelBrightness); |
| 206 | settings.range = sceneRange; |
| 207 | |
| 208 | // If there are no changes compared local CPU copy, then do nothing and return false. |
| 209 | if (memcmp(&_postProcessingData, &settings, sizeof(PostProcessing)) == 0) |
| 210 | return false; // No changes. |
| 211 | |
| 212 | // Update local CPU copy. |
| 213 | _postProcessingData = settings; |
| 214 | |
| 215 | // Update staging buffer, if one provided. |
| 216 | if (pStaging) |
| 217 | *pStaging = settings; |
| 218 | |
| 219 | return true; |
| 220 | } |
| 221 | |
| 222 | bool RendererBase::updateAccumulationGPUStruct(uint32_t sampleIndex, Accumulation* pStaging) |
| 223 | { |